File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { expect , test } from './helpers/fixtures' ;
22
33test . describe ( 'dashboard' , ( ) => {
4- test . beforeEach ( async ( { login, page } ) => {
5- await login ( ) ;
6- await expect ( page ) . toHaveURL ( '/dashboard' ) ;
7- } ) ;
8-
94 test ( 'should display the dashboard header' , async ( { getPageModel } ) => {
10- const dashboardPage = getPageModel ( '/dashboard' ) ;
5+ const dashboardPage = await getPageModel ( '/dashboard' ) ;
116 await expect ( dashboardPage . pageHeader ) . toBeVisible ( ) ;
127 await expect ( dashboardPage . pageHeader ) . toContainText ( 'Dashboard' ) ;
138 } ) ;
Original file line number Diff line number Diff line change @@ -34,10 +34,16 @@ const pageModels = {
3434} satisfies { [ K in RouteTo ] ?: any } ;
3535
3636export const test = base . extend < TestArgs , WorkerArgs > ( {
37- getPageModel : ( { page } , use ) => {
37+ getPageModel : ( { getProjectAuth , page } , use ) => {
3838 return use (
3939 async < TKey extends Extract < keyof PageModels , RouteTo > > ( key : TKey , ...args : NavigateVariadicArgs < TKey > ) => {
4040 const pageModel = new pageModels [ key ] ( page ) as InstanceType < PageModels [ TKey ] > ;
41+ if ( pageModel . _requiresAuth ) {
42+ const auth = await getProjectAuth ( ) ;
43+ await page . addInitScript ( ( accessToken ) => {
44+ window . __PLAYWRIGHT_ACCESS_TOKEN__ = accessToken ;
45+ } , auth . accessToken ) ;
46+ }
4147 await pageModel . goto ( key , ...args ) ;
4248 return pageModel ;
4349 }
You can’t perform that action at this time.
0 commit comments