Skip to content

Commit 8ec8680

Browse files
committed
Review comments, fix buffer size import, clean up todos
1 parent 7b14926 commit 8ec8680

File tree

4 files changed

+54
-427
lines changed

4 files changed

+54
-427
lines changed

dev-packages/browser-integration-tests/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
"@types/glob": "8.0.0",
5656
"@types/node": "^14.18.0",
5757
"@types/pako": "^2.0.0",
58-
"glob": "8.0.3",
59-
"launchdarkly-js-client-sdk": "^3.5.0"
58+
"glob": "8.0.3"
6059
},
6160
"volta": {
6261
"extends": "../../package.json"

dev-packages/browser-integration-tests/suites/integrations/featureFlags/launchdarkly/init.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
import * as Sentry from '@sentry/browser';
22
import { launchDarklyIntegration, buildLaunchDarklyFlagUsedHandler } from '@sentry/browser';
33

4-
54
window.Sentry = Sentry;
6-
window.LDIntegration = launchDarklyIntegration();
5+
window.sentryLDIntegration = launchDarklyIntegration();
76

87
Sentry.init({
98
dsn: 'https://[email protected]/1337',
109
sampleRate: 1.0,
11-
integrations: [window.LDIntegration],
10+
integrations: [window.sentryLDIntegration],
1211
});
1312

13+
// Manually mocking this because LD only has mock test utils for the React SDK.
14+
// Also, no SDK has mock utils for FlagUsedHandler's.
1415
const MockLaunchDarkly = {
1516
initialize(_clientId, context, options) {
1617
const flagUsedHandler = (options && options.inspectors) ? options.inspectors[0].method : undefined;
1718

1819
return {
1920
variation(key, defaultValue) {
2021
if (flagUsedHandler) {
21-
flagUsedHandler(key, { value: defaultValue }, context); // TODO:this is async atm
22+
flagUsedHandler(key, { value: defaultValue }, context);
2223
}
2324
return defaultValue;
2425
},
2526
};
2627
},
2728
};
2829

29-
window.InitializeLD = () => {
30+
window.initializeLD = () => {
3031
return MockLaunchDarkly.initialize(
3132
'example-client-id',
3233
{ kind: 'user', key: 'example-context-key' },

dev-packages/browser-integration-tests/suites/integrations/featureFlags/launchdarkly/test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { expect } from '@playwright/test';
33
import { sentryTest } from '../../../../utils/fixtures';
44

55
import { envelopeRequestParser, waitForErrorRequest } from '../../../../utils/helpers';
6-
// import { FLAG_BUFFER_SIZE } from '@sentry/browser'; // TODO: not picking up export atm
7-
const FLAG_BUFFER_SIZE = 100;
6+
import { FLAG_BUFFER_SIZE } from '@sentry/browser';
87

98
sentryTest('e2e test', async ({ getLocalTestPath, page }) => {
109
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
@@ -18,22 +17,22 @@ sentryTest('e2e test', async ({ getLocalTestPath, page }) => {
1817
const url = await getLocalTestPath({ testDir: __dirname, skipDsnRouteHandler: true });
1918
await page.goto(url);
2019

21-
await page.waitForFunction(() => {
22-
const ldClient = (window as any).InitializeLD();
23-
for (let i = 1; i <= FLAG_BUFFER_SIZE; i++) { // TODO: import constant for buffer size
20+
await page.waitForFunction((bufferSize) => {
21+
const ldClient = (window as any).initializeLD();
22+
for (let i = 1; i <= bufferSize; i++) {
2423
ldClient.variation(`feat${i}`, false);
2524
}
26-
ldClient.variation(`feat${FLAG_BUFFER_SIZE+1}`, true); // eviction
25+
ldClient.variation(`feat${bufferSize + 1}`, true); // eviction
2726
ldClient.variation('feat3', true); // update
2827
return true;
29-
});
28+
}, FLAG_BUFFER_SIZE);
3029

3130
const reqPromise = waitForErrorRequest(page);
3231
await page.locator('#error').click();
3332
const req = await reqPromise;
3433
const event = envelopeRequestParser(req);
3534

36-
const expectedFlags = [{ flag: 'feat2', result: false }];
35+
const expectedFlags = [{ flag: 'feat2', result: false }]
3736
for (let i = 4; i <= FLAG_BUFFER_SIZE; i++) {
3837
expectedFlags.push({ flag: `feat${i}`, result: false });
3938
}

0 commit comments

Comments
 (0)