// ── Where each account's notification screens live ───────────────────────── // // ENGAGEMENT.md Phase 7. Three assertions for a nine-line module, because the // defect they pin was invisible to every other check: `/auth/me/notifications` // is role-agnostic (behind `requireAuth` only, like the rest of `/auth/me`), so // the server, the tests and the API all agreed a staff member had an inbox — // and on the web they could not reach it, because `RequirePlayer` sends anyone // who is not a player back out of `/account`. The bell pointed at a redirect. // // Found in the Phase 7 rig, signed in as an admin. What stops it coming back is // this file plus the two admin routes it maps onto. import { test } from 'node:test' import assert from 'node:assert/strict' import { isStaff, inboxPath, notificationSettingsPath } from '../src/lib/notificationPaths.js' test('a player gets the portal paths', () => { const user = { role: 'player' } assert.equal(isStaff(user), false) assert.equal(inboxPath(user), '/account/notifications') assert.equal(notificationSettingsPath(user), '/account/notifications/settings') }) test('every non-player role gets the admin paths, not just admin', () => { for (const role of ['admin', 'editor', 'moderator']) { const user = { role } assert.equal(isStaff(user), true, role) assert.equal(inboxPath(user), '/admin/notifications', role) assert.equal(notificationSettingsPath(user), '/admin/notifications/settings', role) } }) // The bell renders nothing when signed out, so these are never asked for a null // user in practice — but a default that guessed "staff" would send a signed-out // visitor at the admin area the moment that changed. test('no user, or a user with no role, falls back to the player paths', () => { for (const user of [null, undefined, {}, { role: '' }]) { assert.equal(isStaff(user), false) assert.equal(inboxPath(user), '/account/notifications') } })