Skip to content

Commit

Permalink
fix(browser-integration-tests): Fix feedback addon CDN bundle integra…
Browse files Browse the repository at this point in the history
…tion test setup (#13108)

- Add symlinks to lazy-loaded feedback sub-integrations whenever we discover that `feedbackIntegration` is
imported in a test app
- Stop forwarding the CDN bundle request to the actual CDN but throw a
hard error instead
  • Loading branch information
Lms24 committed Jul 30, 2024
1 parent d222dd5 commit d73a567
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dev-packages/browser-integration-tests/utils/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ const sentryTest = base.extend<TestFixtures>({
// Ensure feedback can be lazy loaded
await page.route(`https://browser.sentry-cdn.com/${SDK_VERSION}/feedback-modal.min.js`, route => {
const filePath = path.resolve(testDir, './dist/feedback-modal.bundle.js');
return fs.existsSync(filePath) ? route.fulfill({ path: filePath }) : route.continue();
if (!fs.existsSync(filePath)) {
throw new Error(`Feedback modal bundle (${filePath}) not found`);
}
return route.fulfill({ path: filePath });
});

await page.route(`https://browser.sentry-cdn.com/${SDK_VERSION}/feedback-screenshot.min.js`, route => {
const filePath = path.resolve(testDir, './dist/feedback-screenshot.bundle.js');
return fs.existsSync(filePath) ? route.fulfill({ path: filePath }) : route.continue();
if (!fs.existsSync(filePath)) {
throw new Error(`Feedback screenshot bundle (${filePath}) not found`);
}
return route.fulfill({ path: filePath });
});
}

Expand Down
13 changes: 13 additions & 0 deletions dev-packages/browser-integration-tests/utils/generatePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ class SentryScenarioGenerationPlugin {
fileName,
);

if (integration === 'feedback') {
addStaticAssetSymlink(
this.localOutPath,
path.resolve(PACKAGES_DIR, 'feedback', 'build/bundles/feedback-modal.js'),
'feedback-modal.bundle.js',
);
addStaticAssetSymlink(
this.localOutPath,
path.resolve(PACKAGES_DIR, 'feedback', 'build/bundles/feedback-screenshot.js'),
'feedback-screenshot.bundle.js',
);
}

const integrationObject = createHtmlTagObject('script', {
src: fileName,
});
Expand Down

0 comments on commit d73a567

Please sign in to comment.