mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Group 245 flat integration tests and 25 loose unit tests into
discoverable subdirectories per spec section 6:
integration/tools/{image,video,audio,document,data}/ (156 files)
integration/platform/ (64 files)
integration/generated/ (14 files)
integration/security/ (10 files)
unit/security/ (8 files, new subdir)
unit/api/ (7 files moved in)
unit/web/ (3 files moved in)
unit/shared/ (6 files moved in)
unit/image-engine/ (1 file moved in)
All moves via git mv (history preserved). Relative imports repaired
for both depth levels (platform/generated/security = +1, tools/ = +2):
static from-imports, dynamic import() calls, vi.mock() paths,
import.meta.dirname joins, and __dirname joins.
Vitest discovery unchanged (no test.include in config, recursive glob
matches subdirs, shard-by-hash unaffected). test-server.ts and
tool-route-drift.test.ts stay at integration root. fixtures/ untouched.
Parity gate: 13189 passing test names before = 13189 after (0 dropped).
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { readFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import {
|
|
convertDocument,
|
|
qpdfAvailable,
|
|
qpdfCheck,
|
|
qpdfPageCount,
|
|
sofficeAvailable,
|
|
} from "@snapotter/doc-engine";
|
|
import { describe, expect, it } from "vitest";
|
|
import { fixtures } from "../../fixtures/index.js";
|
|
|
|
const PDF = fixtures.document.pdf3;
|
|
const DOCX = fixtures.document.tiny("docx");
|
|
|
|
describe.skipIf(!qpdfAvailable())("doc-engine qpdf (requires qpdf)", () => {
|
|
it("counts pages", async () => {
|
|
expect(await qpdfPageCount(PDF)).toBe(3);
|
|
});
|
|
|
|
it("passes a structural check on a valid pdf", async () => {
|
|
await expect(qpdfCheck(PDF)).resolves.toBeUndefined();
|
|
});
|
|
|
|
it("rejects garbage", async () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "doc-engine-"));
|
|
try {
|
|
const bad = join(dir, "bad.pdf");
|
|
writeFileSync(bad, "not a pdf at all");
|
|
await expect(qpdfCheck(bad)).rejects.toThrow();
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
describe.skipIf(!sofficeAvailable())("doc-engine libreoffice (requires soffice)", () => {
|
|
it("converts docx to pdf with an isolated profile", async () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "doc-engine-lo-"));
|
|
try {
|
|
const outPath = await convertDocument(DOCX, dir, "pdf", { timeoutMs: 120_000 });
|
|
const bytes = await readFile(outPath);
|
|
expect(bytes.subarray(0, 5).toString()).toBe("%PDF-");
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
}, 150_000);
|
|
});
|