-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(test) O3-2823: Reuse signed in state in E2E tests (#921)
* O3-2823: Reuse signed in state in esm-core E2E tests excluding login test * Add step to access the home page
- Loading branch information
Showing
7 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { request } from '@playwright/test'; | ||
import * as dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
/** | ||
* This configuration is to reuse the signed-in state in the tests | ||
* by log in only once using the API and then skip the log in step for all the tests. | ||
* | ||
* https://playwright.dev/docs/auth#reuse-signed-in-state | ||
*/ | ||
|
||
async function globalSetup() { | ||
const requestContext = await request.newContext(); | ||
const token = Buffer.from(`${process.env.E2E_USER_ADMIN_USERNAME}:${process.env.E2E_USER_ADMIN_PASSWORD}`).toString( | ||
'base64', | ||
); | ||
await requestContext.post(`${process.env.E2E_BASE_URL}/ws/rest/v1/session`, { | ||
data: { | ||
sessionLocation: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID, | ||
locale: 'en', | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Basic ${token}`, | ||
}, | ||
}); | ||
await requestContext.storageState({ path: 'e2e/storageState.json' }); | ||
await requestContext.dispose(); | ||
} | ||
|
||
export default globalSetup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { type Page } from '@playwright/test'; | ||
|
||
export class HomePage { | ||
constructor(readonly page: Page) {} | ||
|
||
async goto() { | ||
await this.page.goto('home'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './login-page'; | ||
export * from './home-page'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters