teqo-backup/tests/unit/reelsTutoriaisSkill.unit.spec.ts
Francisco Solla 8504b3b13a feat(C196): skill /reels-tutoriais — captura mobile + composição de vídeo
- skill + command finos: shot list é a fonte única; ajuste regenera, nada publica
- scripts/build-reel.mjs + scripts/lib/reel*.mjs: captura CDP com timestamps de
  parede (sem drift), cursor/halo DOM-injected, zoompan do log de cliques,
  legendas queimadas, capa 1080x1350-safe, concat H.264 1080x1920/30fps
- ffmpeg: FFMPEG_PATH -> PATH -> @ffmpeg-installer (registry-only) com probe fail-closed
- kit oficial da campanha: public/campaign-kit (marcas positiva/negativa, numero,
  estrela) + manual em docs/campaign-kit + README de regras; skill e agente de
  design referenciam o material
- 26 testes unit novos + pin do command; changelog 2026-09-18-c196

Closes #1155
2026-09-18 21:50:28 -03:00

77 lines
3 KiB
TypeScript

import { existsSync, readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import { buildReelMetadata } from '../../scripts/lib/reelPackage.mjs'
import { loadShotList, shotListHash } from '../../scripts/lib/reelShotList.mjs'
// C196 — the delivery contract of the reel builder: the package metadata the
// private library ingests, the versioned shot list of the first reel and the
// skill/command coupling (the reel is generated, never edited by hand).
const repoRoot = process.cwd()
const read = (path: string): string => readFileSync(resolve(repoRoot, path), 'utf8')
describe('reel package metadata', () => {
it('carries the identity the library ingests', () => {
const metadata = buildReelMetadata({
shotList: { slug: 'cards', title: 'Crie seu card de apoio', feature: 'cards' },
hash: 'a'.repeat(64),
durationMs: 18_418.6,
ffmpeg: 'ffmpeg version test',
generatedAt: new Date('2026-09-18T12:00:00.000Z'),
})
expect(metadata).toEqual({
slug: 'cards',
title: 'Crie seu card de apoio',
feature: 'cards',
shotListHash: 'a'.repeat(64),
durationMs: 18_419,
width: 1_080,
height: 1_920,
fps: 30,
codec: 'h264',
audio: false,
generatedAt: '2026-09-18T12:00:00.000Z',
ffmpeg: 'ffmpeg version test',
})
})
})
describe('shot list of the first reel', () => {
it('loads, validates and hashes the versioned cards shot list', async () => {
const { shotList, hash } = await loadShotList({ slug: 'cards', root: repoRoot })
expect(hash).toBe(shotListHash(shotList))
expect(shotList.scenes[0]).toMatchObject({ kind: 'graphic', template: 'hook' })
expect(shotList.scenes[shotList.scenes.length - 1]).toMatchObject({
kind: 'graphic',
template: 'cta',
})
const capture = shotList.scenes.filter((scene) => scene.kind === 'capture')
expect(capture).toHaveLength(3)
expect(capture.map((scene) => scene.badge?.number)).toEqual([1, 2, 3])
})
})
describe('skill /reels-tutoriais contract', () => {
it('ships the command coupled to the canonical skill', () => {
const command = read('.opencode/commands/reels-tutoriais.md')
expect(existsSync(resolve(repoRoot, '.agents/skills/reels-tutoriais/SKILL.md'))).toBe(true)
expect(command).toContain('`reels-tutoriais`')
expect(command).toContain('$ARGUMENTS')
expect(command).toContain('.agents/skills/reels-tutoriais/SKILL.md')
expect(command).toMatch(/^description: .+$/m)
expect(command).not.toMatch(/^\s*["']?model["']?\s*:/m)
})
it('keeps the gate contract: shot list is the source, adjustments regenerate', () => {
const skill = read('.agents/skills/reels-tutoriais/SKILL.md')
expect(skill).toContain('shot list')
expect(skill).toContain('Ajuste')
expect(skill).toContain('pnpm reels:build')
expect(skill).toContain('reel.mp4')
expect(skill).toContain('capa.png')
expect(skill).toContain('metadata.json')
expect(skill).toContain('Nada é publicado')
})
})