From bd1ccae6ab5987e82a01f4b7dd5154f79b796dbe Mon Sep 17 00:00:00 2001 From: SimpleTest Date: Thu, 13 Aug 2026 03:09:01 +0300 Subject: [PATCH] Align notification browser test with delivery policy --- e2e/tests/notifications-data.spec.ts | 78 +++++++++++++++++++++------- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/e2e/tests/notifications-data.spec.ts b/e2e/tests/notifications-data.spec.ts index e71103e..2a11273 100644 --- a/e2e/tests/notifications-data.spec.ts +++ b/e2e/tests/notifications-data.spec.ts @@ -36,15 +36,28 @@ test("nearby alerts, private notification inbox, preferences, and data export wo const requestTitle = projectText("Nearby notification request", scope); await gotoLiveView(subscriber.page, "/notifications"); - await subscriber.page.getByRole("link", { name: "Delivery settings" }).click(); - const preferenceForm = subscriber.page.locator("#notification-preferences-form"); - await preferenceForm.getByLabel("Allow email notifications").check(); - await preferenceForm.getByLabel("Nearby requests by email").check(); + await subscriber.page + .getByRole("link", { name: "Delivery settings" }) + .click(); + const preferenceForm = subscriber.page.locator( + "#notification-preferences-form", + ); + await preferenceForm.getByLabel("Allow push notifications").check(); + await preferenceForm.getByLabel("Nearby requests").check(); + await expect( + preferenceForm.getByText( + "Nearby updates use the in-app inbox and optional push. Email digests are not enabled yet.", + ), + ).toBeVisible(); await preferenceForm.getByLabel("Use quiet hours").check(); await preferenceForm.getByLabel("From").fill("22:00"); await preferenceForm.getByLabel("Until").fill("07:00"); - await preferenceForm.getByRole("button", { name: "Save preferences" }).click(); - await expect(subscriber.page.getByText("Notification preferences saved.")).toBeVisible(); + await preferenceForm + .getByRole("button", { name: "Save preferences" }) + .click(); + await expect( + subscriber.page.getByText("Notification preferences saved."), + ).toBeVisible(); await subscriber.page .getByRole("link", { name: "Nearby alerts", exact: true }) @@ -78,19 +91,27 @@ test("nearby alerts, private notification inbox, preferences, and data export wo { timeout: 15_000 }, ) .not.toBeNull(); - await subscriptionForm.getByLabel("Email notification").check(); - await subscriptionForm.getByRole("button", { name: "Create nearby alert" }).click(); + await subscriptionForm.getByLabel("Push notification").check(); + await subscriptionForm + .getByRole("button", { name: "Create nearby alert" }) + .click(); - await expect(subscriber.page.getByText("Nearby alert created.")).toBeVisible(); + await expect( + subscriber.page.getByText("Nearby alert created."), + ).toBeVisible(); const savedAlert = subscriber.page .getByRole("heading", { name: "Your nearby alerts" }) .locator(".."); - await expect(savedAlert.getByRole("heading", { name: alertName })).toBeVisible(); + await expect( + savedAlert.getByRole("heading", { name: alertName }), + ).toBeVisible(); await expect(savedAlert.getByText(`${privateArea} ยท 3 km`)).toBeVisible(); await expect(savedAlert.getByText("Push", { exact: true })).toBeVisible(); - await expect(savedAlert.getByText("Email", { exact: true })).toBeVisible(); + await expect(savedAlert.getByText("Email", { exact: true })).toHaveCount(0); - const accessibility = await new AxeBuilder({ page: subscriber.page }).analyze(); + const accessibility = await new AxeBuilder({ + page: subscriber.page, + }).analyze(); expect( accessibility.violations, accessibility.violations @@ -100,7 +121,9 @@ test("nearby alerts, private notification inbox, preferences, and data export wo await gotoLiveView(requester.page, "/requests/new"); await selectOptionContaining(requester.page, "Category", "Medicine pickup"); - await requester.page.getByLabel("Medicine pickup status").selectOption("reserved"); + await requester.page + .getByLabel("Medicine pickup status") + .selectOption("reserved"); await requester.page.getByLabel("Short title").fill(requestTitle); await requester.page .getByLabel("What help do you need?") @@ -116,38 +139,53 @@ test("nearby alerts, private notification inbox, preferences, and data export wo }); await requester.page.locator("#request-form input[type=checkbox]").check(); await requester.page.getByRole("button", { name: "Publish request" }).click(); - await expect(requester.page.getByRole("heading", { name: requestTitle })).toBeVisible(); + await expect( + requester.page.getByRole("heading", { name: requestTitle }), + ).toBeVisible(); const requestURL = requester.page.url(); await subscriber.page.getByRole("link", { name: "Inbox" }).click(); const inbox = subscriber.page .getByRole("heading", { name: "Inbox" }) .locator("xpath=ancestor::section"); - const notification = inbox.getByRole("link", { name: /New help request nearby/ }); + const notification = inbox.getByRole("link", { + name: /New help request nearby/, + }); await expect(notification).toBeVisible({ timeout: 20_000 }); await expect(inbox.getByText(privateArea)).toHaveCount(0); await notification.click(); await expect(subscriber.page).toHaveURL(requestURL); - await expect(subscriber.page.getByRole("heading", { name: requestTitle })).toBeVisible(); + await expect( + subscriber.page.getByRole("heading", { name: requestTitle }), + ).toBeVisible(); // WebKit reports cancelled image decoding as a page error when a document // destroys a raster map before its worker reaches idle. Waiting here tests // the real rendered state and avoids navigating away mid-decode. await waitForMapIdle(subscriber.page); await gotoWithTransientRetry(subscriber.page, "/users/settings"); - await expect(subscriber.page.getByRole("heading", { name: "Account Settings" })).toBeVisible(); + await expect( + subscriber.page.getByRole("heading", { name: "Account Settings" }), + ).toBeVisible(); assertSubscriberClean(); assertRequesterClean(); - const exportLink = subscriber.page.getByRole("link", { name: "Download my data" }); + const exportLink = subscriber.page.getByRole("link", { + name: "Download my data", + }); await expect(exportLink).toHaveAttribute("href", "/users/data-export"); - const exportURL = new URL("/users/data-export", subscriber.page.url()).toString(); + const exportURL = new URL( + "/users/data-export", + subscriber.page.url(), + ).toString(); const exportResponse = await subscriber.context.request.get(exportURL); expect(exportResponse.status()).toBe(200); expect(exportResponse.headers()["content-disposition"]).toMatch( /^attachment; filename="who-need-help-account-export-\d{4}-\d{2}-\d{2}\.json"$/, ); - expect((await exportResponse.json()).format).toBe("who-need-help-account-export"); + expect((await exportResponse.json()).format).toBe( + "who-need-help-account-export", + ); await subscriber.context.close(); await requester.context.close();