@@ -3,21 +3,25 @@ import { expect } from '@playwright/test';
3
3
import { sentryTest } from '../../../../utils/fixtures' ;
4
4
5
5
import { envelopeRequestParser , waitForErrorRequest } from '../../../../utils/helpers' ;
6
- import { buildLaunchDarklyFlagUsedHandler } from '@sentry/browser' ;
7
- import type { LDContext , LDOptions , LDFlagValue , LDClient } from 'launchdarkly-js-client-sdk' ;
6
+ import type { LDContext , LDOptions , LDFlagValue , LDClient , LDEvaluationDetail } from 'launchdarkly-js-client-sdk' ;
8
7
import type { Event } from '@sentry/types' ;
9
8
10
- // const MockLaunchDarkly = { //TODO:
9
+ // const MockLaunchDarkly = { //TODO: remove in favor of window.MockLaunchDarkly from init.js
11
10
// initialize(
12
11
// _clientId: string,
13
12
// context: LDContext,
14
13
// options: LDOptions,
15
14
// ) {
16
15
// const flagUsedHandler = options?.inspectors?.[0].method;
16
+ // const wellTypedHandler = flagUsedHandler as ((
17
+ // flagKey: string,
18
+ // flagDetail: LDEvaluationDetail,
19
+ // context: LDContext,
20
+ // ) => void) | undefined;
17
21
18
22
// return {
19
23
// variation(key: string, defaultValue: LDFlagValue) {
20
- // flagUsedHandler ?.(key, { value: defaultValue }, context);
24
+ // wellTypedHandler ?.(key, { value: defaultValue }, context);
21
25
// return defaultValue;
22
26
// },
23
27
// };
@@ -44,24 +48,24 @@ sentryTest('e2e test', async ({ getLocalTestPath, page }) => {
44
48
await page . goto ( url ) ;
45
49
46
50
// TODO: could this be in init.js?
47
- const ldClient = await page . evaluate ( ( ) => {
48
- return ( window as any ) . MockLaunchDarkly . initialize (
49
- 'example-client-id' ,
50
- { kind : 'user' , key : 'example-context-key' } ,
51
- { inspectors : [ buildLaunchDarklyFlagUsedHandler ( ) ] } ,
52
- ) as LDClient ;
51
+ await page . waitForFunction ( ( ) => {
52
+ const ldClient = ( window as any ) . InitializeLD ( ) ;
53
+ ldClient . variation ( 'feat1' , false ) ;
54
+ ldClient . variation ( 'feat2' , false ) ;
55
+ ldClient . variation ( 'feat3' , false ) ;
56
+ ldClient . variation ( 'feat2' , true ) ;
57
+ return true ;
53
58
} ) ;
54
59
55
- ldClient . variation ( 'feat1' , false ) ;
56
- ldClient . variation ( 'feat2' , false ) ;
57
- ldClient . variation ( 'feat3' , false ) ;
58
- ldClient . variation ( 'feat2' , true ) ;
60
+
59
61
// TODO: eviction not tested
60
62
61
63
// trigger error
64
+ const reqPromise = waitForErrorRequest ( page ) ;
62
65
await page . locator ( '#error' ) . click ( ) ;
66
+ const req = await reqPromise ;
63
67
64
- const req = await waitForErrorRequest ( page ) ;
68
+ // console.log(errorEventId );
65
69
const event = envelopeRequestParser ( req ) ;
66
70
67
71
expect ( event . contexts ?. flags ?. values ) . toEqual ( [
0 commit comments