Skip to content

Commit

Permalink
Add a test (and fix checkboxes)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Nov 21, 2024
1 parent c3cd7b7 commit 50af4ae
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/sketch/FormV2.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
<label class="govuk-label govuk-label--s" for={intendedUsersId}>
Intended users
</label>
<Checkbox checked={props.v2.for_cycling}>Is this for cyclists?</Checkbox>
<Checkbox checked={props.v2.for_walking_wheeling}>
<Checkbox bind:checked={props.v2.for_cycling}>Is this for cyclists?</Checkbox>
<Checkbox bind:checked={props.v2.for_walking_wheeling}>
Is this for walking/wheeling?
</Checkbox>
</div>
Expand Down
38 changes: 38 additions & 0 deletions tests/v2.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect, test } from "@playwright/test";
import { resetSketch, getLocalStorage, clickMap } from "./shared.js";

test("v2 forms work", async ({ page }) => {
let filename = await resetSketch(page, "v2");

await page.getByRole("button", { name: "New point" }).click();
await clickMap(page, 500, 500);

await page.getByLabel("Modal Filter").check();
await page.getByLabel("Is this for cyclists?").check();
await page.getByLabel("Something completely new").check();
await page.getByLabel("Description").fill("Bus gate");

await page.getByRole("button", { name: "Finish" }).click();

// Check the data in local storage
let json = await getLocalStorage(page, `sketch/LAD_Adur/${filename}`);
let feature = json.features[0] as any;
expect(feature.properties.v2).toEqual({
intervention_type: "modal filter",
for_cycling: true,
for_walking_wheeling: false,
work_type: "new",
});
expect(feature.properties.description).toEqual("Bus gate");

// Edit the point and make sure the forms are still there
await page.getByRole("link", { name: "Untitled point" }).click();
await page.getByLabel("Improvements to something already existing").check();
await page.getByRole("button", { name: "Finish" }).click();

// Check the edit
await page.getByRole("link", { name: "Untitled point" }).click();
await expect(
page.getByLabel("Improvements to something already existing"),
).toBeChecked();
});

0 comments on commit 50af4ae

Please sign in to comment.