diff --git a/web/app/components/NotificationBox.nuxt.test.ts b/web/app/components/NotificationBox.nuxt.test.ts index e3eb9827..8e92c40d 100644 --- a/web/app/components/NotificationBox.nuxt.test.ts +++ b/web/app/components/NotificationBox.nuxt.test.ts @@ -96,6 +96,7 @@ describe("", { concurrent: false }, () => { const wrapper = await mountBox() expect(wrapper.text()).toContain(t("notification.empty-title")) + expect(wrapper.text()).toContain(t("notification.empty-description")) }) it("lists one row per notification", async ({ expect }) => { @@ -301,14 +302,19 @@ describe("", { concurrent: false }, () => { expect, }) => { disposeMockEndpoints() - const calls = mockEndpoint("GET", "/api/notifications", (call) => ({ - notifications: [ - makeNotification({ - id: `${String(call.query["filter-read_eq"] ?? "all")}-${String(call.query.page)}`, - }), - ], - pageCount: call.query["filter-read_eq"] === "false" ? 2 : 3, - })) + const calls = mockEndpoint("GET", "/api/notifications", (call) => { + const read = call.query["filter-read_eq"] + const filter = typeof read === "string" ? read : "all" + + return { + notifications: [ + makeNotification({ + id: `${filter}-${String(call.query.page)}`, + }), + ], + pageCount: read === "false" ? 2 : 3, + } + }) seedPages( [ [makeNotification({ id: "all-1" })], @@ -945,7 +951,17 @@ function rows(wrapper: Awaited>) { } function notificationIds(wrapper: Awaited>) { - return wrapper - .findAllComponents(NotificationRow) - .map((row) => row.props("notification").id) + return wrapper.findAllComponents(NotificationRow).map((row) => { + const notification: unknown = row.props("notification") + if ( + !notification || + typeof notification !== "object" || + !("id" in notification) || + typeof notification.id !== "string" + ) { + throw new Error("Expected a notification with a string id") + } + + return notification.id + }) } diff --git a/web/app/components/NotificationBox.vue b/web/app/components/NotificationBox.vue index 526f9f69..b4d09a01 100644 --- a/web/app/components/NotificationBox.vue +++ b/web/app/components/NotificationBox.vue @@ -274,20 +274,16 @@ async function handleMarkAllRead() { >
{{ - t( - readFilter === "all" - ? "notification.empty-title" - : "notification.filtered-empty-title", - ) + readFilter === "all" + ? t("notification.empty-title") + : t("notification.filtered-empty-title") }}
{{ - t( - readFilter === "all" - ? "notification.empty-description" - : "notification.filtered-empty-description", - ) + readFilter === "all" + ? t("notification.empty-description") + : t("notification.filtered-empty-description") }}
diff --git a/web/app/composables/api/useNotificationAPI.nuxt.test.ts b/web/app/composables/api/useNotificationAPI.nuxt.test.ts index 18cfbdd5..f9923122 100644 --- a/web/app/composables/api/useNotificationAPI.nuxt.test.ts +++ b/web/app/composables/api/useNotificationAPI.nuxt.test.ts @@ -144,7 +144,7 @@ describe("useNotificationAPI", { concurrent: false }, () => { makePage( [ makeNotification( - `${String(call.query["filter-read_eq"] ?? "all")}-${String(call.query.page)}`, + notificationPageId(call.query), call.query["filter-read_eq"] === "true", ), ], @@ -216,12 +216,7 @@ describe("useNotificationAPI", { concurrent: false }, () => { } return makePage( - [ - makeNotification( - `${String(call.query["filter-read_eq"] ?? "all")}-${String(call.query.page)}`, - false, - ), - ], + [makeNotification(notificationPageId(call.query), false)], 2, ) }) @@ -692,3 +687,10 @@ describe("useNotificationAPI", { concurrent: false }, () => { }) }) }) + +function notificationPageId(query: Record) { + const read = query["filter-read_eq"] + const filter = typeof read === "string" ? read : "all" + + return `${filter}-${String(query.page)}` +}