Files
portal/tools/extract-node-dormancy.test.mjs
T
Дмитрий 6dec34403f feat(observer): node-dormancy extractor + initial JSON snapshot
Two-signal availability check: dormant=true OR boundaries contains DEFERRED.
Treats #17 (Tooling-marked) and #44/#50/#54/#67 (DEFERRED in boundaries)
uniformly as unavailable. Tooling Прил.Н unmodified — semantics preserved.

7 vitest cases (basic, multi-row, DEFERRED-fallback, boundary check).
Initial JSON: 67 nodes, 6 unavailable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 09:59:56 +03:00

54 lines
2.4 KiB
JavaScript

import { describe, it, expect } from 'vitest';
import { extractDormancy } from './extract-node-dormancy.mjs';
describe('extractDormancy', () => {
it('returns false for a live row (dormant=false, no DEFERRED in boundaries)', () => {
const md = [
'#### #10 Laravel Boost',
'',
'**Атрибуты:**',
'',
'| id | name | kind | phase | subcategory | triggers | boundaries | dormant | last-touched |',
'|---|---|---|---|---|---|---|---|---|',
'| #10 | Laravel Boost | composer-dep | 1 | — | «SQL, Eloquent» | replaces #1 PG MCP | false | 2026-05-19 |',
].join('\n');
expect(extractDormancy(md)).toEqual({ '#10': false });
});
it('returns true when Tooling marks dormant=true', () => {
const md = '| #17 | pg_partman | binary-dep | 1 | — | «partition mgmt» | none | true | 2026-05-19 |';
expect(extractDormancy(md)).toEqual({ '#17': true });
});
it('returns true when boundaries contains DEFERRED (even if dormant=false)', () => {
const md = '| #44 | Figma MCP | mcp | off-phase | design-tooling | «figma extract» | DEFERRED — нет Figma-аккаунта | false | 2026-05-19 |';
expect(extractDormancy(md)).toEqual({ '#44': true });
});
it('handles multiple nodes in one pass (mixed signals)', () => {
const md = [
'| #44 | Figma MCP | mcp | off-phase | design-tooling | «figma extract» | DEFERRED — нет Figma | false | 2026-05-17 |',
'| #45 | Universal Icons MCP | mcp | off-phase | design-tooling | «svg search» | non-Lucide | false | 2026-05-17 |',
].join('\n');
expect(extractDormancy(md)).toEqual({ '#44': true, '#45': false });
});
it('ignores header/separator rows', () => {
const md = [
'| id | name | kind | phase | subcategory | triggers | boundaries | dormant | last-touched |',
'|---|---|---|---|---|---|---|---|---|',
].join('\n');
expect(extractDormancy(md)).toEqual({});
});
it('ignores non-numeric ids (template placeholders)', () => {
const md = '| #NN | <name> | <kind> | <phase> | <subcat or —> | «<triggers>» | <ADR-NNN or none> | false | 2026-05-19 |';
expect(extractDormancy(md)).toEqual({});
});
it('does NOT match the word DEFERRED inside a longer token (boundary check)', () => {
const md = '| #99 | fake | mcp | off | tooling | «t» | NODEFERREDX prefix | false | 2026-05-19 |';
expect(extractDormancy(md)).toEqual({ '#99': false });
});
});