🧑💻(e2e) display more information when auth fails
When the auth fails, it was quite obscure to understand what was going on. We now take a screenshot of the page and display the console logs.
This commit is contained in:
1
src/frontend/apps/e2e/.gitignore
vendored
1
src/frontend/apps/e2e/.gitignore
vendored
@@ -4,3 +4,4 @@ report/
|
|||||||
blob-report/
|
blob-report/
|
||||||
playwright/.auth/
|
playwright/.auth/
|
||||||
playwright/.cache/
|
playwright/.cache/
|
||||||
|
screenshots/
|
||||||
|
|||||||
@@ -12,23 +12,36 @@ const saveStorageState = async (
|
|||||||
const context = await browser.newContext(useConfig);
|
const context = await browser.newContext(useConfig);
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
||||||
await page.goto('/', { waitUntil: 'networkidle' });
|
try {
|
||||||
await page.content();
|
await page.goto('/', { waitUntil: 'networkidle' });
|
||||||
await expect(page.getByText('Docs').first()).toBeVisible();
|
await page.content();
|
||||||
|
await expect(page.getByText('Docs').first()).toBeVisible();
|
||||||
|
|
||||||
await keyCloakSignIn(page, browserName);
|
await keyCloakSignIn(page, browserName);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
page.locator('header').first().getByRole('button', {
|
page.locator('header').first().getByRole('button', {
|
||||||
name: 'Logout',
|
name: 'Logout',
|
||||||
}),
|
}),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
|
||||||
await page.context().storageState({
|
await page.context().storageState({
|
||||||
path: storageState as string,
|
path: storageState as string,
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
await browser.close();
|
await page.screenshot({
|
||||||
|
path: `./screenshots/${browserName}-${Date.now()}.png`,
|
||||||
|
});
|
||||||
|
// Get console logs
|
||||||
|
const consoleLogs = await page.evaluate(() =>
|
||||||
|
console.log(window.console.log),
|
||||||
|
);
|
||||||
|
console.log(consoleLogs);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
async function globalSetup(config: FullConfig) {
|
||||||
|
|||||||
Reference in New Issue
Block a user