30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
import assert from 'node:assert/strict'
|
|||
|
|
import { readFile } from 'node:fs/promises'
|
||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
const moduleRoot = new URL('./', import.meta.url)
|
||
|
|
|
||
|
|
test('keeps message-center routes unreleased until the server contract is frozen', async () => {
|
||
|
|
const source = await readFile(new URL('routes.ts', moduleRoot), 'utf8')
|
||
|
|
assert.match(source, /name: 'notifications-list'[\s\S]*release: 'prototype'/)
|
||
|
|
assert.match(source, /name: 'notification-detail'[\s\S]*release: 'prototype'/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('does not accept browser-selected customer or user scope in the API boundary', async () => {
|
||
|
|
const source = await readFile(new URL('api/notifications.ts', moduleRoot), 'utf8')
|
||
|
|
assert.doesNotMatch(source, /tenantId|customerId|merchantId|userId/)
|
||
|
|
assert.match(source, /merchant\/v1\/notifications/)
|
||
|
|
assert.match(source, /read-all/)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('keeps customer message actions first and covers the requested local states', async () => {
|
||
|
|
const source = await readFile(new URL('views/NotificationsView.vue', moduleRoot), 'utf8')
|
||
|
|
const operationColumn = source.indexOf('label="操作"')
|
||
|
|
const titleColumn = source.indexOf('label="消息标题"')
|
||
|
|
assert.ok(operationColumn >= 0 && operationColumn < titleColumn)
|
||
|
|
assert.match(source, /全部标为已读/)
|
||
|
|
assert.match(source, /标为已读/)
|
||
|
|
assert.match(source, /state-panel--error/)
|
||
|
|
assert.match(source, /暂无消息/)
|
||
|
|
})
|