@@ -3,40 +3,9 @@ import { expect } from '@playwright/test';
3
3
import { sentryTest } from '../../../../utils/fixtures' ;
4
4
5
5
import { envelopeRequestParser , waitForErrorRequest } from '../../../../utils/helpers' ;
6
- import type { LDContext , LDOptions , LDFlagValue , LDClient , LDEvaluationDetail } from 'launchdarkly-js-client-sdk' ;
7
- import type { Event } from '@sentry/types' ;
8
-
9
- // const MockLaunchDarkly = { //TODO: remove in favor of window.MockLaunchDarkly from init.js
10
- // initialize(
11
- // _clientId: string,
12
- // context: LDContext,
13
- // options: LDOptions,
14
- // ) {
15
- // const flagUsedHandler = options?.inspectors?.[0].method;
16
- // const wellTypedHandler = flagUsedHandler as ((
17
- // flagKey: string,
18
- // flagDetail: LDEvaluationDetail,
19
- // context: LDContext,
20
- // ) => void) | undefined;
21
-
22
- // return {
23
- // variation(key: string, defaultValue: LDFlagValue) {
24
- // wellTypedHandler?.(key, { value: defaultValue }, context);
25
- // return defaultValue;
26
- // },
27
- // };
28
- // },
29
- // };
30
6
31
7
sentryTest ( 'e2e test' , async ( { getLocalTestPath, page } ) => {
32
- let errorEventId : string = 'invalid_id' ;
33
8
await page . route ( 'https://dsn.ingest.sentry.io/**/*' , route => {
34
- const event = envelopeRequestParser ( route . request ( ) ) ;
35
- // error events have no type field
36
- if ( event && ! event . type && event . event_id ) {
37
- errorEventId = event . event_id ;
38
- }
39
-
40
9
return route . fulfill ( {
41
10
status : 200 ,
42
11
contentType : 'application/json' ,
@@ -47,30 +16,27 @@ sentryTest('e2e test', async ({ getLocalTestPath, page }) => {
47
16
const url = await getLocalTestPath ( { testDir : __dirname , skipDsnRouteHandler : true } ) ;
48
17
await page . goto ( url ) ;
49
18
50
- // TODO: could this be in init.js?
51
19
await page . waitForFunction ( ( ) => {
52
20
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 ) ;
21
+ for ( let i = 1 ; i <= 100 ; i ++ ) { // TODO: import constant for buffer size
22
+ ldClient . variation ( `feat${ i } ` , false ) ;
23
+ }
24
+ ldClient . variation ( 'feat101' , true ) ; // eviction
25
+ ldClient . variation ( 'feat3' , true ) ; // update
57
26
return true ;
58
27
} ) ;
59
28
60
-
61
- // TODO: eviction not tested
62
-
63
- // trigger error
64
29
const reqPromise = waitForErrorRequest ( page ) ;
65
30
await page . locator ( '#error' ) . click ( ) ;
66
31
const req = await reqPromise ;
67
-
68
- // console.log(errorEventId);
69
32
const event = envelopeRequestParser ( req ) ;
70
33
71
- expect ( event . contexts ?. flags ?. values ) . toEqual ( [
72
- { flag : 'feat1' , result : false } ,
73
- { flag : 'feat3' , result : false } ,
74
- { flag : 'feat2' , result : true } ,
75
- ] ) ;
34
+ const expectedFlags = [ { flag : 'feat2' , result : false } ] ;
35
+ for ( let i = 4 ; i <= 100 ; i ++ ) {
36
+ expectedFlags . push ( { flag : `feat${ i } ` , result : false } ) ;
37
+ }
38
+ expectedFlags . push ( { flag : 'feat101' , result : true } ) ;
39
+ expectedFlags . push ( { flag : 'feat3' , result : true } ) ;
40
+
41
+ expect ( event . contexts ?. flags ?. values ) . toEqual ( expectedFlags ) ;
76
42
} ) ;
0 commit comments