fix(notifications): satisfy translation and type-aware lint

Keep translation keys static and narrow query values and row props in
notification tests. Preserve all empty-state translations and assertions.

All 19 API tests, 42 component tests, full formatting and source review
pass. Final-head types, cold ESLint and remaining WIP gates still need
validation.
This commit is contained in:
FredApps 2026-10-10 17:02:56 +02:00
parent 2ebcbfac3c
commit 5863f7607b
3 changed files with 42 additions and 28 deletions

View File

@ -96,6 +96,7 @@ describe("<NotificationBox>", { 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("<NotificationBox>", { 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<ReturnType<typeof mountBox>>) {
}
function notificationIds(wrapper: Awaited<ReturnType<typeof mountBox>>) {
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
})
}

View File

@ -274,20 +274,16 @@ async function handleMarkAllRead() {
>
<div class="text-base text-muted-foreground">
{{
t(
readFilter === "all"
? "notification.empty-title"
: "notification.filtered-empty-title",
)
readFilter === "all"
? t("notification.empty-title")
: t("notification.filtered-empty-title")
}}
</div>
<div class="text-sm text-muted-foreground">
{{
t(
readFilter === "all"
? "notification.empty-description"
: "notification.filtered-empty-description",
)
readFilter === "all"
? t("notification.empty-description")
: t("notification.filtered-empty-description")
}}
</div>
</div>

View File

@ -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<string, unknown>) {
const read = query["filter-read_eq"]
const filter = typeof read === "string" ? read : "all"
return `${filter}-${String(query.page)}`
}