Baseline commit of the existing Maquina Comercial Pessoal project

Tracks the app that was already in place (capture, treatment, outreach,
WhatsApp integration, server, frontend, tests, docs) so future feature
work can branch and use isolated worktrees.
This commit is contained in:
Gustavo
2026-07-31 10:54:07 -03:00
parent 6cd336a41e
commit d330bb5ff0
132 changed files with 29969 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { EventEmitter } from 'node:events';
import { PassThrough } from 'node:stream';
import { readZipLines } from '../src/extract/rfb-extractor.mjs';
function fakeChild() {
const child = new EventEmitter();
child.stdout = new PassThrough();
child.stderr = new PassThrough();
child.kill = () => child.emit('exit', null, 'SIGTERM');
return child;
}
test('readZipLines rejeita leitor ZIP que encerra com codigo nao zero e inclui stderr limitado', async () => {
const child = fakeChild();
const zip = readZipLines({ name: 'fake', argsFor: () => [] }, 'ruim.zip', { spawn: () => child });
child.stderr.write('arquivo corrompido');
child.stdout.end();
child.emit('exit', 2, null);
await assert.rejects(zip.done, /codigo 2.*arquivo corrompido/i);
});
test('readZipLines rejeita erro de spawn mas nao trata kill intencional como corrupcao', async () => {
const failed = fakeChild();
const zipFailed = readZipLines({ name: 'missing', argsFor: () => [] }, 'x.zip', { spawn: () => failed });
failed.emit('error', new Error('ENOENT'));
await assert.rejects(zipFailed.done, /ENOENT/);
const cancelled = fakeChild();
const zipCancelled = readZipLines({ name: 'fake', argsFor: () => [] }, 'x.zip', { spawn: () => cancelled });
zipCancelled.close();
await zipCancelled.done;
});
test('readZipLines propaga erro do stream de saida do leitor', async () => {
const child = fakeChild();
const zip = readZipLines({ name: 'fake', argsFor: () => [] }, 'x.zip', { spawn: () => child });
child.stdout.emit('error', new Error('falha de leitura'));
await assert.rejects(zip.done, /falha de leitura/i);
});