25 lines
1.2 KiB
JavaScript
25 lines
1.2 KiB
JavaScript
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { readFileSync } from 'node:fs';
|
||
|
|
import test from 'node:test';
|
||
|
|
|
||
|
|
const importBar = readFileSync(new URL('../../apps/web/src/master/ImportBar.tsx', import.meta.url), 'utf8');
|
||
|
|
const download = readFileSync(new URL('../../apps/web/src/api/download.ts', import.meta.url), 'utf8');
|
||
|
|
const backend = readFileSync(new URL('../../server/gateway/app.py', import.meta.url), 'utf8');
|
||
|
|
|
||
|
|
test('master data panel downloads the intake template through the authenticated helper', () => {
|
||
|
|
assert.match(importBar, /downloadAuthenticatedFile/);
|
||
|
|
assert.match(importBar, /\/api\/import\/template/);
|
||
|
|
assert.match(importBar, /\u4e0b\u8f7d\u91c7\u96c6\u6a21\u677f/);
|
||
|
|
assert.doesNotMatch(importBar, /window\.location\s*=|<\s*a\s+href=/);
|
||
|
|
assert.match(download, /export async function downloadAuthenticatedFile/);
|
||
|
|
assert.match(download, /response\.ok/);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('template endpoint stays behind auth and declares the template profile contract', () => {
|
||
|
|
assert.match(backend, /@app\.get\("\/api\/import\/template"\)/);
|
||
|
|
assert.match(backend, /build_intake_template\(profileId\)/);
|
||
|
|
assert.match(backend, /X-APS-Template-Id/);
|
||
|
|
assert.match(backend, /X-APS-Profile-Digest/);
|
||
|
|
assert.match(backend, /status_code=404/);
|
||
|
|
});
|