Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Jul 2, 2024
1 parent 2f5d514 commit 72f2b17
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
22 changes: 13 additions & 9 deletions e2e/setup/auth.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();

Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/integrations/admin/create-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/integrations/admin/create-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const IntegrationTypeSubscriptionMap: Record<IntegrationType, string> = {
[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) {
Expand All @@ -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 };
}
17 changes: 11 additions & 6 deletions e2e/tests/integrations/integrator/create-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
27 changes: 23 additions & 4 deletions e2e/tests/integrations/integrator/create-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}
Expand Down

0 comments on commit 72f2b17

Please sign in to comment.