Files
Claude-Code-Workflow/ccw/frontend/src/lib/ccw-artifacts.test.ts
catlog22 8938c47f88 feat: add experimental support for AST parsing and static graph indexing
- Introduced CLI options for using AST grep parsers and enabling static graph relationships during indexing.
- Updated configuration management to load new settings for AST parsing and static graph types.
- Enhanced AST grep processor to handle imports with aliases and improve relationship tracking.
- Modified TreeSitter parsers to support synthetic module scopes for better static graph persistence.
- Implemented global relationship updates in the incremental indexer for static graph expansion.
- Added new ArtifactTag and FloatingFileBrowser components to the frontend for improved terminal dashboard functionality.
- Created utility functions for detecting CCW artifacts in terminal output with associated tests.
2026-02-15 23:12:06 +08:00

74 lines
2.4 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { detectCcArtifacts } from './ccw-artifacts';
describe('ccw-artifacts', () => {
it('returns empty array for empty input', () => {
expect(detectCcArtifacts('')).toEqual([]);
});
it('detects workflow session artifacts', () => {
const text = 'Created: (.workflow/active/WFS-demo/workflow-session.json)';
expect(detectCcArtifacts(text)).toEqual([
{ type: 'workflow-session', path: '.workflow/active/WFS-demo/workflow-session.json' },
]);
});
it('detects lite session artifacts', () => {
const text = 'Plan: .workflow/.lite-plan/terminal-dashboard-enhancement-2026-02-15/plan.json';
expect(detectCcArtifacts(text)).toEqual([
{ type: 'lite-session', path: '.workflow/.lite-plan/terminal-dashboard-enhancement-2026-02-15/plan.json' },
]);
});
it('detects CLAUDE.md artifacts (case-insensitive)', () => {
const text = 'Updated: /repo/docs/claude.md and also CLAUDE.md';
const res = detectCcArtifacts(text);
expect(res).toEqual([
{ type: 'claude-md', path: '/repo/docs/claude.md' },
{ type: 'claude-md', path: 'CLAUDE.md' },
]);
});
it('detects CCW config artifacts', () => {
const text = 'Config: .ccw/config.toml and ccw.config.yaml';
expect(detectCcArtifacts(text)).toEqual([
{ type: 'ccw-config', path: '.ccw/config.toml' },
{ type: 'ccw-config', path: 'ccw.config.yaml' },
]);
});
it('detects issue artifacts', () => {
const text = 'Queue: .workflow/issues/queues/index.json';
expect(detectCcArtifacts(text)).toEqual([
{ type: 'issue', path: '.workflow/issues/queues/index.json' },
]);
});
it('deduplicates repeated artifacts', () => {
const text = '.workflow/issues/issues.jsonl ... .workflow/issues/issues.jsonl';
expect(detectCcArtifacts(text)).toEqual([
{ type: 'issue', path: '.workflow/issues/issues.jsonl' },
]);
});
it('preserves discovery order across types', () => {
const text = [
'Issue: .workflow/issues/issues.jsonl',
'Then plan: .workflow/.lite-plan/abc/plan.json',
'Then session: .workflow/active/WFS-x/workflow-session.json',
'Then config: .ccw/config.toml',
'Then CLAUDE: CLAUDE.md',
].join(' | ');
const res = detectCcArtifacts(text);
expect(res.map((a) => a.type)).toEqual([
'issue',
'lite-session',
'workflow-session',
'ccw-config',
'claude-md',
]);
});
});