import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import test from 'node:test' const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8') const contract = JSON.parse(read('contracts/channel-workbench-runtime.json')) const registry = JSON.parse(read('contracts/numbered-ipc-registry.json')) const modulePackage = JSON.parse(read('fixtures/module-packages/HLP-MOD-LOCAL-CHANNEL-WORKBENCH-0001-0.1.0.ghmod')) const rust = read('src-tauri/src/channel_workbench.rs') const frontend = [read('src/modules/channel-workbench/index.tsx'), read('src/modules/channel-workbench/document-engine.tsx'), read('src/modules/channel-workbench/spreadsheet-engine.tsx')].join('\n') test('channel workbench is a signed account-local adapter with durable user data', () => { assert.equal(contract.candidate_number, 'HLP-DONOR-CAND-0002') assert.equal(contract.runtime_module_number, 'HLP-MOD-LOCAL-CHANNEL-WORKBENCH-0001') assert.equal(contract.data_boundary.scope, 'CURRENT_AUTHENTICATED_ACCOUNT_LOCAL') assert.equal(contract.data_boundary.package_unmount_deletes_user_data, false) assert.equal(modulePackage.manifest.adapter, 'channel-workbench-v1') assert.deepEqual(modulePackage.manifest.permissions, ['CHANNEL_DOCUMENT_READ', 'CHANNEL_DOCUMENT_WRITE', 'CHANNEL_SPREADSHEET_READ', 'CHANNEL_SPREADSHEET_WRITE']) assert.match(rust, /require_active_module_adapter/) assert.match(rust, /workbench_receipts_no_update/) assert.doesNotMatch(rust, /#\[tauri::command\]/) assert.doesNotMatch(frontend, /from ['"]@tauri-apps\/api\/core['"]/) }) test('document and spreadsheet cross only their exact numbered routes', () => { const routes = registry.operations.filter((route) => route.module_number === 'HLP-NIPC-MOD-0022') assert.deepEqual(routes.map((route) => route.operation_number), ['HLP-NIPC-OP-0074', 'HLP-NIPC-OP-0075', 'HLP-NIPC-OP-0076']) assert.deepEqual(routes.map((route) => route.alias), ['get_channel_workbench_snapshot', 'save_channel_document', 'save_channel_spreadsheet']) assert.ok(routes.every((route) => route.target_number === 'HLP-NIPC-TGT-0022')) assert.ok(routes.every((route) => route.admission === 'VERIFIED_HUMAN_ROUTE')) }) test('the legacy engines are preserved but loaded only inside the module chunk', () => { assert.match(frontend, /LexicalComposer/) assert.match(frontend, /Workbook/) assert.match(frontend, /calculateFormula/) assert.match(read('src/main.tsx'), /lazy\(\(\) => import\('\.\/modules\/channel-workbench'\)/) })