From 6f9e39832d5ed9ecafb243f4ec9d61396ee13e54 Mon Sep 17 00:00:00 2001 From: Michael-Kruggel Date: Thu, 18 Jul 2024 19:12:50 +0000 Subject: [PATCH] CI debug --- tests/auth.setup.ts | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/auth.setup.ts b/tests/auth.setup.ts index c63348c..c9adb62 100644 --- a/tests/auth.setup.ts +++ b/tests/auth.setup.ts @@ -2,24 +2,27 @@ import { test as setup, expect } from '@playwright/test'; import { authFile } from './playwright.config'; setup('authenticate', async ({ page, context, baseURL }) => { - await page.goto(baseURL); - await page.getByLabel("Username or email").fill("doug"); - await page.getByLabel("Password").fill("unicorn123!@#"); - await page.getByRole("button", { name: "Log In" }).click(); + try { + await page.goto(baseURL); + await page.getByLabel("Username or email").fill("doug"); + await page.getByLabel("Password").fill("unicorn123!@#"); + await page.getByRole("button", { name: "Log In" }).click(); - // ensure auth cookies were set - const cookies = await context.cookies(); - const keycloakCookie = cookies.find( - (cookie) => cookie.name === "KEYCLOAK_SESSION", - ); + // ensure auth cookies were set + const cookies = await context.cookies(); + const keycloakCookie = cookies.find( + (cookie) => cookie.name === "KEYCLOAK_SESSION", + ); - expect(keycloakCookie).toBeDefined(); - expect(keycloakCookie?.value).not.toBe(""); - expect(keycloakCookie?.domain).toContain("sso."); + expect(keycloakCookie).toBeDefined(); + expect(keycloakCookie?.value).not.toBe(""); + expect(keycloakCookie?.domain).toContain("sso."); - await page.context().storageState({ path: authFile }); + await page.context().storageState({ path: authFile }); - await page.waitForURL(baseURL); // successful redirect - - await expect(page).toHaveURL(baseURL); + await expect(page).toHaveURL(baseURL); + } catch (error) { + await page.screenshot({ path: 'screenshot.png' }); + throw error; // rethrow the error after taking the screenshot +} })