File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -47,19 +47,25 @@ export const logInWithUsernameAndPassword = async (
47
47
await passwordField . press ( "Enter" ) ;
48
48
49
49
await expect ( async ( ) => {
50
- expect ( page . url ( ) ) . toBe (
50
+ expect ( page . url ( ) ) . toContain (
51
51
`${ process . env . BASE_URL } /insights/content/repositories`
52
52
) ;
53
53
} ) . toPass ( ) ;
54
54
} ;
55
55
56
56
export const switchToUser = async ( page : Page , userName : string ) => {
57
+ const storagePath = path . join ( __dirname , `../../.auth/${ userName } .json` ) ;
57
58
const { cookies } = await page . context ( ) . storageState ( {
58
- path : path . join ( __dirname , `../../.auth/ ${ userName } .json` ) ,
59
+ path : storagePath ,
59
60
} ) ;
60
- process . env . TOKEN = `Bearer ${
61
- cookies . find ( ( cookie ) => cookie . name === "cs_jwt" ) ?. value
62
- } `;
61
+
62
+ const jwtCookie = cookies . find ( ( cookie ) => cookie . name === "cs_jwt" ) ;
63
+
64
+ if ( ! jwtCookie || ! jwtCookie . value ) {
65
+ throw new Error ( `No valid cs_jwt cookie found in storage state for user ${ userName } at ${ storagePath } ` ) ;
66
+ }
67
+
68
+ process . env . TOKEN = `Bearer ${ jwtCookie . value } ` ;
63
69
await page . waitForTimeout ( 100 ) ;
64
70
} ;
65
71
You can’t perform that action at this time.
0 commit comments