import test from 'node:test'; import assert from 'node:assert/strict'; import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync, symlinkSync, realpathSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { cleanupWorkshop, removeRoomNavigation } from '../../scripts/apply-room-tab-cleanup.mjs'; const before = `// Claude's edited full-room layout — é🤖\r\nexport const Workshop = () =>
\r\n\r\nDemo
;\r\n`; const fragment = ''; function fixture(t) { const root = mkdtempSync(join(realpathSync(tmpdir()), 'tsc-room-cleanup-')); t.after(() => rmSync(root, { recursive: true, force: true })); mkdirSync(join(root, 'apps/web/src/components'), { recursive: true }); writeFileSync(join(root, 'package.json'), JSON.stringify({ name: 'thatstupidcomputer' })); const path = join(root, 'apps/web/src/components/Workshop.tsx'); writeFileSync(path, before); return { targetRoot: root, path }; } test('AST removal preserves all surrounding Claude edits, line endings and remaining navigation byte-for-byte', () => { const result = removeRoomNavigation(before); assert.equal(result.source, before.replace(fragment, '')); assert.match(result.source, /top:96/); assert.match(result.source, //); assert.match(result.source, //); assert.match(result.source, /href="\/contact\/"/); assert.doesNotMatch(result.source, /onMouseEnter|item.tip/); assert.equal(removeRoomNavigation(result.source).status, 'already-clean'); }); test('literal class expressions and expression-valued navs are removed without invalid TSX', () => { assert.equal(removeRoomNavigation('export const x = show && ;').source, 'export const x = show && null;'); assert.equal(removeRoomNavigation('export const x = <>