hololake-system-architecture/product-source/hololake-native-desktop/scripts/authenticated-main-world-navigation.test.mjs

26 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict'
import fs from 'node:fs'
import test from 'node:test'
const frontend = fs.readFileSync(new URL('../src/main.tsx', import.meta.url), 'utf8')
const architecture = JSON.parse(
fs.readFileSync(new URL('../../../routing/hololake-current-architecture.json', import.meta.url), 'utf8'),
)
test('returning to the main world preserves the authenticated session', () => {
const handler = frontend.match(/const returnToMainWorld = \(\) => \{([\s\S]*?)\n \}/)?.[1] || ''
assert.match(handler, /setShowMainWorld\(true\)/)
assert.doesNotMatch(handler, /signOutRepo|setRepoLogin\(null\)|sign_out_code_repo_login/)
assert.match(frontend, /if \(!repoLogin \|\| showMainWorld\)/)
})
test('main-world return and account sign-out remain separate visible actions', () => {
assert.match(frontend, />返回主世界</)
assert.match(frontend, />进入所属域</)
assert.match(frontend, />退出账号</)
assert.equal(
architecture.current_native_edge.authenticated_main_world_navigation,
'SOURCE_INTEGRATED_SESSION_PRESERVING_REENTRY',
)
})