Files
Agent-System/web/src/lib/blockEditorDialog.test.ts
T
weichenandCursor a42895ccdc feat(web): give block editor an accessible dialog label
Expose role=dialog and a stable aria-label so save can be scoped
without changing the modal's visuals or save behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 17:46:37 +00:00

29 lines
1.2 KiB
TypeScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
BLOCK_EDITOR_DIALOG_LABEL,
BLOCK_EDITOR_SAVE_NAME,
blockEditorDialogPolicy,
} from './blockEditorDialog';
describe('blockEditorDialogPolicy', () => {
it('pins an accessible dialog label and exact save name', () => {
const policy = blockEditorDialogPolicy();
assert.equal(policy.role, 'dialog');
assert.equal(policy.name, '编辑受控块');
assert.equal(policy.name, BLOCK_EDITOR_DIALOG_LABEL);
assert.equal(policy.saveButton.name, '保存修改');
assert.equal(policy.saveButton.name, BLOCK_EDITOR_SAVE_NAME);
assert.equal(policy.saveButton.exact, true);
});
it('rejects page-wide fuzzy /保存/ that would hit private-library buttons', () => {
const policy = blockEditorDialogPolicy();
const privateLibrary = '一键保存到我的私密文档库';
assert.match(privateLibrary, policy.forbidPageWideSaveRegex);
assert.equal(policy.saveButton.name === '保存修改', true);
assert.doesNotMatch(policy.saveButton.name, /^一键保存/);
assert.equal(policy.forbidPageWideSaveRegex.source, '保存修改|保存');
});
});