From 72f2b17e9a6192429cda8df2a466114f67836cd6 Mon Sep 17 00:00:00 2001 From: vhande Date: Tue, 2 Jul 2024 14:40:11 +0200 Subject: [PATCH 1/5] Fix tests --- e2e/setup/auth.setup.ts | 22 ++++++++------- .../admin/create-integration.test.ts | 4 ++- .../integrations/admin/create-integration.ts | 4 ++- .../integrator/create-integration.test.ts | 17 +++++++----- .../integrator/create-integration.ts | 27 ++++++++++++++++--- 5 files changed, 53 insertions(+), 21 deletions(-) diff --git a/e2e/setup/auth.setup.ts b/e2e/setup/auth.setup.ts index 30163cde2..1a773287e 100644 --- a/e2e/setup/auth.setup.ts +++ b/e2e/setup/auth.setup.ts @@ -5,13 +5,13 @@ setup("authenticate as admin", async ({ page }) => { await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-acc.uitid.be\/*/); + await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); await page - .getByLabel("Je e-mailadres") + .locator('input[name="username"]') .fill(process.env.E2E_TEST_ADMIN_EMAIL!); await page - .getByLabel("Je wachtwoord") + .locator('input[name="password"]') .fill(process.env.E2E_TEST_ADMIN_PASSWORD!); await page.getByRole("button", { name: "Meld je aan", exact: true }).click(); @@ -27,10 +27,14 @@ setup("authenticate as contributor", async ({ page }) => { await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-acc.uitid.be\/*/); + await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); - await page.getByLabel("Je e-mailadres").fill(process.env.E2E_TEST_EMAIL!); - await page.getByLabel("Je wachtwoord").fill(process.env.E2E_TEST_PASSWORD!); + await page + .locator('input[name="username"]') + .fill(process.env.E2E_TEST_EMAIL!); + await page + .locator('input[name="password"]') + .fill(process.env.E2E_TEST_PASSWORD!); await page.getByRole("button", { name: "Meld je aan", exact: true }).click(); @@ -47,13 +51,13 @@ setup( await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-acc.uitid.be\/*/); + await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); await page - .getByLabel("Je e-mailadres") + .locator('input[name="username"]') .fill(process.env.E2E_TEST_V1_EMAIL!); await page - .getByLabel("Je wachtwoord") + .locator('input[name="password"]') .fill(process.env.E2E_TEST_V1_PASSWORD!); await page diff --git a/e2e/tests/integrations/admin/create-integration.test.ts b/e2e/tests/integrations/admin/create-integration.test.ts index 04ae210be..45ce9cd89 100644 --- a/e2e/tests/integrations/admin/create-integration.test.ts +++ b/e2e/tests/integrations/admin/create-integration.test.ts @@ -17,7 +17,9 @@ async function addContactToIntegration( await page.locator("#type").selectOption(type); await page.getByPlaceholder("First Name").fill(faker.person.firstName()); await page.getByPlaceholder("Last Name").fill(faker.person.lastName()); - await page.getByTestId("integrations").selectOption(integrationId!); + await page + .locator("[dusk='integrations-select']") + .selectOption(integrationId!); await page.getByRole("button", { name: "Create Contact" }).click(); await page.waitForURL( diff --git a/e2e/tests/integrations/admin/create-integration.ts b/e2e/tests/integrations/admin/create-integration.ts index b61cda9c0..cdf4df396 100644 --- a/e2e/tests/integrations/admin/create-integration.ts +++ b/e2e/tests/integrations/admin/create-integration.ts @@ -6,6 +6,7 @@ const IntegrationTypeSubscriptionMap: Record = { [IntegrationType.SearchApi]: "b46745a1-feb5-45fd-8fa9-8e3ef25aac26", [IntegrationType.Widgets]: "c470ccbf-074c-4bf1-b526-47c94c5e9296", [IntegrationType.EntryApi]: "6311ba66-91c2-4905-a182-150f1cdf4825", + [IntegrationType.UiTPAS]: "52bb667f-d4da-47cd-9a76-f8896be410bd" }; export async function createIntegration(page: Page, type: IntegrationType) { @@ -19,8 +20,9 @@ export async function createIntegration(page: Page, type: IntegrationType) { await page.locator("#key_visibility").selectOption("all"); await page.getByPlaceholder("Description").fill(faker.lorem.lines(2)); await page - .getByTestId("subscriptions") + .locator("[dusk='subscriptions-select']") .selectOption(IntegrationTypeSubscriptionMap[type]); + await page.getByPlaceholder("Website").fill(faker.internet.url()); await page.getByRole("button", { name: "Create Integration" }).click(); return { name, page }; } diff --git a/e2e/tests/integrations/integrator/create-integration.test.ts b/e2e/tests/integrations/integrator/create-integration.test.ts index 54f95d5ef..bab4617c2 100644 --- a/e2e/tests/integrations/integrator/create-integration.test.ts +++ b/e2e/tests/integrations/integrator/create-integration.test.ts @@ -2,12 +2,17 @@ import { test, expect } from "@playwright/test"; import { createIntegrationAsIntegrator } from "./create-integration.js"; import { IntegrationType } from "@app-types/IntegrationType"; -test.use({ storageState: "playwright/.auth/user.json" }); +const integrationTypeValues = Object.entries(IntegrationType); -test("As an integrator I can create a new integration", async ({ page }) => { - const { integrationName } = await createIntegrationAsIntegrator( +integrationTypeValues.map(([integrationName, integrationType]) => { + test.use({ storageState: "playwright/.auth/user.json" }); + test(`As an integrator I can create a new ${integrationName} integration`, async ({ page, - IntegrationType.SearchApi - ); - await expect(page.getByText(integrationName)).toBeVisible(); + }) => { + const { integrationName } = await createIntegrationAsIntegrator( + page, + integrationType + ); + await expect(page.getByText(integrationName)).toBeVisible(); + }); }); diff --git a/e2e/tests/integrations/integrator/create-integration.ts b/e2e/tests/integrations/integrator/create-integration.ts index d15894f05..2a7b22dd6 100644 --- a/e2e/tests/integrations/integrator/create-integration.ts +++ b/e2e/tests/integrations/integrator/create-integration.ts @@ -27,13 +27,24 @@ export async function createIntegrationAsIntegrator( .click(); } - if (integrationType !== IntegrationType.EntryApi) { - await page.getByText("Basic € 125 / jaar", { exact: true }).click(); + if (integrationType === IntegrationType.UiTPAS) { + await page + .locator("li") + .filter({ hasText: /^UiTPAS API/ }) + .click(); + } + + if ( + integrationType === IntegrationType.SearchApi || + integrationType === IntegrationType.Widgets + ) { + await page.getByLabel("Basic (€ 125 / jaar)Je zorgt").check(); } const integrationName = faker.word.adjective(); await page.getByLabel("Naam integratie").fill(integrationName); await page.getByLabel("Doel van de integratie").fill(faker.lorem.lines(2)); + await page.locator('input[name="website"]').fill(faker.internet.url()); await page .locator('input[name="lastNameFunctionalContact"]') .fill(faker.person.lastName()); @@ -55,9 +66,17 @@ export async function createIntegrationAsIntegrator( await page.locator('input[name="firstNameTechnicalContact"]').press("Tab"); await page.locator('input[name="emailPartner"]').fill(faker.internet.email()); - await page.getByLabel("Ik ga akkoord met de").check(); + await page.locator('input[name="agreement"]').check(); + + if (integrationType === IntegrationType.UiTPAS) { + await page.locator('input[name="uitpasAgreement"]').check(); + } - if (couponCode && integrationType !== IntegrationType.EntryApi) { + if ( + couponCode && + (integrationType === IntegrationType.SearchApi || + integrationType === IntegrationType.Widgets) + ) { await page.getByLabel("Ik heb een coupon").check(); await page.locator('input[name="coupon"]').fill(couponCode); } From 2c75476ea11aa32fd3e623d67172c4741facf1cc Mon Sep 17 00:00:00 2001 From: vhande Date: Tue, 2 Jul 2024 15:17:39 +0200 Subject: [PATCH 2/5] Improve test --- e2e/tests/integrations/integrator/create-integration.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/e2e/tests/integrations/integrator/create-integration.test.ts b/e2e/tests/integrations/integrator/create-integration.test.ts index bab4617c2..279cc5f1a 100644 --- a/e2e/tests/integrations/integrator/create-integration.test.ts +++ b/e2e/tests/integrations/integrator/create-integration.test.ts @@ -3,9 +3,8 @@ import { createIntegrationAsIntegrator } from "./create-integration.js"; import { IntegrationType } from "@app-types/IntegrationType"; const integrationTypeValues = Object.entries(IntegrationType); - -integrationTypeValues.map(([integrationName, integrationType]) => { - test.use({ storageState: "playwright/.auth/user.json" }); +test.use({ storageState: "playwright/.auth/user.json" }); +integrationTypeValues.forEach(([integrationName, integrationType]) => { test(`As an integrator I can create a new ${integrationName} integration`, async ({ page, }) => { From 15ed6b07d8d4dbe8b9f1ff3b62cceeb5c38d8bfd Mon Sep 17 00:00:00 2001 From: vhande Date: Thu, 4 Jul 2024 11:15:16 +0200 Subject: [PATCH 3/5] Add const loginDomain --- e2e/setup/auth.setup.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/setup/auth.setup.ts b/e2e/setup/auth.setup.ts index 1a773287e..880954129 100644 --- a/e2e/setup/auth.setup.ts +++ b/e2e/setup/auth.setup.ts @@ -1,11 +1,15 @@ import { test as setup } from "@playwright/test"; +const loginDomain = process.env.KEYCLOAK_ENABLED + ? /account-keycloak-acc.uitid.be\/*/ + : /account-acc.uitid.be\/*/; + setup("authenticate as admin", async ({ page }) => { await page.goto("/nl"); await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); + await page.waitForURL(loginDomain); await page .locator('input[name="username"]') @@ -27,7 +31,7 @@ setup("authenticate as contributor", async ({ page }) => { await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); + await page.waitForURL(loginDomain); await page .locator('input[name="username"]') @@ -51,7 +55,7 @@ setup( await page.getByRole("link", { name: "Probeer gratis" }).click(); - await page.waitForURL(/account-keycloak-acc.uitid.be\/*/); + await page.waitForURL(loginDomain); await page .locator('input[name="username"]') From ec3de0c9154c4578b9f6348e6aed6cbaa7b59091 Mon Sep 17 00:00:00 2001 From: vhande Date: Fri, 5 Jul 2024 09:54:02 +0200 Subject: [PATCH 4/5] Fix auth0-keycloak login --- e2e/setup/auth.setup.ts | 68 ++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/e2e/setup/auth.setup.ts b/e2e/setup/auth.setup.ts index 880954129..35b723935 100644 --- a/e2e/setup/auth.setup.ts +++ b/e2e/setup/auth.setup.ts @@ -1,8 +1,11 @@ import { test as setup } from "@playwright/test"; -const loginDomain = process.env.KEYCLOAK_ENABLED - ? /account-keycloak-acc.uitid.be\/*/ - : /account-acc.uitid.be\/*/; +const isKeycloakLoginEnabled = process.env.KEYCLOAK_LOGIN_ENABLED === "true"; + +const loginDomain = + process.env.KEYCLOAK_LOGIN_ENABLED === "true" + ? /account-keycloak-acc.uitid.be\/*/ + : /account-acc.uitid.be\/*/; setup("authenticate as admin", async ({ page }) => { await page.goto("/nl"); @@ -11,12 +14,21 @@ setup("authenticate as admin", async ({ page }) => { await page.waitForURL(loginDomain); - await page - .locator('input[name="username"]') - .fill(process.env.E2E_TEST_ADMIN_EMAIL!); - await page - .locator('input[name="password"]') - .fill(process.env.E2E_TEST_ADMIN_PASSWORD!); + if (isKeycloakLoginEnabled) { + await page + .locator('input[name="username"]') + .fill(process.env.E2E_TEST_ADMIN_EMAIL!); + await page + .locator('input[name="password"]') + .fill(process.env.E2E_TEST_ADMIN_PASSWORD!); + } else { + await page + .getByLabel("Je e-mailadres") + .fill(process.env.E2E_TEST_ADMIN_EMAIL!); + await page + .getByLabel("Je wachtwoord") + .fill(process.env.E2E_TEST_ADMIN_PASSWORD!); + } await page.getByRole("button", { name: "Meld je aan", exact: true }).click(); @@ -33,12 +45,17 @@ setup("authenticate as contributor", async ({ page }) => { await page.waitForURL(loginDomain); - await page - .locator('input[name="username"]') - .fill(process.env.E2E_TEST_EMAIL!); - await page - .locator('input[name="password"]') - .fill(process.env.E2E_TEST_PASSWORD!); + if (isKeycloakLoginEnabled) { + await page + .locator('input[name="username"]') + .fill(process.env.E2E_TEST_EMAIL!); + await page + .locator('input[name="password"]') + .fill(process.env.E2E_TEST_PASSWORD!); + } else { + await page.getByLabel("Je e-mailadres").fill(process.env.E2E_TEST_EMAIL!); + await page.getByLabel("Je wachtwoord").fill(process.env.E2E_TEST_PASSWORD!); + } await page.getByRole("button", { name: "Meld je aan", exact: true }).click(); @@ -57,12 +74,21 @@ setup( await page.waitForURL(loginDomain); - await page - .locator('input[name="username"]') - .fill(process.env.E2E_TEST_V1_EMAIL!); - await page - .locator('input[name="password"]') - .fill(process.env.E2E_TEST_V1_PASSWORD!); + if (isKeycloakLoginEnabled) { + await page + .locator('input[name="username"]') + .fill(process.env.E2E_TEST_V1_EMAIL!); + await page + .locator('input[name="password"]') + .fill(process.env.E2E_TEST_V1_PASSWORD!); + } else { + await page + .getByLabel("Je e-mailadres") + .fill(process.env.E2E_TEST_V1_EMAIL!); + await page + .getByLabel("Je wachtwoord") + .fill(process.env.E2E_TEST_V1_PASSWORD!); + } await page .getByRole("button", { name: "Meld je aan", exact: true }) From fd37e53b121916fd711eac36df52ee7181b62607 Mon Sep 17 00:00:00 2001 From: vhande Date: Fri, 5 Jul 2024 10:17:51 +0200 Subject: [PATCH 5/5] Improve const --- e2e/setup/auth.setup.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/e2e/setup/auth.setup.ts b/e2e/setup/auth.setup.ts index 35b723935..1938ca983 100644 --- a/e2e/setup/auth.setup.ts +++ b/e2e/setup/auth.setup.ts @@ -2,10 +2,9 @@ import { test as setup } from "@playwright/test"; const isKeycloakLoginEnabled = process.env.KEYCLOAK_LOGIN_ENABLED === "true"; -const loginDomain = - process.env.KEYCLOAK_LOGIN_ENABLED === "true" - ? /account-keycloak-acc.uitid.be\/*/ - : /account-acc.uitid.be\/*/; +const loginDomain = isKeycloakLoginEnabled + ? /account-keycloak-acc.uitid.be\/*/ + : /account-acc.uitid.be\/*/; setup("authenticate as admin", async ({ page }) => { await page.goto("/nl");