A draft the core refuses as lone_surrogate is unreadable content: it
goes to osteo:quarantine:draft verbatim with the existing notice. An
import is refused as ImportError('lone_surrogate') with the owner's
wording (home.import.error_lone_surrogate, FR/EN), the file untouched.
The publish gate reads the kind as invalid_shape. Tests on the real
core: quarantine keeps the exact text, an editor action leaves the
report as it was, normal text with pairs and literal backslashes reads
unchanged.
67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { nodeCoreRuntime, nodeCoreSource } from '../src/node'
|
|
|
|
const CORE_MANIFEST = new URL(
|
|
'../../../crates/core/Cargo.toml',
|
|
import.meta.url,
|
|
)
|
|
const WORKSPACE_MANIFEST = new URL('../../../Cargo.toml', import.meta.url)
|
|
const SHIPPED_DTS = new URL('../pkg/faunosteo_wasm.d.ts', import.meta.url)
|
|
|
|
describe('core facade (shipped wasm build)', () => {
|
|
it('reports the workspace version of the core', async () => {
|
|
const core = await nodeCoreRuntime()
|
|
const workspace = readFileSync(fileURLToPath(WORKSPACE_MANIFEST), 'utf8')
|
|
const version = /\[workspace\.package\][^[]*?version = "([^"]+)"/s.exec(
|
|
workspace,
|
|
)?.[1]
|
|
expect(version).toBeDefined()
|
|
expect(readFileSync(fileURLToPath(CORE_MANIFEST), 'utf8')).toContain(
|
|
'version.workspace = true',
|
|
)
|
|
expect(core.call('core_version', '')).toEqual({ ok: true, value: version })
|
|
})
|
|
|
|
it('answers with a closed outcome envelope', async () => {
|
|
const core = await nodeCoreRuntime()
|
|
expect(core.call('nope', '{}')).toMatchObject({
|
|
ok: false,
|
|
kind: 'unknown_op',
|
|
})
|
|
expect(core.call('pretty_json', '{ not json')).toMatchObject({
|
|
ok: false,
|
|
kind: 'invalid_json',
|
|
})
|
|
})
|
|
|
|
it('refuses a lone surrogate with its own kind, never a replacement (L1)', async () => {
|
|
const core = await nodeCoreRuntime()
|
|
const zone = JSON.stringify({ annotationId: 'a\ud800', viewId: 'v' })
|
|
expect(zone).toContain('\\ud800')
|
|
const refused = core.call('report_zone', zone)
|
|
expect(refused).toMatchObject({ ok: false, kind: 'lone_surrogate' })
|
|
expect(JSON.stringify(refused)).not.toContain('\ufffd')
|
|
const paired = JSON.stringify({ annotationId: 'a😀\\ud800', viewId: 'v' })
|
|
expect(core.call('report_zone', paired)).toEqual({
|
|
ok: true,
|
|
value: { annotationId: 'a😀\\ud800', viewId: 'v' },
|
|
})
|
|
})
|
|
|
|
it('ships no trap export (the proofs live in pkg-proofs only)', async () => {
|
|
const glue = (await nodeCoreSource('pkg').importGlue(0)) as unknown as Record<
|
|
string,
|
|
unknown
|
|
>
|
|
for (const name of ['core_version', 'call', 'SheetHandle']) {
|
|
expect(typeof glue[name]).toBe('function')
|
|
}
|
|
expect(glue.panic_for_test).toBeUndefined()
|
|
expect(glue.recurse_for_test).toBeUndefined()
|
|
const dts = readFileSync(fileURLToPath(SHIPPED_DTS), 'utf8')
|
|
expect(dts).not.toMatch(/panic_for_test|recurse_for_test/)
|
|
})
|
|
})
|