From e087bbb75896bbb5bf44a29a997b9f5adc7d2c67 Mon Sep 17 00:00:00 2001 From: volubyl Date: Tue, 17 Jan 2023 17:20:34 +0100 Subject: [PATCH] fix e2e --- .../components/DatasetForm/DatasetForm.svelte | 2 +- client/src/tests/e2e/contribuer.spec.ts | 10 +++++--- client/src/tests/e2e/edit.spec.ts | 23 ++++++++----------- client/src/tests/e2e/fixtures.ts | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/client/src/lib/components/DatasetForm/DatasetForm.svelte b/client/src/lib/components/DatasetForm/DatasetForm.svelte index 95a52cbe..884ee9f9 100644 --- a/client/src/lib/components/DatasetForm/DatasetForm.svelte +++ b/client/src/lib/components/DatasetForm/DatasetForm.svelte @@ -304,7 +304,7 @@
{#each formats as { id, name }, index} - {@const identifier = `dataformats-${name}`} + {@const identifier = `dataformats-${id}`}
{ // "Sources et formats" section - const apiFormat = page.locator("label[for=dataformats-api]"); + const apiFormat = page.locator("label[for=dataformats-1]"); await apiFormat.check(); - expect(await page.isChecked("input[value=api]")).toBeTruthy(); const technicalSource = page.locator("form [name=technicalSource]"); await technicalSource.fill(technicalSourceText); @@ -145,7 +144,12 @@ test.describe("Basic form submission", () => { expect(json.title).toBe(titleText); expect(json.description).toBe(descriptionText); expect(json.geographical_coverage).toBe("Europe continentale"); - expect(json.formats).toStrictEqual(["api"]); + expect(json.formats).toStrictEqual([ + { + id: 1, + name: "Fichier tabulaire (XLS, XLSX, CSV, ...)", + }, + ]); expect(json.producer_email).toBe(producerEmailText); expect(json.contact_emails).toEqual([contactEmail1Text, contactEmail2Text]); expect(json).toHaveProperty("id"); diff --git a/client/src/tests/e2e/edit.spec.ts b/client/src/tests/e2e/edit.spec.ts index 46575978..b9d9e48a 100644 --- a/client/src/tests/e2e/edit.spec.ts +++ b/client/src/tests/e2e/edit.spec.ts @@ -28,8 +28,6 @@ test.describe("Edit dataset", () => { const description = page.locator("form [name=description]"); expect(await description.inputValue()).toBe(dataset.description); - expect(await page.isChecked("input[value='api']")).toBeTruthy(); - expect(dataset.extraFieldValues).toHaveLength(1); const extraReferentiel = page.locator("form [name=referentiel]"); expect(await extraReferentiel.inputValue()).toBe( @@ -48,16 +46,6 @@ test.describe("Edit dataset", () => { await description.fill(newDescriptionText); expect(await description.inputValue()).toBe(newDescriptionText); - const apiFormat = page.locator("label[for=dataformats-api]"); - await apiFormat.uncheck(); - expect(await page.isChecked("input[value=api]")).toBeFalsy(); - const websiteFormat = page.locator("label[for=dataformats-website]"); - await websiteFormat.check(); - expect(await page.isChecked("input[value=website]")).toBeTruthy(); - const databaseFormat = page.locator("label[for=dataformats-database]"); - await databaseFormat.check(); - expect(await page.isChecked("input[value=database]")).toBeTruthy(); - const selectedTag = page.locator( 'button[role="listitem"]:has-text("services")' ); @@ -86,7 +74,16 @@ test.describe("Edit dataset", () => { expect(json).toHaveProperty("id"); expect(json.title).toBe(newTitleText); expect(json.description).toBe(newDescriptionText); - expect(json.formats).toStrictEqual(["database", "website"]); + expect(json.formats).toStrictEqual([ + { + id: 1, + name: "Fichier tabulaire (XLS, XLSX, CSV, ...)", + }, + { + id: 2, + name: "Fichier SIG (Shapefile, ...)", + }, + ]); expect( json.tags.findIndex((item) => item.name === "environnement") !== -1 ).toBeTruthy(); diff --git a/client/src/tests/e2e/fixtures.ts b/client/src/tests/e2e/fixtures.ts index b6fe23d1..83cf6a89 100644 --- a/client/src/tests/e2e/fixtures.ts +++ b/client/src/tests/e2e/fixtures.ts @@ -63,7 +63,7 @@ export const test = base.extend({ organization_siret: "11004601800013", title: "Sample title", description: "Sample description", - formats: ["api"], + format_ids: [1, 2], entrypoint_email: "jane.doe@beta.gouv.fr", contact_emails: ["contact@beta.gouv.fr"], service: "La Drac",