mirror of
https://github.com/aaddrick/claude-desktop-debian.git
synced 2026-05-17 00:26:21 +03:00
test(harness): fix S25 by routing require through process.mainModule
Three bare `require('node:fs')` calls inside evalInMain bodies were
failing with `ReferenceError: require is not defined` on the bundled
Electron's main-process CDP eval scope — `require` isn't exposed as a
global there, only on the current module object. Adjacent calls on
the same blocks already used `process.mainModule.require('electron')`
correctly; the `node:fs` lines were the outliers.
Doc comment on lib/inspector.ts:evalInMain captures the gotcha so the
next caller doesn't trip the same wire.
S25 verified: passes in 15.1s on KDE-W (CLAUDE_TEST_USE_HOST_CONFIG=1).
Co-Authored-By: Claude <claude@anthropic.com>
This commit is contained in:
@@ -151,6 +151,9 @@ export class InspectorClient {
|
||||
// value. JSON-stringification inside the IIFE dodges the inspector's
|
||||
// Promise-result deep-marshaling quirks (returnByValue produces empty
|
||||
// objects for awaited Promise resolutions on this build).
|
||||
//
|
||||
// Bare `require` is NOT a global in the CDP eval scope — go through
|
||||
// `process.mainModule.require('electron'|'node:fs'|…)` instead.
|
||||
async evalInMain<T = unknown>(body: string, timeoutMs?: number): Promise<T> {
|
||||
const expression =
|
||||
'globalThis.__r = (async () => { ' +
|
||||
|
||||
@@ -104,7 +104,7 @@ test('S25 — safeStorage token round-trip survives app restart', async ({}, tes
|
||||
path: string;
|
||||
}>(`
|
||||
const { safeStorage } = process.mainModule.require('electron');
|
||||
const fs = require('node:fs');
|
||||
const fs = process.mainModule.require('node:fs');
|
||||
const cipher = safeStorage.encryptString(${JSON.stringify(PLAINTEXT)});
|
||||
fs.mkdirSync(${JSON.stringify(isolation.configDir)}, {
|
||||
recursive: true,
|
||||
@@ -133,7 +133,7 @@ test('S25 — safeStorage token round-trip survives app restart', async ({}, tes
|
||||
// that's harder to distinguish from a cross-restart break.
|
||||
const inSessionRoundTrip = await inspector.evalInMain<string>(`
|
||||
const { safeStorage } = process.mainModule.require('electron');
|
||||
const fs = require('node:fs');
|
||||
const fs = process.mainModule.require('node:fs');
|
||||
const cipher = fs.readFileSync(${JSON.stringify(tokenFile)});
|
||||
return safeStorage.decryptString(cipher);
|
||||
`);
|
||||
@@ -168,7 +168,7 @@ test('S25 — safeStorage token round-trip survives app restart', async ({}, tes
|
||||
|
||||
decrypted = await inspector.evalInMain<string>(`
|
||||
const { safeStorage } = process.mainModule.require('electron');
|
||||
const fs = require('node:fs');
|
||||
const fs = process.mainModule.require('node:fs');
|
||||
const cipher = fs.readFileSync(${JSON.stringify(tokenFile)});
|
||||
return safeStorage.decryptString(cipher);
|
||||
`);
|
||||
|
||||
Reference in New Issue
Block a user