@@ -17,60 +17,66 @@ const mockProtectSettings = async (page: Page, config?: ProtectConfigJSON) => {
1717 } ) ;
1818} ;
1919
20- testAgainstRunningApps ( { withEnv : [ appConfigs . envs . withEmailCodes ] } ) ( 'Clerk Protect checks @generic' , ( { app } ) => {
21- test . describe . configure ( { mode : 'parallel' } ) ;
20+ testAgainstRunningApps ( { withEnv : [ appConfigs . envs . withProtectService ] } ) (
21+ 'Clerk Protect checks @generic' ,
22+ ( { app } ) => {
23+ test . describe . configure ( { mode : 'parallel' } ) ;
2224
23- test . afterAll ( async ( ) => {
24- await app . teardown ( ) ;
25- } ) ;
26-
27- test ( 'should add loader script when protect_config.loader is set' , async ( { page, context } ) => {
28- const u = createTestUtils ( { app, page, context } ) ;
29- await mockProtectSettings ( page , {
30- object : 'protect_config' ,
31- id : 'n' ,
32- loaders : [
33- {
34- rollout : 1.0 ,
35- type : 'script' ,
36- target : 'body' ,
37- attributes : { id : 'test-protect-loader-1' , type : 'module' , src : 'data:application/json;base64,Cgo=' } ,
38- } ,
39- ] ,
25+ test . afterAll ( async ( ) => {
26+ await app . teardown ( ) ;
4027 } ) ;
41- await u . page . goToAppHome ( ) ;
42- await u . page . waitForClerkJsLoaded ( ) ;
4328
44- await expect ( page . locator ( '#test-protect-loader-1' ) ) . toHaveAttribute ( 'type' , 'module' ) ;
45- } ) ;
29+ test ( 'should add loader script when protect_config.loader is set' , async ( { page, context } ) => {
30+ const u = createTestUtils ( { app, page, context } ) ;
31+ await mockProtectSettings ( page , {
32+ object : 'protect_config' ,
33+ id : 'n' ,
34+ loaders : [
35+ {
36+ rollout : 1.0 ,
37+ type : 'script' ,
38+ target : 'body' ,
39+ attributes : { id : 'test-protect-loader-1' , type : 'module' , src : 'data:application/json;base64,Cgo=' } ,
40+ } ,
41+ ] ,
42+ } ) ;
43+ await u . page . goToAppHome ( ) ;
44+ await u . page . waitForClerkJsLoaded ( ) ;
4645
47- test ( 'should not add loader script when protect_config.loader is set and rollout 0.00' , async ( { page, context } ) => {
48- const u = createTestUtils ( { app, page, context } ) ;
49- await mockProtectSettings ( page , {
50- object : 'protect_config' ,
51- id : 'n' ,
52- loaders : [
53- {
54- rollout : 0 , // force 0% rollout, should not materialize
55- type : 'script' ,
56- target : 'body' ,
57- attributes : { id : 'test-protect-loader-2' , type : 'module' , src : 'data:application/json;base64,Cgo=' } ,
58- } ,
59- ] ,
46+ await expect ( page . locator ( '#test-protect-loader-1' ) ) . toHaveAttribute ( 'type' , 'module' ) ;
6047 } ) ;
61- await u . page . goToAppHome ( ) ;
62- await u . page . waitForClerkJsLoaded ( ) ;
6348
64- await expect ( page . locator ( '#test-protect-loader-2' ) ) . toHaveCount ( 0 ) ;
65- } ) ;
49+ test ( 'should not add loader script when protect_config.loader is set and rollout 0.00' , async ( {
50+ page,
51+ context,
52+ } ) => {
53+ const u = createTestUtils ( { app, page, context } ) ;
54+ await mockProtectSettings ( page , {
55+ object : 'protect_config' ,
56+ id : 'n' ,
57+ loaders : [
58+ {
59+ rollout : 0 , // force 0% rollout, should not materialize
60+ type : 'script' ,
61+ target : 'body' ,
62+ attributes : { id : 'test-protect-loader-2' , type : 'module' , src : 'data:application/json;base64,Cgo=' } ,
63+ } ,
64+ ] ,
65+ } ) ;
66+ await u . page . goToAppHome ( ) ;
67+ await u . page . waitForClerkJsLoaded ( ) ;
6668
67- test ( 'should not create loader element when protect_config.loader is not set' , async ( { page, context } ) => {
68- const u = createTestUtils ( { app, page, context } ) ;
69- await mockProtectSettings ( page ) ;
70- await u . page . goToAppHome ( ) ;
71- await u . page . waitForClerkJsLoaded ( ) ;
69+ await expect ( page . locator ( '#test-protect-loader-2' ) ) . toHaveCount ( 0 ) ;
70+ } ) ;
7271
73- // Playwright locators are always objects, never undefined
74- await expect ( page . locator ( '#test-protect-loader' ) ) . toHaveCount ( 0 ) ;
75- } ) ;
76- } ) ;
72+ test ( 'should not create loader element when protect_config.loader is not set' , async ( { page, context } ) => {
73+ const u = createTestUtils ( { app, page, context } ) ;
74+ await mockProtectSettings ( page ) ;
75+ await u . page . goToAppHome ( ) ;
76+ await u . page . waitForClerkJsLoaded ( ) ;
77+
78+ // Playwright locators are always objects, never undefined
79+ await expect ( page . locator ( '#test-protect-loader' ) ) . toHaveCount ( 0 ) ;
80+ } ) ;
81+ } ,
82+ ) ;
0 commit comments