Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPF-470-E2E test: creating an UiTPAS integration #1240

Merged
merged 10 commits into from
Jul 24, 2024
70 changes: 52 additions & 18 deletions e2e/setup/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
import { test as setup } from "@playwright/test";

const isKeycloakLoginEnabled = process.env.KEYCLOAK_LOGIN_ENABLED === "true";

const loginDomain =
process.env.KEYCLOAK_LOGIN_ENABLED === "true"
vhande marked this conversation as resolved.
Show resolved Hide resolved
? /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-acc.uitid.be\/*/);
await page.waitForURL(loginDomain);

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!);
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();

Expand All @@ -27,10 +43,19 @@ setup("authenticate as contributor", async ({ page }) => {

await page.getByRole("link", { name: "Probeer gratis" }).click();

await page.waitForURL(/account-acc.uitid.be\/*/);
await page.waitForURL(loginDomain);

await page.getByLabel("Je e-mailadres").fill(process.env.E2E_TEST_EMAIL!);
await page.getByLabel("Je wachtwoord").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();

Expand All @@ -47,14 +72,23 @@ setup(

await page.getByRole("link", { name: "Probeer gratis" }).click();

await page.waitForURL(/account-acc.uitid.be\/*/);

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.waitForURL(loginDomain);

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 })
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 };
}
16 changes: 10 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,16 @@ import { test, expect } from "@playwright/test";
import { createIntegrationAsIntegrator } from "./create-integration.js";
import { IntegrationType } from "@app-types/IntegrationType";

const integrationTypeValues = Object.entries(IntegrationType);
test.use({ storageState: "playwright/.auth/user.json" });

test("As an integrator I can create a new integration", async ({ page }) => {
const { integrationName } = await createIntegrationAsIntegrator(
integrationTypeValues.forEach(([integrationName, integrationType]) => {
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
Loading