From 5bd45a17768f829de241632ce4319352875538b4 Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Wed, 20 Nov 2024 15:37:23 +0100 Subject: [PATCH 1/4] Add start of ownership test --- src/test/e2e/create-organizer.spec.ts | 105 +++++++++++++++----------- 1 file changed, 62 insertions(+), 43 deletions(-) diff --git a/src/test/e2e/create-organizer.spec.ts b/src/test/e2e/create-organizer.spec.ts index b6792e1b5..ac57122dc 100644 --- a/src/test/e2e/create-organizer.spec.ts +++ b/src/test/e2e/create-organizer.spec.ts @@ -18,55 +18,74 @@ const dummyOrganizer = { }; test('create an organizer', async ({ baseURL, page }) => { - await page.goto(`${baseURL}/organizers/create`); + let organizerUrl; - await page.getByLabel('Naam').click(); - await page.getByLabel('Naam').fill(dummyOrganizer.name); - await page.getByLabel('Website', { exact: true }).click(); - await page - .getByLabel('Website', { exact: true }) - .fill(dummyOrganizer.website); - await page.getByRole('button', { name: 'Opslaan' }).click(); + await test.step('Step 1: Create an organizer', async () => { + await page.goto(`${baseURL}/organizers/create`); - await page.getByRole('tab', { name: 'Beschrijving' }).click(); - await page.getByLabel('rdw-editor').click(); - await page.getByLabel('rdw-editor').fill(dummyOrganizer.description); + await page.getByLabel('Naam').click(); + await page.getByLabel('Naam').fill(dummyOrganizer.name); + await page.getByLabel('Website', { exact: true }).click(); + await page + .getByLabel('Website', { exact: true }) + .fill(dummyOrganizer.website); + await page.getByRole('button', { name: 'Opslaan' }).click(); - await page.getByRole('tab', { name: 'Contact' }).click(); - await page.getByRole('button', { name: 'Contactgegevens toevoegen' }).click(); - await page.locator('#contact-info-value-1').click(); - await page.locator('#contact-info-value-1').fill(dummyOrganizer.email); - await page.locator('#contact-info-value-1').blur(); + await page.getByRole('tab', { name: 'Beschrijving' }).click(); + await page.getByLabel('rdw-editor').click(); + await page.getByLabel('rdw-editor').fill(dummyOrganizer.description); - await page.getByRole('tab', { name: 'Labels' }).click(); - await page.getByLabel('Verfijn met labels').click(); - await page.getByLabel('Verfijn met labels').fill(dummyOrganizer.label); - await page.getByLabel(dummyOrganizer.label).click(); - await page.getByText(dummyOrganizer.label).click(); + await page.getByRole('tab', { name: 'Contact' }).click(); + await page + .getByRole('button', { name: 'Contactgegevens toevoegen' }) + .click(); + await page.locator('#contact-info-value-1').click(); + await page.locator('#contact-info-value-1').fill(dummyOrganizer.email); + await page.locator('#contact-info-value-1').blur(); - await page.getByRole('tab', { name: 'Afbeeldingen' }).click(); - await page.getByRole('button', { name: 'Afbeelding toevoegen' }).click(); - await page.getByRole('button', { name: 'Kies bestand' }).click(); - await page - .locator('input[type=file]') - .setInputFiles('./src/test/data/image.png'); - await page.getByLabel('Beschrijving').click(); - await page.getByLabel('Beschrijving').fill(dummyOrganizer.image.name); - await page.getByLabel('Copyright').click(); - await page.getByLabel('Copyright').fill(dummyOrganizer.image.copyright); - await page.getByRole('button', { name: 'Uploaden' }).click(); - await page.getByText(`© ${dummyOrganizer.image.copyright}`).click(); + await page.getByRole('tab', { name: 'Labels' }).click(); + await page.getByLabel('Verfijn met labels').click(); + await page.getByLabel('Verfijn met labels').fill(dummyOrganizer.label); + await page.getByLabel(dummyOrganizer.label).click(); + await page.getByText(dummyOrganizer.label).click(); - await page.getByRole('tab', { name: 'Adres' }).click(); - await page.getByLabel('Gemeente').click(); - await page.getByLabel('Gemeente').fill(dummyOrganizer.location.municipality); - await page.getByLabel(dummyOrganizer.location.municipality).click(); - const streetField = await page.getByLabel('Straat en nummer').nth(0); - await streetField.click(); - await streetField.fill(dummyOrganizer.location.address); - await streetField.blur(); + await page.getByRole('tab', { name: 'Afbeeldingen' }).click(); + await page.getByRole('button', { name: 'Afbeelding toevoegen' }).click(); + await page.getByRole('button', { name: 'Kies bestand' }).click(); + await page + .locator('input[type=file]') + .setInputFiles('./src/test/data/image.png'); + await page.getByLabel('Beschrijving').click(); + await page.getByLabel('Beschrijving').fill(dummyOrganizer.image.name); + await page.getByLabel('Copyright').click(); + await page.getByLabel('Copyright').fill(dummyOrganizer.image.copyright); + await page.getByRole('button', { name: 'Uploaden' }).click(); + await page.getByText(`© ${dummyOrganizer.image.copyright}`).click(); - await page.getByText('100/100').click(); + await page.getByRole('tab', { name: 'Adres' }).click(); + await page.getByLabel('Gemeente').click(); + await page + .getByLabel('Gemeente') + .fill(dummyOrganizer.location.municipality); + await page.getByLabel(dummyOrganizer.location.municipality).click(); + const streetField = await page.getByLabel('Straat en nummer').nth(0); + await streetField.click(); + await streetField.fill(dummyOrganizer.location.address); + await streetField.blur(); - await page.getByRole('button', { name: 'Klaar met bewerken' }).click(); + await page.getByText('100/100').click(); + + await page + .getByRole('button', { name: 'Klaar met bewerken' }) + .click({ force: true }); + + await page.waitForURL('**/preview**'); + organizerUrl = await page.url(); + }); + + console.log(organizerUrl); + await test.step('Step 2: can assign ownerships on organizer', async () => { + await page.goto(organizerUrl.replace('preview', 'ownerships')); + await page.getByLabel('Nieuwe beheerder toevoegen').isVisible(); + }); }); From cf18752895083bcce05ee2ba45111e43c2270a0f Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Wed, 20 Nov 2024 15:50:22 +0100 Subject: [PATCH 2/4] Work on requesting ownership --- src/test/e2e/create-organizer.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/e2e/create-organizer.spec.ts b/src/test/e2e/create-organizer.spec.ts index ac57122dc..4369e9d3c 100644 --- a/src/test/e2e/create-organizer.spec.ts +++ b/src/test/e2e/create-organizer.spec.ts @@ -1,5 +1,5 @@ import { faker } from '@faker-js/faker'; -import { test } from '@playwright/test'; +import { test, expect } from '@playwright/test'; const dummyOrganizer = { name: faker.lorem.word(), @@ -86,6 +86,15 @@ test('create an organizer', async ({ baseURL, page }) => { console.log(organizerUrl); await test.step('Step 2: can assign ownerships on organizer', async () => { await page.goto(organizerUrl.replace('preview', 'ownerships')); - await page.getByLabel('Nieuwe beheerder toevoegen').isVisible(); + await page + .getByRole('button', { name: 'Nieuwe beheerder toevoegen' }) + .click(); + await page.getByLabel('E-mailadres').fill(process.env.E2E_TEST_EMAIL); + await page.getByRole('button', { name: 'Beheerder toevoegen' }).click(); + await page.getByRole('dialog').isHidden(); + await expect(page.getByRole('alert').nth(1).textContent()).toContain( + process.env.E2E_TEST_EMAIL, + ); + await page.getByText(process.env.E2E_TEST_EMAIL).isVisible(); }); }); From c6671f3596f7fe74e6b0c2bb1ad96bd1c3f589ea Mon Sep 17 00:00:00 2001 From: Emma Fabre Date: Thu, 21 Nov 2024 11:53:49 +0100 Subject: [PATCH 3/4] Add E2E test to add and remove ownership --- .../ownerships/OwnershipsTable.tsx | 2 ++ src/test/e2e/create-organizer.spec.ts | 21 ++++++++++++++----- src/ui/Alert.tsx | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx b/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx index 3c05b8967..07e118ebf 100644 --- a/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx +++ b/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx @@ -19,6 +19,7 @@ export const OwnershipsTable = ({ requests, renderActions }: Props) => { const { t } = useTranslation(); return ( { {requests.map((request) => ( { organizerUrl = await page.url(); }); - console.log(organizerUrl); await test.step('Step 2: can assign ownerships on organizer', async () => { await page.goto(organizerUrl.replace('preview', 'ownerships')); + + // Add ownership await page .getByRole('button', { name: 'Nieuwe beheerder toevoegen' }) .click(); await page.getByLabel('E-mailadres').fill(process.env.E2E_TEST_EMAIL); await page.getByRole('button', { name: 'Beheerder toevoegen' }).click(); - await page.getByRole('dialog').isHidden(); - await expect(page.getByRole('alert').nth(1).textContent()).toContain( + await expect(page.getByRole('dialog')).toBeHidden(); + await expect(page.getByTestId('alert-success')).toContainText( process.env.E2E_TEST_EMAIL, ); - await page.getByText(process.env.E2E_TEST_EMAIL).isVisible(); + await expect( + page.getByRole('row').getByText(process.env.E2E_TEST_EMAIL), + ).toBeVisible(); + await page.getByRole('row').getByRole('button').click(); + + // Delete ownership + await page.getByRole('button', { name: 'Beheerder verwijderen' }).click(); + await expect(page.getByRole('dialog')).toBeHidden(); + await expect( + page.getByRole('row').getByText(process.env.E2E_TEST_EMAIL), + ).toBeHidden(); }); }); diff --git a/src/ui/Alert.tsx b/src/ui/Alert.tsx index 6f98b2dcd..572d3451a 100644 --- a/src/ui/Alert.tsx +++ b/src/ui/Alert.tsx @@ -139,6 +139,7 @@ const Alert = ({ return ( Date: Thu, 21 Nov 2024 11:56:03 +0100 Subject: [PATCH 4/4] No braces I know --- .../organizers/[organizerId]/ownerships/OwnershipsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx b/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx index 07e118ebf..d183e77d4 100644 --- a/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx +++ b/src/pages/organizers/[organizerId]/ownerships/OwnershipsTable.tsx @@ -43,7 +43,7 @@ export const OwnershipsTable = ({ requests, renderActions }: Props) => { {requests.map((request) => (