@flighthq/tool-capture 0.2.0 → 0.2.1-next.423.3350e53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +39 -0
- package/dist/bin.js.map +1 -0
- package/dist/captureBrowser.d.ts +1 -0
- package/dist/captureBrowser.d.ts.map +1 -1
- package/dist/captureBrowser.js +94 -9
- package/dist/captureBrowser.js.map +1 -1
- package/dist/captureEntries.d.ts +2 -1
- package/dist/captureEntries.d.ts.map +1 -1
- package/dist/captureEntries.js +4 -0
- package/dist/captureEntries.js.map +1 -1
- package/dist/captureEntry.d.ts +64 -0
- package/dist/captureEntry.d.ts.map +1 -1
- package/dist/captureEntry.js +354 -26
- package/dist/captureEntry.js.map +1 -1
- package/dist/captureServer.js +4 -1
- package/dist/captureServer.js.map +1 -1
- package/dist/functionalVerify.d.ts +51 -0
- package/dist/functionalVerify.d.ts.map +1 -0
- package/dist/functionalVerify.js +140 -0
- package/dist/functionalVerify.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/referenceCapture.d.ts +31 -0
- package/dist/referenceCapture.d.ts.map +1 -0
- package/dist/referenceCapture.js +142 -0
- package/dist/referenceCapture.js.map +1 -0
- package/package.json +7 -1
- package/src/captureEntry.test.ts +113 -1
- package/src/functionalVerify.test.ts +94 -0
- package/src/referenceCapture.test.ts +81 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { discoverReferenceEntries, runReferenceCapture, startReferenceDevServer } from './referenceCapture';
|
|
8
|
+
|
|
9
|
+
// Builds a minimal flight-reference checkout tree: content/frameworks/<framework>/<corpus>/<case>. A case
|
|
10
|
+
// is only discoverable when it has a Flight implementation at flight/src/app.ts.
|
|
11
|
+
function writeCase(root: string, framework: string, corpus: string, name: string, withApp: boolean): void {
|
|
12
|
+
const caseDir = join(root, 'content', 'frameworks', framework, corpus, name);
|
|
13
|
+
mkdirSync(caseDir, { recursive: true });
|
|
14
|
+
if (withApp) {
|
|
15
|
+
mkdirSync(join(caseDir, 'flight', 'src'), { recursive: true });
|
|
16
|
+
writeFileSync(join(caseDir, 'flight', 'src', 'app.ts'), 'export {};');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('discoverReferenceEntries', () => {
|
|
21
|
+
let root: string;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
root = mkdtempSync(join(tmpdir(), 'reference-capture-'));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
rmSync(root, { recursive: true, force: true });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('returns one entry per case with a Flight app, named framework/corpus/case and sorted', () => {
|
|
32
|
+
writeCase(root, 'openfl', 'display', 'node-alpha', true);
|
|
33
|
+
writeCase(root, 'awayjs', 'intermediate', 'md5-animation', true);
|
|
34
|
+
|
|
35
|
+
const entries = discoverReferenceEntries(root);
|
|
36
|
+
|
|
37
|
+
expect(entries.map((e) => e.name)).toEqual(['awayjs/intermediate/md5-animation', 'openfl/display/node-alpha']);
|
|
38
|
+
expect(entries.every((e) => e.renderers.includes('webgl'))).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('routes to the harness `${framework}-tests/${corpus}/${case}/flight/${renderer}/` URL', () => {
|
|
42
|
+
writeCase(root, 'awayjs', 'intermediate', 'md5-animation', true);
|
|
43
|
+
|
|
44
|
+
const [entry] = discoverReferenceEntries(root);
|
|
45
|
+
|
|
46
|
+
expect(entry!.route?.('webgl')).toBe('awayjs-tests/intermediate/md5-animation/flight/webgl/');
|
|
47
|
+
expect(entry!.route?.('flight:webgl')).toBe('awayjs-tests/intermediate/md5-animation/flight/flight-webgl/');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('skips _shared directories and cases without a Flight app', () => {
|
|
51
|
+
writeCase(root, 'openfl', 'display', '_shared', true);
|
|
52
|
+
writeCase(root, 'openfl', 'display', 'starling-only', false);
|
|
53
|
+
|
|
54
|
+
expect(discoverReferenceEntries(root)).toEqual([]);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('returns empty when the frameworks directory is absent', () => {
|
|
58
|
+
expect(discoverReferenceEntries(join(root, 'missing'))).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('runReferenceCapture', () => {
|
|
63
|
+
// The full session starts flight-reference's Vite dev server and launches a browser, so it is exercised
|
|
64
|
+
// end to end by capture:reference. Here we only assert the entry point is wired and validates input.
|
|
65
|
+
it('rejects when no reference cases match', async () => {
|
|
66
|
+
const root = mkdtempSync(join(tmpdir(), 'reference-capture-'));
|
|
67
|
+
try {
|
|
68
|
+
await expect(
|
|
69
|
+
runReferenceCapture({ checkoutDir: root, repoRoot: root, outBase: join(root, 'out') }),
|
|
70
|
+
).rejects.toThrow(/No reference cases/);
|
|
71
|
+
} finally {
|
|
72
|
+
rmSync(root, { recursive: true, force: true });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('startReferenceDevServer', () => {
|
|
78
|
+
it('is a callable dev-server starter', () => {
|
|
79
|
+
expect(typeof startReferenceDevServer).toBe('function');
|
|
80
|
+
});
|
|
81
|
+
});
|