test: tighten Playwright selectors

This commit is contained in:
Nico 2026-05-25 11:48:12 -07:00
parent d2fe873956
commit d4b1de452c
6 changed files with 17 additions and 13 deletions

View File

@ -170,7 +170,7 @@ export default function ConfirmSlideModal({
onPointerCancel={handlePointerCancel} onPointerCancel={handlePointerCancel}
aria-label="Slide to confirm" aria-label="Slide to confirm"
> >
> >
</button> </button>
</div> </div>
</div> </div>

View File

@ -150,8 +150,8 @@ test("manage stores opens a modal to edit and delete household store items", asy
const managerModal = page.locator(".store-items-modal"); const managerModal = page.locator(".store-items-modal");
await expect(managerModal).toBeVisible(); await expect(managerModal).toBeVisible();
await expect(managerModal.getByText("milk")).toBeVisible(); await expect(managerModal.getByText("milk", { exact: true })).toBeVisible();
await expect(managerModal.getByText("apples")).toBeVisible(); await expect(managerModal.getByText("apples", { exact: true })).toBeVisible();
await managerModal.locator(".store-items-table-row").filter({ hasText: "apples" }).getByRole("button", { name: "Edit Settings" }).click(); await managerModal.locator(".store-items-table-row").filter({ hasText: "apples" }).getByRole("button", { name: "Edit Settings" }).click();
const editorModal = page.locator(".available-item-editor-modal"); const editorModal = page.locator(".available-item-editor-modal");

View File

@ -271,7 +271,9 @@ test("add-details modal validates with toasts and persists classification detail
const yogurtRow = page.locator(".glist-li").filter({ hasText: "yogurt" }); const yogurtRow = page.locator(".glist-li").filter({ hasText: "yogurt" });
await expect(yogurtRow).toBeVisible(); await expect(yogurtRow).toBeVisible();
await expect(page.locator(".action-toast.action-toast-success")).toContainText("Added item"); await expect(
page.locator(".action-toast.action-toast-success").filter({ hasText: "Added item" })
).toContainText("Added item");
await openEditModal(yogurtRow, page); await openEditModal(yogurtRow, page);
@ -302,7 +304,9 @@ test("edit modal supports zone-only updates and shows API error toasts", async (
await editModal.locator(".edit-modal-select").nth(1).selectOption("Checkout Area"); await editModal.locator(".edit-modal-select").nth(1).selectOption("Checkout Area");
await editModal.getByRole("button", { name: "Save Changes" }).click(); await editModal.getByRole("button", { name: "Save Changes" }).click();
await expect(page.locator(".action-toast.action-toast-success")).toContainText("Updated item"); await expect(
page.locator(".action-toast.action-toast-success").filter({ hasText: "Updated item" })
).toContainText("Updated item");
await expect(editModal).toBeHidden(); await expect(editModal).toBeHidden();
await openEditModal(yogurtRow, page); await openEditModal(yogurtRow, page);

View File

@ -39,14 +39,14 @@ test("new users with no households see create and join actions instead of a load
await expect(page.getByRole("button", { name: "Create or Join Household" })).toBeVisible(); await expect(page.getByRole("button", { name: "Create or Join Household" })).toBeVisible();
await expect(page.getByRole("heading", { name: "No household yet" })).toBeVisible(); await expect(page.getByRole("heading", { name: "No household yet" })).toBeVisible();
await expect(page.getByRole("button", { name: "Create Household" })).toBeVisible(); await expect(page.getByRole("button", { name: "Create Household", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Join Household" })).toBeVisible(); await expect(page.getByRole("button", { name: "Join Household", exact: true })).toBeVisible();
await page.getByRole("button", { name: "Join Household" }).click(); await page.getByRole("button", { name: "Join Household", exact: true }).click();
await expect(page.getByLabel("Invite Code or Link")).toBeVisible(); await expect(page.getByLabel("Invite Code or Link")).toBeVisible();
await page.getByRole("button", { name: "Close household dialog" }).click(); await page.getByRole("button", { name: "Close household dialog" }).click();
await page.getByRole("button", { name: "Create Household" }).click(); await page.getByRole("button", { name: "Create Household", exact: true }).click();
await expect(page.getByLabel("Household Name")).toBeVisible(); await expect(page.getByLabel("Household Name")).toBeVisible();
await page.getByRole("button", { name: "Close household dialog" }).click(); await page.getByRole("button", { name: "Close household dialog" }).click();
@ -54,6 +54,6 @@ test("new users with no households see create and join actions instead of a load
await expect(page.getByRole("heading", { name: "Manage" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Manage" })).toBeVisible();
await expect(page.getByRole("heading", { name: "No household yet" })).toBeVisible(); await expect(page.getByRole("heading", { name: "No household yet" })).toBeVisible();
await expect(page.getByRole("button", { name: "Create Household" })).toBeVisible(); await expect(page.getByRole("button", { name: "Create Household", exact: true })).toBeVisible();
await expect(page.getByRole("button", { name: "Join Household" })).toBeVisible(); await expect(page.getByRole("button", { name: "Join Household", exact: true })).toBeVisible();
}); });

View File

@ -71,7 +71,7 @@ test("join household modal accepts invite links but rejects legacy invite codes"
}); });
await page.goto("/manage"); await page.goto("/manage");
await page.getByRole("button", { name: "Join Household" }).click(); await page.getByRole("button", { name: "Join Household", exact: true }).click();
await page.getByLabel("Invite Link").fill("HABC123"); await page.getByLabel("Invite Link").fill("HABC123");
await page.getByRole("button", { name: "Open Invite" }).click(); await page.getByRole("button", { name: "Open Invite" }).click();

View File

@ -38,7 +38,7 @@ test("login failure shows inline error and error toast", async ({ page }) => {
await page.getByPlaceholder("Password").fill("bad-password"); await page.getByPlaceholder("Password").fill("bad-password");
await page.getByRole("button", { name: "Login" }).click(); await page.getByRole("button", { name: "Login" }).click();
await expect(page.getByText("Invalid credentials")).toBeVisible(); await expect(page.getByText("Invalid credentials", { exact: true })).toBeVisible();
await expect(page.locator(".action-toast.action-toast-error")).toContainText("Login failed"); await expect(page.locator(".action-toast.action-toast-error")).toContainText("Login failed");
await expect(page.locator(".action-toast.action-toast-error")).toContainText("Invalid credentials"); await expect(page.locator(".action-toast.action-toast-error")).toContainText("Invalid credentials");
}); });