hololake-system-architecture/product-source/hololake-native-desktop/scripts/domain-number-routing.test.mjs

89 lines
4.9 KiB
JavaScript

import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const read = (relative) => fs.readFileSync(path.join(root, relative), 'utf8')
test('public routing starts from five domains and lets the number select the verifier', () => {
const contract = JSON.parse(read('contracts/domain-number-routing.json'))
assert.equal(contract.public_entry, 'FIVE_DOMAIN_HOME')
assert.equal(contract.user_selects_domain_before_number, false)
assert.equal(contract.route_key, 'USER_NUMBER')
assert.equal(contract.routing.number_shape_is_authority, false)
assert.equal(contract.routing.client_supplied_domain_is_authority, false)
assert.equal(contract.routing.unknown_or_unavailable_route, 'FAIL_CLOSED_BEFORE_LOGIN')
assert.equal(contract.registries.FIFTH_DOMAIN.ownership, 'ICE-GL_INFINITY_PRIVATE_DOMAIN')
assert.equal(contract.registries.ENTERPRISE_FOUR_DOMAINS.ownership, 'TCS_0002_ENTERPRISE_REALITY_BODY')
})
test('the public shell shows five domains and login is domain-routed', () => {
const frontend = read('src/main.tsx')
const login = read('src-tauri/src/code_repo_login.rs')
const router = read('src-tauri/src/zero_point.rs')
for (const name of ['光湖主域', '光湖分域', '光湖零域', '光湖零感域', '第五域 · 光湖本源域']) {
assert.match(frontend, new RegExp(name.replace('·', '\\·')))
}
assert.match(frontend, /输入编号进入所属域/)
assert.match(frontend, /TCS-GL-/)
assert.match(frontend, /肥猫 · TCS-GL-0007∞/)
assert.match(frontend, /桔子 · TCS-GL-0008∞/)
assert.match(frontend, /烬舟 · PER-JZ001 · AGE/)
assert.match(frontend, /熹微 · PER-JZ-ARCH-001 · AGE/)
assert.doesNotMatch(frontend, /肥猫 \+ 烬舟/)
assert.match(frontend, /className="gate-close"/)
assert.match(frontend, /className="domain-info-scrim"/)
assert.match(frontend, /setActiveDomainInfo\(gate\.domain\)/)
assert.match(frontend, /event\.key !== 'Escape'/)
assert.match(frontend, /编号 \{zeroPoint\?\.userNumber \|\| gateNumber\} · 欢迎登入光湖语言世界/)
assert.match(frontend, /createWorldWelcome\(snapshot\)/)
assert.match(frontend, /className="world-impression"/)
assert.match(frontend, /index === previous/)
assert.match(frontend, /核对人格关系/)
assert.match(frontend, /确认关系并签署/)
assert.match(frontend, /接受责任并签署/)
assert.doesNotMatch(frontend, /<aside className="sidebar">/)
assert.doesNotMatch(frontend, /className="traffic-lights"/)
assert.match(login, /login_host_for_domain/)
assert.match(login, /ENTERPRISE_LOGIN_HOST.*guanghu\.chat/)
assert.match(login, /change_enterprise_first_login_password/)
assert.match(frontend, /第一次使用?先修改一次性密码/)
assert.match(router, /enterprise_resolve_url/)
assert.match(router, /verified_user_route/)
assert.match(router, /FIFTH_DOMAIN.*MAIN_DOMAIN.*BRANCH_DOMAIN.*ZERO_DOMAIN.*ZERO_SENSE_DOMAIN/s)
})
test('the locked Qoder world template is the running client structure, not a skin reference', () => {
const contract = JSON.parse(read('contracts/enterprise-four-domain-entry.json'))
const frontend = read('src/main.tsx')
assert.equal(contract.state, 'SERVER_LIVE_CLIENT_UI_INTEGRATED')
assert.match(contract.ui_template, /official-login-template-v0\.4-locked\+inner-screens-v0\.1/)
assert.equal(contract.desktop_install_acceptance.mac_arm64, 'PASS')
assert.equal(contract.desktop_install_acceptance.mac_x86_64, 'NOT_BUILT')
assert.equal(contract.desktop_install_acceptance.windows, 'NOT_BUILT')
assert.equal(contract.desktop_install_acceptance.automatic_update_channel, 'UNPROVISIONED_FAIL_CLOSED')
assert.match(frontend, /number-nucleus/)
assert.match(frontend, /worldStage === 'domain'/)
assert.match(frontend, /worldStage === 'channel'/)
assert.match(frontend, /worldStage === 'tool'/)
})
test('the public five-domain world starts before any private account storage is opened', () => {
const library = read('src-tauri/src/lib.rs')
const broker = read('src-tauri/src/direct_local_broker.rs')
const home = read('src-tauri/src/home_status.rs')
assert.match(library, /DirectLocalBrokerState::default\(\)/)
assert.match(broker, /HOLOLAKE_AUTHENTICATED_ACCOUNT_REQUIRED/)
assert.match(broker, /Ok\(false\)/)
assert.match(home, /WAITING_FOR_LOGIN/)
assert.doesNotMatch(library, /let broker = direct_local_broker::start\(app\.handle\(\)\)\?/)
})
test('enterprise root uses a bounded lighthouse on the current Linux service node', () => {
const contract = JSON.parse(read('contracts/domain-number-routing.json'))
assert.equal(contract.server_runtime.enterprise_root, 'ENTERPRISE_LIGHTHOUSE_ON_CURRENT_LINUX_SERVICE_NODE')
assert.equal(contract.server_runtime.linux_role, 'PHYSICAL_SUBSTRATE_AND_SERVICE_SUPERVISOR')
assert.equal(contract.server_runtime.ordinary_user_node_requires_full_os_install, false)
})