Skip to content

Commit 6988dbe

Browse files
committed
refine tests
1 parent 87a86f1 commit 6988dbe

4 files changed

+105
-46
lines changed

src/domains/edit/tests/add-wheelchair-description.e2e-spec.ts

+43-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Locator, expect, test } from "@playwright/test";
2+
import node4544823443Mock from "~/domains/edit/tests/mocks/node-4544823443-osm-mock.json";
23
import {
34
getDialog,
45
getEditButton,
@@ -19,23 +20,55 @@ test.describe("Add wheelchair description in new language", () => {
1920
dialog = await getDialog(page);
2021
});
2122

23+
test("dialog is rendered", async () => {
24+
await expect(dialog).toBeVisible();
25+
});
26+
2227
test("dialog has select box when adding a new language", async () => {
2328
await expect(dialog.getByRole("combobox")).toBeVisible();
2429
});
2530

26-
test("text area is hidden before language is selected", async () => {
27-
const combobox = dialog.getByRole("combobox");
31+
test("dialog content is key board navigable", async () => {
32+
//TODO
33+
});
34+
35+
test("text area is hidden before language is selected", async ({ page }) => {
2836
const textArea = dialog.getByRole("textbox");
2937
await expect(textArea).toBeHidden();
3038

31-
await combobox.click();
32-
//TODO: await expect(textArea).toBeVisible();
39+
await dialog.getByRole("combobox").click();
40+
await page.locator("text=English").click();
41+
await expect(textArea).toBeVisible();
3342
});
3443

35-
//TODO: test aria snapshot
36-
// test("matches the accessibility snapshot", async ({ page }) => {});
37-
//TODO: test WCAG accessibility
38-
// test("passes WCAG accessibility check", async ({ page }) => {
39-
// expect(true).toBe(true);
40-
// });
44+
test("correct description is displayed when another language is selected", async ({
45+
page,
46+
}) => {
47+
const mockedEnglishDescription =
48+
node4544823443Mock.properties["wheelchair:description:en"];
49+
const mockedPortugeseDescription =
50+
node4544823443Mock.properties["wheelchair:description:pt"];
51+
52+
const comboboxTrigger = dialog.getByRole("combobox");
53+
const textArea = dialog.getByRole("textbox");
54+
55+
await comboboxTrigger.click();
56+
await page.locator("text=/^English$/ ").click();
57+
await expect(comboboxTrigger).toHaveText("English");
58+
await expect(textArea).toHaveText(mockedEnglishDescription);
59+
60+
await comboboxTrigger.click();
61+
await page.locator("text=/^Portuguese$/").click();
62+
await expect(comboboxTrigger).toHaveText("Portuguese");
63+
await expect(textArea).toHaveText(mockedPortugeseDescription);
64+
});
65+
66+
test("dialog can be closed using the cancel button", async () => {
67+
await dialog.getByRole("button", { name: "Cancel" }).click();
68+
await expect(dialog).toBeHidden();
69+
});
70+
71+
test("passes WCAG accessibility check", async ({ page }) => {
72+
//TODO
73+
});
4174
});

src/domains/edit/tests/edit-toilet-accessibility.e2e-spec.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ test.describe("Edit toilet accessibility", () => {
1717
dialog = await getDialog(page);
1818
});
1919

20+
test("dialog is rendered", async () => {
21+
await expect(dialog).toBeVisible();
22+
});
23+
2024
test("dialog content is keyboard navigable", async () => {
2125
//TODO
2226
});
@@ -36,10 +40,12 @@ test.describe("Edit toilet accessibility", () => {
3640
await expect(dialog.getByRole("button", { name: "Send" })).toBeVisible();
3741
});
3842

39-
//TODO: test aria snapshot
40-
// test("matches the accessibility snapshot", async ({ page }) => {});
41-
//TODO: test WCAG accessibility
42-
// test("passes WCAG accessibility check", async ({ page }) => {
43-
// expect(true).toBe(true);
44-
// });
43+
test("dialog can be closed using the cancel button", async () => {
44+
await dialog.getByRole("button", { name: "Cancel" }).click();
45+
await expect(dialog).toBeHidden();
46+
});
47+
48+
test("passes WCAG accessibility check", async ({ page }) => {
49+
//TODO
50+
});
4551
});

src/domains/edit/tests/edit-wheelchair-accessibility.e2e-spec.ts

+25-10
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,40 @@ test.describe("Edit wheelchair accessibility", () => {
1313
await page.goto("/");
1414
await skipOnboarding(page);
1515
await mockPlaceInfo(page);
16-
await getEditButton(page, "wheelchair:description").click();
16+
await getEditButton(page, "wheelchair").click();
1717
dialog = await getDialog(page);
1818
});
1919

20+
test("dialog is rendered", async () => {
21+
await expect(dialog).toBeVisible();
22+
});
23+
2024
test("dialog content is key board navigable", async () => {
2125
//TODO
2226
});
2327

24-
test("confirm button changes to send after input changes", async () => {
25-
//TODO:
28+
test("confirm button changes to send after input changes", async ({
29+
page,
30+
}) => {
2631
await expect(dialog.getByRole("button", { name: "Confirm" })).toBeVisible();
27-
// select a new radio button
32+
const yesRadio = page.locator("form svg").first();
33+
const limitedRadio = page.locator("form svg").nth(2);
34+
const noRadio = page.locator("form svg").nth(3);
35+
36+
await expect(yesRadio).toBeVisible();
37+
await expect(limitedRadio).toBeVisible();
38+
await expect(noRadio).toBeVisible();
39+
40+
await noRadio.click();
2841
await expect(dialog.getByRole("button", { name: "Send" })).toBeVisible();
2942
});
3043

31-
//TODO: test aria snapshot
32-
// test("matches the accessibility snapshot", async ({ page }) => {});
33-
//TODO: test WCAG accessibility
34-
// test("passes WCAG accessibility check", async ({ page }) => {
35-
// expect(true).toBe(true);
36-
// });
44+
test("dialog can be closed using the cancel button", async () => {
45+
await dialog.getByRole("button", { name: "Cancel" }).click();
46+
await expect(dialog).toBeHidden();
47+
});
48+
49+
test("passes WCAG accessibility check", async ({ page }) => {
50+
//TODO
51+
});
3752
});
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Locator, expect, test } from "@playwright/test";
2+
import node4544823443Mock from "~/domains/edit/tests/mocks/node-4544823443-osm-mock.json";
23
import {
34
getDialog,
45
getEditButton,
@@ -19,40 +20,44 @@ test.describe("Edit wheelchair description", () => {
1920
dialog = await getDialog(page);
2021
});
2122

23+
test("dialog is rendered", async () => {
24+
await expect(dialog).toBeVisible();
25+
});
26+
2227
test("dialog has textarea and buttons", async () => {
2328
await expect(dialog.getByRole("textbox")).toBeVisible();
2429
await expect(dialog.getByRole("button", { name: "Cancel" })).toBeVisible();
2530
await expect(dialog.getByRole("button", { name: "Confirm" })).toBeVisible();
2631
});
2732

28-
test("text area contains description", async () => {
29-
await expect(dialog.getByRole("textbox")).toBeVisible();
30-
await expect(dialog.getByRole("button", { name: "Cancel" })).toBeVisible();
31-
await expect(dialog.getByRole("button", { name: "Confirm" })).toBeVisible();
33+
test("dialog does not have select box when editing current description", async () => {
34+
await expect(dialog.getByRole("combobox")).toBeHidden();
3235
});
3336

34-
test("confirm button changes to send after input changes", async () => {
37+
test("dialog content is key board navigable", async () => {
38+
//TODO
39+
});
40+
41+
test("text area contains description", async () => {
42+
const mockedDefaultDescription =
43+
node4544823443Mock.properties["wheelchair:description"];
3544
const textArea = dialog.getByRole("textbox");
36-
const confirmButton = dialog.getByRole("button", { name: "Confirm" });
45+
await expect(textArea).toHaveText(mockedDefaultDescription);
46+
});
3747

38-
await expect(confirmButton).toBeVisible();
39-
await expect(confirmButton).toHaveText("Confirm");
48+
test("confirm button changes to send after input changes", async () => {
49+
await expect(dialog.getByRole("button", { name: "Confirm" })).toBeVisible();
4050

41-
await textArea.fill("New text input");
51+
await dialog.getByRole("textbox").fill("New text input");
4252
await expect(dialog.getByRole("button", { name: "Send" })).toBeVisible();
4353
});
4454

45-
//TODO: test aria snapshot
46-
// test("matches the accessibility snapshot", async ({ page }) => {});
47-
//TODO: test WCAG accessibility
48-
// test("passes WCAG accessibility check", async ({ page }) => {
49-
// expect(true).toBe(true);
50-
// });
51-
52-
test("can be closed using the cancel button", async () => {
53-
const cancelButton = dialog.getByRole("button", { name: "Cancel" });
54-
await expect(cancelButton).toBeVisible();
55-
await cancelButton.click();
55+
test("dialog can be closed using the cancel button", async () => {
56+
await dialog.getByRole("button", { name: "Cancel" }).click();
5657
await expect(dialog).toBeHidden();
5758
});
59+
60+
test("passes WCAG accessibility check", async ({ page }) => {
61+
//TODO
62+
});
5863
});

0 commit comments

Comments
 (0)