import { describe, it, expect } from 'vitest'; import { mkdtempSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { recordArtifact, recordSideObjection } from './round-memory-record.mjs'; import { getVersions, getArgs, getObjections } from './round-memory-store.mjs'; const dir = () => mkdtempSync(join(tmpdir(), 'rmrec-')); describe('recordArtifact', () => { it('пишет версию артефакта', () => { const d = dir(); recordArtifact('t1', 'plan', '# План\nтело', d); expect(getVersions('t1', 'plan', d)).toEqual(['# План\nтело']); }); it('пишет доводы последнего круга по дорожкам M/J', () => { const d = dir(); const content = `# План ## Переговоры ### Круг 1 **Наставнику:** довод M **Судье:** довод J ## Шаги`; recordArtifact('t1', 'plan', content, d); expect(getArgs('t1', 'plan', 'M', d)).toEqual(['довод M']); expect(getArgs('t1', 'plan', 'J', d)).toEqual(['довод J']); }); it('нет переговоров → версия есть, доводов нет', () => { const d = dir(); recordArtifact('t1', 'spec', '# Спека', d); expect(getVersions('t1', 'spec', d)).toEqual(['# Спека']); expect(getArgs('t1', 'spec', 'M', d)).toEqual([]); }); it('fail-quiet на мусоре не кидает', () => { expect(() => recordArtifact('t1', 'plan', null, '\0bad')).not.toThrow(); }); }); describe('recordSideObjection', () => { it('пишет дословное замечание стороны в дорожку', () => { const d = dir(); recordSideObjection('t1', 'plan', 'judge', 'замечание судьи', d); expect(getObjections('t1', 'plan', 'judge', d)).toEqual(['замечание судьи']); }); it('пустой текст не пишется', () => { const d = dir(); recordSideObjection('t1', 'plan', 'mentor', '', d); recordSideObjection('t1', 'plan', 'mentor', null, d); expect(getObjections('t1', 'plan', 'mentor', d)).toEqual([]); }); it('fail-quiet на мусоре не кидает', () => { expect(() => recordSideObjection('t1', 'plan', 'judge', 'x', '\0bad')).not.toThrow(); }); });