test: cover member removal confirmation
This commit is contained in:
parent
921952eb2c
commit
c681312eba
@ -4,6 +4,7 @@ import {
|
||||
confirmSlide,
|
||||
expectNoFailedApiRequests,
|
||||
mockConfig,
|
||||
mockHouseholdAndStoreShell,
|
||||
seedAuthStorage,
|
||||
} from "./helpers/e2e";
|
||||
|
||||
@ -179,6 +180,65 @@ test("household management shows pending invite approvals and can approve them",
|
||||
await expect(page.getByText("Members (2)")).toBeVisible();
|
||||
});
|
||||
|
||||
test("household member removal opens slide confirmation instead of browser dialog", async ({ page }) => {
|
||||
await seedAuthStorage(page, { role: "owner", username: "manager-user" });
|
||||
await mockConfig(page);
|
||||
await mockHouseholdAndStoreShell(page, {
|
||||
household: { name: "Removal Home", role: "owner" },
|
||||
});
|
||||
|
||||
let dialogCount = 0;
|
||||
page.on("dialog", async (dialog) => {
|
||||
dialogCount += 1;
|
||||
await dialog.dismiss();
|
||||
});
|
||||
|
||||
await page.route("**/households/1/members", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify([
|
||||
{ id: 1, username: "manager-user", role: "owner" },
|
||||
{ id: 2, username: "remove-me", role: "member" },
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/groups/join-policy", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ joinPolicy: "APPROVAL_REQUIRED" }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/groups/invites", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ links: [] }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/api/groups/join-requests", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify({ requests: [] }),
|
||||
});
|
||||
});
|
||||
|
||||
await page.goto("/manage?tab=household");
|
||||
|
||||
const memberCard = page.locator(".member-card").filter({ hasText: "remove-me" });
|
||||
await memberCard.getByRole("button", { name: "Remove" }).click();
|
||||
|
||||
await expect(page.getByRole("heading", { name: "Remove remove-me?" })).toBeVisible();
|
||||
await expect(page.getByText("Slide to confirm. They will lose access to this household.")).toBeVisible();
|
||||
await expect(page.locator(".confirm-slide-label")).toHaveText("Remove Member");
|
||||
expect(dialogCount).toBe(0);
|
||||
});
|
||||
|
||||
test("household owner can transfer ownership from household settings", async ({ page }) => {
|
||||
const failedApiRequests = collectFailedApiRequests(page);
|
||||
await seedAuthStorage(page, { role: "owner", username: "manager-user" });
|
||||
@ -206,6 +266,14 @@ test("household owner can transfer ownership from household settings", async ({
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/stores/household/1", async (route) => {
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: "application/json",
|
||||
body: JSON.stringify([{ id: 10, name: "Costco", location: "Warehouse", is_default: true }]),
|
||||
});
|
||||
});
|
||||
|
||||
await page.route("**/households/1/members/*/role", async (route) => {
|
||||
const request = route.request();
|
||||
if (request.method() !== "PATCH") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user