feat(FN-3723): harden isolated HOME cleanup and shell connection visibility
- Harden test isolation cleanup retries and allow-list behavior in scripts/test-changed.mjs - Expand test coverage for cleanup retry logic and allow-list handling in scripts/__tests__/test-changed.test.mjs - Add shell-native connection status plumbing and UI coverage across dashboard, desktop preload/types, and mobile typings - Add ShellConnectionStatus and mobile nav wiring plus related app/component test coverage - Document shell connection contracts and add FN-3568 diagnosis/recovery notes Fusion-Task-Id: FN-3723
This commit is contained in:
@@ -24,9 +24,12 @@ import {
|
||||
shouldRunIsolationGuard,
|
||||
defaultTestWorkerBudget,
|
||||
createIsolatedHomeEnv,
|
||||
cleanupIsolatedHomePath,
|
||||
knownIsolatedHomeBasenames,
|
||||
__setCleanupRmSyncForTests,
|
||||
} from "../test-changed.mjs";
|
||||
|
||||
import { mkdirSync, writeFileSync, mkdtempSync, rmSync } from "node:fs";
|
||||
import { mkdirSync, writeFileSync, mkdtempSync, rmSync, existsSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
@@ -673,3 +676,63 @@ test("createIsolatedHomeEnv: returns temp HOME/USERPROFILE pair without mutating
|
||||
|
||||
rmSync(isolatedHome, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
test("cleanupIsolatedHomePath: removes existing isolated HOME directory", () => {
|
||||
const homePath = mkdtempSync(path.join(tmpdir(), "fusion-test-home-root-cleanup-"));
|
||||
assert.equal(path.basename(homePath).startsWith("fusion-test-home-root-cleanup-"), true);
|
||||
|
||||
cleanupIsolatedHomePath(homePath);
|
||||
|
||||
assert.equal(existsSync(homePath), false);
|
||||
});
|
||||
|
||||
test("cleanupIsolatedHomePath: silently succeeds for ENOENT paths", () => {
|
||||
const missingPath = path.join(tmpdir(), `fusion-test-home-root-missing-${Date.now()}-${Math.random()}`);
|
||||
const warnings = [];
|
||||
const originalWarn = console.warn;
|
||||
console.warn = (msg) => warnings.push(String(msg));
|
||||
|
||||
try {
|
||||
cleanupIsolatedHomePath(missingPath);
|
||||
} finally {
|
||||
console.warn = originalWarn;
|
||||
}
|
||||
|
||||
assert.deepEqual(warnings, []);
|
||||
});
|
||||
|
||||
test("cleanupIsolatedHomePath: warns once after bounded retry failures", () => {
|
||||
const homePath = mkdtempSync(path.join(tmpdir(), "fusion-test-home-root-fail-"));
|
||||
const warnings = [];
|
||||
const originalWarn = console.warn;
|
||||
const error = Object.assign(new Error("simulated EBUSY"), { code: "EBUSY" });
|
||||
let calls = 0;
|
||||
|
||||
__setCleanupRmSyncForTests(() => {
|
||||
calls += 1;
|
||||
throw error;
|
||||
});
|
||||
console.warn = (msg) => warnings.push(String(msg));
|
||||
|
||||
try {
|
||||
cleanupIsolatedHomePath(homePath, 3, 0);
|
||||
} finally {
|
||||
__setCleanupRmSyncForTests(null);
|
||||
console.warn = originalWarn;
|
||||
rmSync(homePath, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
assert.equal(calls, 3);
|
||||
assert.equal(warnings.length, 1);
|
||||
assert.match(warnings[0], /failed to remove isolated HOME/);
|
||||
});
|
||||
|
||||
test("createIsolatedHomeEnv: records raw/realpath basenames in allow-list set", () => {
|
||||
const { isolatedHome } = createIsolatedHomeEnv({ PATH: process.env.PATH || "" });
|
||||
const base = path.basename(isolatedHome);
|
||||
|
||||
assert.equal(knownIsolatedHomeBasenames.has(base), true);
|
||||
assert.ok(knownIsolatedHomeBasenames.size >= 1);
|
||||
|
||||
cleanupIsolatedHomePath(isolatedHome);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user