mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* test: harden e2e inspect specs * test: wire e2e release reports * chore: bump packaged beta base to 0.6.1 * test: run release smoke vitest directly * test: add suite-owned tools-dev lifecycle * ci: harden stable release packaging * fix(release,e2e): gate stable signing on verify and harden suite cleanup - restore `needs: [metadata, verify]` on the stable release `build_mac`, `build_mac_intel`, `build_win`, and `build_linux` jobs so Apple signing/notarization and Windows release builds cannot run before pnpm guard, typecheck, and layout checks complete on the metadata commit. - in `runToolsDevSuite`, drop the `started` flag and always attempt `stopToolsDevWeb` in `finally`; record stop errors in diagnostics, and when the test body succeeded, escalate the stop failure to the suite result and rethrow — so orphan daemon/web processes from an interrupted `startToolsDevWeb` or a broken shutdown can no longer pass silently. Addresses PR #1140 review feedback from lefarcen and mrcfps.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
import { tmpdir } from 'node:os';
|
|
|
|
import { afterEach, describe, expect, test } from 'vitest';
|
|
|
|
import { createReport } from '@/vitest/report';
|
|
|
|
const roots: string[] = [];
|
|
|
|
describe('report lifecycle', () => {
|
|
afterEach(async () => {
|
|
await Promise.all(roots.splice(0).map((root) => rm(root, { force: true, recursive: true })));
|
|
});
|
|
|
|
test('saves binary and JSON entries under the report root', async () => {
|
|
const root = await makeRoot();
|
|
const report = await createReport(root);
|
|
|
|
const binary = await report.save('evidence/sample.bin', Buffer.from([1, 2, 3]));
|
|
const json = await report.json('summary.json', { ok: true });
|
|
|
|
expect(binary.relpath).toBe('evidence/sample.bin');
|
|
expect(binary.path).toBe(join(root, 'evidence', 'sample.bin'));
|
|
expect(binary.bytes).toBe(3);
|
|
expect(await readFile(binary.path)).toEqual(Buffer.from([1, 2, 3]));
|
|
expect(json.path).toBe(join(root, 'summary.json'));
|
|
expect(JSON.parse(await readFile(json.path, 'utf8'))).toEqual({ ok: true });
|
|
});
|
|
|
|
test('rejects absolute paths and parent traversal', async () => {
|
|
const report = await createReport(await makeRoot());
|
|
|
|
await expect(report.save('/tmp/out.txt', 'x')).rejects.toThrow(/relative/);
|
|
await expect(report.save('../out.txt', 'x')).rejects.toThrow(/escape/);
|
|
await expect(report.save('nested/../../out.txt', 'x')).rejects.toThrow(/escape/);
|
|
});
|
|
});
|
|
|
|
async function makeRoot(): Promise<string> {
|
|
const root = await mkdtemp(join(tmpdir(), 'open-design-e2e-report-'));
|
|
roots.push(root);
|
|
return root;
|
|
}
|