53 lines
3.2 KiB
JavaScript
53 lines
3.2 KiB
JavaScript
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/education-workspace.json'))
|
|
const registry = JSON.parse(read('contracts/numbered-ipc-registry.json'))
|
|
const modulePackage = JSON.parse(read('fixtures/module-packages/HLP-MOD-OFFICIAL-EDUCATION-WORKBENCH-0001-0.1.0.ghmod'))
|
|
const workspaceRust = read('src-tauri/src/education_workspace.rs')
|
|
const translationRust = read('src-tauri/src/education_translation.rs')
|
|
const frontend = [
|
|
read('src/modules/education-workspace/index.tsx'),
|
|
read('src/modules/education-workspace/education-data.ts'),
|
|
read('src/modules/education-workspace/education-adaptive-rendering.ts'),
|
|
].join('\n')
|
|
|
|
test('education is an official signed declarative adapter over the shared office foundation', () => {
|
|
assert.equal(contract.package.official_module_number, 'HLP-MOD-OFFICIAL-EDUCATION-WORKBENCH-0001')
|
|
assert.equal(contract.foundation_dependency.module_id, 'hololake.builtin.channel-workbench')
|
|
assert.equal(modulePackage.manifest.registrationClass, 'OFFICIAL_LIGHTHOUSE')
|
|
assert.equal(modulePackage.manifest.adapter, 'education-workbench-v1')
|
|
assert.equal(modulePackage.payload.adapterConfig.foundationModule, 'HLP-MOD-LOCAL-CHANNEL-WORKBENCH-0001')
|
|
assert.equal(modulePackage.payload.adapterConfig.importDefaultScope, 'UNASSIGNED')
|
|
assert.equal(modulePackage.payload.adapterConfig.modelFileTransferDefault, 'DENY')
|
|
assert.equal(modulePackage.manifest.permissions.length, 8)
|
|
})
|
|
|
|
test('all education effects cross the exact numbered adapter routes', () => {
|
|
const routes = registry.operations.filter((route) => route.module_number === 'HLP-NIPC-MOD-0024')
|
|
assert.deepEqual(routes.map((route) => route.operation_number), Array.from({ length: 18 }, (_, index) => `HLP-NIPC-OP-${String(index + 85).padStart(4, '0')}`))
|
|
assert.ok(routes.every((route) => route.target_number === 'HLP-NIPC-TGT-0024'))
|
|
assert.ok(routes.every((route) => route.admission === 'VERIFIED_HUMAN_ROUTE'))
|
|
assert.doesNotMatch(frontend, /from ['"]@tauri-apps\/api\/core['"]/)
|
|
assert.doesNotMatch(workspaceRust, /#\[tauri::command\]/)
|
|
assert.doesNotMatch(translationRust, /#\[tauri::command\]/)
|
|
assert.match(workspaceRust, /require_active_module_adapter/)
|
|
})
|
|
|
|
test('legacy silent corruption and automatic destructive behavior are rejected', () => {
|
|
assert.doesNotMatch(workspaceRust, /serde_json::from_str[^\n]+unwrap_or_default/)
|
|
assert.match(workspaceRust, /deny_unknown_fields/)
|
|
assert.match(frontend, /生成只读预览/)
|
|
assert.match(frontend, /我确认,写入清理结果/)
|
|
assert.match(frontend, /生成只读预览令牌/)
|
|
assert.match(frontend, /我确认,按此令牌执行/)
|
|
assert.match(frontend, /确认归入教育频道/)
|
|
})
|
|
|
|
test('education UI is independently lazy-loaded and reuses, rather than duplicates, office engines', () => {
|
|
assert.match(read('src/main.tsx'), /lazy\(\(\) => import\('\.\/modules\/education-workspace'\)/)
|
|
assert.match(read('src/modules/education-workspace/education-document-engine.tsx'), /channel-workbench\/document-engine/)
|
|
assert.match(read('src/modules/education-workspace/index.tsx'), /channel-workbench\/spreadsheet-engine/)
|
|
})
|