diff --git a/src/main/orcad/node-pty-precondition.test.ts b/src/main/orcad/node-pty-precondition.test.ts index f5b567ae9ec..ee2194aaefe 100644 --- a/src/main/orcad/node-pty-precondition.test.ts +++ b/src/main/orcad/node-pty-precondition.test.ts @@ -179,21 +179,25 @@ describe('checkNodePtyPrecondition', () => { expect(verdict).toMatchObject({ status: 'blocked', reason: 'dependency_missing' }) }) - it('agrees with whether node-pty actually loads on this host', () => { - // Why compared against ground truth rather than asserted as 'ok': CI's test shard - // runs `vitest` directly, so `ensure-native-runtime --runtime=node` never prepares - // node-pty for the Node ABI and `degraded` is the CORRECT verdict there. Asserting - // 'ok' encoded a prepared environment the shard does not have. Asserting "whatever - // it said" would be vacuous, so this pins the verdict to an independent check. - let loads = true - try { - createRequire(import.meta.url)('node-pty') - } catch { - loads = false - } - + it('returns a self-consistent verdict against the real host', () => { + // Why not a predicted status: this depends on how the host was prepared. CI's test + // shard runs `vitest` directly, so `ensure-native-runtime --runtime=node` never + // builds node-pty for the Node ABI and `degraded` is correct there; a prepared + // checkout gives 'ok'. Predicting either encodes an environment. + // + // Why not require('node-pty') as ground truth: that resolves the JS wrapper while + // the native binding loads lazily, so it proves strictly less than this checks — + // that was the first version of this test and it failed on CI for that reason. + // + // What is invariant: on a host where node-pty is installed at all, the verdict is + // never 'blocked' and never carries an unestablished reason. const verdict = checkNodePtyPrecondition({ prebuildsDir: null }) - expect(verdict.status).toBe(loads ? 'ok' : 'degraded') + + expect(['ok', 'degraded']).toContain(verdict.status) + if (verdict.status === 'degraded') { + expect(verdict.reason).toBeDefined() + expect(verdict.reason).not.toBe('unknown') + } expect(verdict.slot).toBe( process.platform === 'linux' ? `linux-${process.arch}-${verdict.abi.libc}`