import test from 'node:test' import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' test('message center offers a keyboard-accessible, permission-gated announcement management entry even when empty', () => { const source = readFileSync(new URL('../../src/layout/components/HeaderNotice/index.vue', import.meta.url), 'utf8') assert.match(source, /@click="openCenter"/) assert.match(source, /]*aria-label="消息中心"/) assert.match(source, /v-if="proxy\?\.\$can\(\['system:notice:list'\]\)" class="center-footer"/) assert.match(source, />公告管理<\/el-button>/) assert.match(source, /if \(!proxy\.\$can\(\['system:notice:list'\]\)\) return/) assert.match(source, /router\.push\('\/system\/notice'\)/) assert.doesNotMatch(source, /notice-footer[^>]*noticeList\.length/) }) test('notice management keeps native create, update and delete permission gates', () => { const source = readFileSync(new URL('../../src/views/system/notice/index.vue', import.meta.url), 'utf8') for (const permission of ['add', 'edit', 'remove']) assert.ok(source.includes(`$can(['system:notice:${permission}'])`)) const navbar = readFileSync(new URL('../../src/layout/components/Navbar.vue', import.meta.url), 'utf8') const beforeNotice = navbar.slice(0, navbar.indexOf('') > beforeNotice.lastIndexOf(`appStore.device !== 'mobile'`), 'The notice entry must not disappear on mobile') })