Datasets:
Download code/evaluation-code/v0.2-0c2690ae/apps/console/web/tests/verify.test.ts from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 3.46 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/tests/verify.test.ts
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/apps/console/web/tests/verify.test.ts
-
curl -L -o verify.test.ts https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/web/tests/verify.test.ts
3.46 kB
| import test from 'node:test'; | |
| import assert from 'node:assert/strict'; | |
| import {readFileSync} from 'node:fs'; | |
| import ts from 'typescript'; | |
| import {createElement} from 'react'; | |
| import {renderToStaticMarkup} from 'react-dom/server'; | |
| import {parseRoute} from '../src/route.ts'; | |
| import {VERIFY_BLOCKS, evidenceURL} from '../src/verify.ts'; | |
| import type {VerifyReport} from '../src/verify.ts'; | |
| // Existing node:test runner strips TS, so transpile the actual JSX component in memory. | |
| const source = readFileSync(new URL('../src/VerifyRows.tsx', import.meta.url), 'utf8'); | |
| const compiled = ts.transpileModule(source, {compilerOptions: {jsx: ts.JsxEmit.ReactJSX, module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2022}}).outputText | |
| .replaceAll('"react/jsx-runtime"', JSON.stringify(import.meta.resolve('react/jsx-runtime'))) | |
| .replaceAll("'./route.ts'", JSON.stringify(new URL('../src/route.ts', import.meta.url).href)) | |
| .replaceAll("'./verify.ts'", JSON.stringify(new URL('../src/verify.ts', import.meta.url).href)); | |
| const {VerifyTable} = await import('data:text/javascript;base64,' + Buffer.from(compiled).toString('base64')); | |
| const row = {index: 0, script_id: 'case-a', segment_id: 'np-1/case-a', state: 'completed', reason: null, seconds: 2.5, world: '102', tier: 'short', n: '4', robots: '1', observers: 'virtual', | |
| checks: Object.fromEntries(VERIFY_BLOCKS.map(([key], i) => [key, {status: ['ok','none','fail','warn','none'][i], summary: key+' receipt', details: {value: '<raw>'}, evidence: ['logs/with space.log'], log_tail: 'failure <trace>'}]))}; | |
| const report = {schema: 'np-verify-report/1', run_id: 'np-1', root_alias: 'np-1', status: 'completed', generator_commit: null, segments: [row], errors: [], generic_reasons: {}, evidence: []} as VerifyReport; | |
| test('verify route handles empty, explicit, encoded and malformed run identities', () => { | |
| assert.deepEqual(parseRoute('#/verify'), {page: 'verify', run: null}); | |
| assert.deepEqual(parseRoute('#/verify/np-1'), {page: 'verify', run: 'np-1'}); | |
| assert.deepEqual(parseRoute('#/verify/a%20b'), {page: 'verify', run: 'a b'}); | |
| assert.deepEqual(parseRoute('#/verify/%ZZ'), {page: 'verify', run: null}); | |
| assert.deepEqual(parseRoute('#/verify/'), {page: 'verify', run: null}); | |
| }); | |
| test('actual table renders one row, five status cells and expanded evidence with scoped review links', () => { | |
| const closed = renderToStaticMarkup(createElement(VerifyTable, {report, expanded: null, onSelect() {}})); | |
| assert.match(closed, /case-a/); assert.match(closed, /102/); assert.match(closed, /short/); | |
| assert.equal((closed.match(/aria-label=/g) || []).length, 5); | |
| assert.match(closed, /chip bad/); assert.match(closed, /chip warn/); assert.match(closed, /aria-expanded="false"/); | |
| assert.doesNotMatch(closed, /详细记录/); | |
| const opened = renderToStaticMarkup(createElement(VerifyTable, {report, expanded: 0, onSelect() {}})); | |
| assert.match(opened, /aria-expanded="true"/); | |
| assert.match(opened, /#\/segments\/np-1%2Fcase-a/); | |
| assert.match(opened, /evidence.html\?segment=np-1%2Fcase-a/); | |
| assert.match(opened, /target="_blank"/); assert.match(opened, /logs%2Fwith\+space.log/); | |
| assert.match(opened, /failure <trace>/); assert.match(opened, /<raw>/); | |
| assert.equal((opened.match(/详细记录/g) || []).length, 5); | |
| }); | |
| test('evidence URL preserves run identity', () => { | |
| assert.equal(evidenceURL('a/b', 'out/a b.json'), '/api/v1/np/runs/a%2Fb/file?path=out%2Fa+b.json'); | |
| }); | |