Skip to content

Commit f40366a

Browse files
authored
test: improve privacy snapshot generation (#38571)
## **Description** - Our code was generating new privacy snapshots that did not end with a newline, and then failed Prettier lint. It now ends with a newline. - One of the unit tests was using `o124216.ingest.us.sentry.io`, which works, but lands at the same place as the simpler `sentry.io` we use everywhere else. I changed it to be simpler and more consistent. ## **Changelog** CHANGELOG entry: null <!--## **Related issues** ## **Manual testing steps** ## **Screenshots/Recordings** ## **Pre-merge author checklist** ## **Pre-merge reviewer checklist**--> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds a trailing newline when writing `privacy-snapshot.json` and updates Sentry DSN test URLs/expectations to `sentry.io`. > > - **Tests**: > - **E2E (`test/e2e/helpers.js`)**: Write `privacy-snapshot.json` with a trailing newline to satisfy prettier. > - **Unit (`ui/helpers/utils/display-critical-error.test.ts`)**: Update mocked DSNs to `sentry.io` and adjust `extractEnvelopeUrlFromDsn` expected envelope URL accordingly; regional DSN test remains unchanged. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 827f326. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 3781b99 commit f40366a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

test/e2e/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ async function withFixtures(options, testSuite) {
454454
if (process.env.UPDATE_PRIVACY_SNAPSHOT === 'true') {
455455
writeFileSync(
456456
'./privacy-snapshot.json',
457-
JSON.stringify(mergedReport, null, 2),
457+
`${JSON.stringify(mergedReport, null, 2)}\n`, // must add trailing newline to satisfy prettier
458458
);
459459
} else {
460460
throw new Error(

ui/helpers/utils/display-critical-error.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jest.mock('webextension-polyfill', () => ({
2222

2323
// Mock environment variables before importing the module
2424
const MOCK_SENTRY_DSN =
25-
'https://3567c198f8a8412082d32655da2961d0@o124216.ingest.us.sentry.io/273505';
26-
const MOCK_SENTRY_DSN_DEV = 'https://dev123@o124216.ingest.us.sentry.io/273505';
25+
'https://[email protected]/273505';
26+
const MOCK_SENTRY_DSN_DEV = 'https://[email protected]/273505';
2727

2828
const originalEnv = process.env;
2929
process.env = {
@@ -237,12 +237,9 @@ describe('displayCriticalError', () => {
237237

238238
describe('extractEnvelopeUrlFromDsn', () => {
239239
it('should extract correct envelope URL from valid DSN', () => {
240-
const dsn =
241-
'https://[email protected]/273505';
240+
const dsn = 'https://[email protected]/273505';
242241
const result = extractEnvelopeUrlFromDsn(dsn);
243-
expect(result).toBe(
244-
'https://o124216.ingest.us.sentry.io/api/273505/envelope/',
245-
);
242+
expect(result).toBe('https://sentry.io/api/273505/envelope/');
246243
});
247244

248245
it('should handle different regions', () => {

0 commit comments

Comments
 (0)