dsh-better-chat/tests/reader-in-chat-wiring.test.ts

27 lines
1.2 KiB
TypeScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { test } from 'vitest';
/**
* The reader-in-chat wiring is mostly declarative (slot id, priority, child
* seats, retired official entry), so the cheap regression guard is reading the
* entry module itself. Behaviour of the ledger surgery lives in
* `chat-view-seat.test.ts`.
*/
const url = new URL('../src/client/reader-plugin.tsx', import.meta.url);
const source = await readFile(url, 'utf8');
test('the reader occupies the built-in 对话 View at a shadowing priority', () => {
assert.match(source, /name: 'conversation\.view'/u);
assert.match(source, /id: CHAT_VIEW_ID/u);
assert.match(source, /priority: CHAT_VIEW_PRIORITY/u);
assert.match(source, /label: \(\) => '对话'/u);
assert.doesNotMatch(source, /id: 'reader'/u, 'the old 阅读 tab must not come back');
assert.doesNotMatch(source, /installReaderEntry/u, 'no forced View switch on open');
});
test('the freed View ledger row is restored on teardown', () => {
assert.match(source, /retireHostedChatView/u);
assert.match(source, /yield retireHostedChatView\(/u);
assert.match(source, /yield installOfficialSlots\(ctx\)/u);
});