Files
screenci__screenci/cli.source-scan.spec.ts
Olli Paloviita 34b24c1f7b feat(codesync): locate a video's builder by scanning recording sources
When an editable snapshot carries no source.file for a video (it was edited
before it was cleanly recorded), planCodeSync could not find the builder
declaration. Add listScreenciSourceFiles, a cheap recursive *.screenci.ts
scan (skipping node_modules/.screenci/.git/dist/test-results), and thread it
through applyCodegen and codeSync as an optional last-resort listRecordingFiles
fallback. The declaration is still disambiguated by the video(...)('<name>')
literal, so an over-broad list is harmless. Also make edit-id error messages
human-readable via describeEditId. Adds cli.source-scan and related specs.
2026-07-19 14:32:52 +03:00

42 lines
1.5 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { mkdtemp, mkdir, writeFile, rm } from 'fs/promises'
import { tmpdir } from 'os'
import { join } from 'path'
import { listScreenciSourceFiles } from './cli'
describe('listScreenciSourceFiles', () => {
let root: string
beforeEach(async () => {
root = await mkdtemp(join(tmpdir(), 'screenci-scan-'))
})
afterEach(async () => {
await rm(root, { recursive: true, force: true })
})
it('collects nested .screenci.ts sources and skips ignored dirs', async () => {
await mkdir(join(root, 'recordings'), { recursive: true })
await mkdir(join(root, 'node_modules', 'pkg'), { recursive: true })
await mkdir(join(root, '.screenci', 'Demo'), { recursive: true })
await mkdir(join(root, 'dist'), { recursive: true })
await writeFile(join(root, 'recordings', 'a.screenci.ts'), '')
await writeFile(join(root, 'b.screenci.ts'), '')
await writeFile(join(root, 'recordings', 'notes.ts'), '')
await writeFile(join(root, 'node_modules', 'pkg', 'x.screenci.ts'), '')
await writeFile(join(root, '.screenci', 'Demo', 'y.screenci.ts'), '')
await writeFile(join(root, 'dist', 'z.screenci.ts'), '')
expect(listScreenciSourceFiles(root).sort()).toEqual(
[
join(root, 'b.screenci.ts'),
join(root, 'recordings', 'a.screenci.ts'),
].sort()
)
})
it('returns an empty list for a missing directory', () => {
expect(listScreenciSourceFiles(join(root, 'does-not-exist'))).toEqual([])
})
})