test(FN-4783): stabilize workspace test lanes for verification

Fusion-Task-Id: FN-4783
Fusion-Task-Lineage: 7a02897b-e303-4947-86b2-3dd7a343f653
This commit is contained in:
Fusion (runfusion.ai)
2026-05-16 13:43:16 -07:00
committed by gsxdsm
parent 3c272cda63
commit 415cd6a111
6 changed files with 40 additions and 20 deletions

View File

@@ -296,11 +296,15 @@ describe("bin command routing and fallbacks", () => {
expect(output).toContain("worktrunk.onFailure");
});
it("launches dashboard when no args are provided", async () => {
commandMocks.runDashboard.mockResolvedValue({ dispose: vi.fn() });
await runBin([]);
expect(commandMocks.runDashboard).toHaveBeenCalled();
});
it(
"launches dashboard when no args are provided",
async () => {
commandMocks.runDashboard.mockResolvedValue({ dispose: vi.fn() });
await runBin([]);
expect(commandMocks.runDashboard).toHaveBeenCalled();
},
15000,
);
it(
"prints an error for unknown top-level command",

View File

@@ -128,22 +128,29 @@ describe("test-project fixture", () => {
});
it("cleans up auto-created temp dirs when setup fails before returning a fixture", async () => {
const projectPrefix = `fusion-test-project-failure-${Date.now()}-`;
const globalPrefix = `fusion-test-global-failure-${Date.now()}-`;
const countTmpDirs = (prefix: string) =>
readdirSync(tmpdir()).filter((entry) => entry.startsWith(prefix)).length;
const projectCountBefore = countTmpDirs("fusion-test-project-");
const globalCountBefore = countTmpDirs("fusion-test-global-");
const projectCountBefore = countTmpDirs(projectPrefix);
const globalCountBefore = countTmpDirs(globalPrefix);
const error = new Error("boom");
const spy = vi.spyOn(TaskStore.prototype, "updateSettings").mockRejectedValueOnce(error);
try {
await expect(createTestProject()).rejects.toThrow(error);
await expect(
createTestProject({
rootDirPrefix: projectPrefix,
globalDirPrefix: globalPrefix,
}),
).rejects.toThrow(error);
} finally {
spy.mockRestore();
}
expect(countTmpDirs("fusion-test-project-")).toBe(projectCountBefore);
expect(countTmpDirs("fusion-test-global-")).toBe(globalCountBefore);
expect(countTmpDirs(projectPrefix)).toBe(projectCountBefore);
expect(countTmpDirs(globalPrefix)).toBe(globalCountBefore);
});
it("createTestProject({ seedTasks }) pre-seeds tasks during setup", async () => {

View File

@@ -16,6 +16,8 @@ export interface CreateTestProjectOptions {
seedTasks?: number;
globalSettingsDir?: string;
settings?: Partial<Settings>;
rootDirPrefix?: string;
globalDirPrefix?: string;
}
export interface TestProjectFixture {
@@ -67,10 +69,12 @@ function splitSettings(settings?: Partial<Settings>): {
export async function createTestProject(
options: CreateTestProjectOptions = {},
): Promise<TestProjectFixture> {
const rootDir = mkdtempSync(join(tmpdir(), "fusion-test-project-"));
const rootDirPrefix = options.rootDirPrefix ?? "fusion-test-project-";
const globalDirPrefix = options.globalDirPrefix ?? "fusion-test-global-";
const rootDir = mkdtempSync(join(tmpdir(), rootDirPrefix));
const globalDir = options.globalSettingsDir
? options.globalSettingsDir
: mkdtempSync(join(tmpdir(), "fusion-test-global-"));
: mkdtempSync(join(tmpdir(), globalDirPrefix));
const ownsGlobalDir = !options.globalSettingsDir;
assertAbsolutePath(rootDir, "rootDir");

View File

@@ -120,6 +120,7 @@ describe("native integrations", () => {
mocks.updaterHandlers.clear();
mocks.autoUpdater.autoDownload = false;
mocks.autoUpdater.autoInstallOnAppQuit = false;
(mocks.Notification.isSupported as ReturnType<typeof vi.fn>).mockReturnValue(true);
mocks.dialog.showSaveDialog.mockResolvedValue({
canceled: false,
@@ -303,8 +304,10 @@ describe("native integrations", () => {
setupAutoUpdater(mocks.browserWindow as never);
await vi.dynamicImportSettled();
expect(mocks.autoUpdater.autoDownload).toBe(true);
expect(mocks.autoUpdater.autoInstallOnAppQuit).toBe(true);
await vi.waitFor(() => {
expect(mocks.autoUpdater.autoDownload).toBe(true);
expect(mocks.autoUpdater.autoInstallOnAppQuit).toBe(true);
});
});
it("registers updater listeners and checks for updates", async () => {
@@ -313,10 +316,12 @@ describe("native integrations", () => {
setupAutoUpdater(mocks.browserWindow as never);
await vi.dynamicImportSettled();
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("update-available", expect.any(Function));
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("update-downloaded", expect.any(Function));
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("error", expect.any(Function));
expect(mocks.autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);
await vi.waitFor(() => {
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("update-available", expect.any(Function));
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("update-downloaded", expect.any(Function));
expect(mocks.autoUpdater.on).toHaveBeenCalledWith("error", expect.any(Function));
expect(mocks.autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1);
});
});
it("update-available triggers notification and renderer IPC", async () => {

View File

@@ -148,5 +148,5 @@ describe("foreign start-point no-owned-commit interactions (real git)", () => {
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
}, 20_000);
});

View File

@@ -91,5 +91,5 @@ describe("verification-fix already-on-main reliability interactions (real git)",
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
}, 20_000);
});