Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Volubyl committed Jan 17, 2023
1 parent 6b2b425 commit e087bbb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion client/src/lib/components/DatasetForm/DatasetForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
</legend>
<div class="fr-fieldset__content">
{#each formats as { id, name }, index}
{@const identifier = `dataformats-${name}`}
{@const identifier = `dataformats-${id}`}
<div class="fr-checkbox-group">
<input
type="checkbox"
Expand Down
10 changes: 7 additions & 3 deletions client/src/tests/e2e/contribuer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ test.describe("Basic form submission", () => {

// "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);
Expand Down Expand Up @@ -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");
Expand Down
23 changes: 10 additions & 13 deletions client/src/tests/e2e/edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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")'
);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion client/src/tests/e2e/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const test = base.extend<AppTestArgs>({
organization_siret: "11004601800013",
title: "Sample title",
description: "Sample description",
formats: ["api"],
format_ids: [1, 2],
entrypoint_email: "[email protected]",
contact_emails: ["[email protected]"],
service: "La Drac",
Expand Down

0 comments on commit e087bbb

Please sign in to comment.