@@ -3,40 +3,9 @@ import { expect } from '@playwright/test';
33import { sentryTest } from '../../../../utils/fixtures' ;
44
55import { 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- // };
306
317sentryTest ( 'e2e test' , async ( { getLocalTestPath, page } ) => {
32- let errorEventId : string = 'invalid_id' ;
338 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-
409 return route . fulfill ( {
4110 status : 200 ,
4211 contentType : 'application/json' ,
@@ -47,30 +16,27 @@ sentryTest('e2e test', async ({ getLocalTestPath, page }) => {
4716 const url = await getLocalTestPath ( { testDir : __dirname , skipDsnRouteHandler : true } ) ;
4817 await page . goto ( url ) ;
4918
50- // TODO: could this be in init.js?
5119 await page . waitForFunction ( ( ) => {
5220 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
5726 return true ;
5827 } ) ;
5928
60-
61- // TODO: eviction not tested
62-
63- // trigger error
6429 const reqPromise = waitForErrorRequest ( page ) ;
6530 await page . locator ( '#error' ) . click ( ) ;
6631 const req = await reqPromise ;
67-
68- // console.log(errorEventId);
6932 const event = envelopeRequestParser ( req ) ;
7033
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 ) ;
7642} ) ;
0 commit comments