Files
Agent-System/web/src/lib/workflowCategoryNavigation.test.ts
T
weichenandCursor ba4bb41e1c fix(e2e): switch to workflow category before opening controlled docs
UI-13a stayed on private after upload, so the doc menu had no
doc_proj* entries. Always use the category trigger first, then exact id.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-13 21:03:23 +00:00

58 lines
2.0 KiB
TypeScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
planExactDocOpen,
requiredCategoryForDocOpen,
} from './workflowCategoryNavigation';
describe('workflowCategoryNavigation', () => {
it('private menu cannot see doc_proj* so it must switch to workflow before exact select', () => {
const fromPrivate = planExactDocOpen({
currentCategory: 'private',
visibleMenuDocIds: ['doc-free-1789-1'],
targetDocId: 'doc_proj6143_intake',
});
assert.deepEqual(fromPrivate, [{ action: 'ensure_category', category: 'workflow' }]);
const afterSwitch = planExactDocOpen({
currentCategory: 'workflow',
visibleMenuDocIds: ['doc_proj6143_intake', 'doc_proj6143_prelim_design'],
targetDocId: 'doc_proj6143_intake',
});
assert.deepEqual(afterSwitch, [
{ action: 'ensure_category', category: 'workflow' },
{ action: 'select_exact', docId: 'doc_proj6143_intake' },
]);
});
it('fail-closes when the workflow menu is showing but the exact doc is missing', () => {
const verdict = planExactDocOpen({
currentCategory: 'workflow',
visibleMenuDocIds: ['doc_proj6143_prelim_design'],
targetDocId: 'doc_proj6143_intake',
});
const last = verdict[verdict.length - 1];
assert.equal(last?.action, 'fail');
if (last?.action !== 'fail') {
throw new Error('expected fail-closed last step');
}
assert.match(last.reason, /doc-selector menu missing data-doc-id=doc_proj6143_intake/);
});
it('label and taskKey opens always require the workflow category', () => {
assert.equal(requiredCategoryForDocOpen({ kind: 'workflow-label' }), 'workflow');
assert.equal(
requiredCategoryForDocOpen({ kind: 'controlled-task-key', taskKey: 'intake' }),
'workflow',
);
assert.equal(
requiredCategoryForDocOpen({ kind: 'exact-id', docId: 'doc_proj12_intake' }),
'workflow',
);
assert.equal(
requiredCategoryForDocOpen({ kind: 'exact-id', docId: 'doc-free-1' }),
'private',
);
});
});