This repository was archived by the owner on Jul 14, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,19 +47,25 @@ export const logInWithUsernameAndPassword = async (
4747 await passwordField . press ( "Enter" ) ;
4848
4949 await expect ( async ( ) => {
50- expect ( page . url ( ) ) . toBe (
50+ expect ( page . url ( ) ) . toContain (
5151 `${ process . env . BASE_URL } /insights/content/repositories`
5252 ) ;
5353 } ) . toPass ( ) ;
5454} ;
5555
5656export const switchToUser = async ( page : Page , userName : string ) => {
57+ const storagePath = path . join ( __dirname , `../../.auth/${ userName } .json` ) ;
5758 const { cookies } = await page . context ( ) . storageState ( {
58- path : path . join ( __dirname , `../../.auth/ ${ userName } .json` ) ,
59+ path : storagePath ,
5960 } ) ;
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 } ` ;
6369 await page . waitForTimeout ( 100 ) ;
6470} ;
6571
You can’t perform that action at this time.
0 commit comments