feat(FN-3314): align auth route assertion in agents routes test

Test FN-3314 completes its final step by refining an auth route assertion in the agents routes test, ensuring the test accurately validates the expected behavior.

Fusion-Task-Id: FN-3314
This commit is contained in:
Fusion
2026-05-04 14:58:58 -07:00
committed by gsxdsm
parent 3b4bb2d134
commit a66ddf2e7f
4 changed files with 24 additions and 13 deletions

View File

@@ -60,6 +60,7 @@ function createMockStore(overrides: Partial<TaskStore> = {}): TaskStore {
return {
getSettings: vi.fn().mockResolvedValue({ remoteAccess: buildRemoteAccessSettings() }),
updateSettings: vi.fn(async (patch: Record<string, unknown>) => patch),
updateGlobalSettings: vi.fn().mockResolvedValue(undefined),
getRootDir: vi.fn().mockReturnValue("/fake/root"),
getFusionDir: vi.fn().mockReturnValue("/fake/root/.fusion"),
getDatabase: vi.fn().mockReturnValue({
@@ -125,13 +126,13 @@ beforeEach(() => {
describe("remote access provider/lifecycle contracts", () => {
it("switches active provider and rejects invalid provider values", async () => {
const updateSettings = vi.fn().mockResolvedValue(undefined);
const { app } = createApp({ store: createMockStore({ updateSettings }) });
const updateGlobalSettings = vi.fn().mockResolvedValue(undefined);
const { app } = createApp({ store: createMockStore({ updateGlobalSettings }) });
const activate = await REQUEST(app, "POST", "/api/remote/provider/activate", { provider: "tailscale" });
expect(activate.status).toBe(200);
expect(activate.body).toEqual({ activeProvider: "tailscale" });
expect(updateSettings).toHaveBeenCalledWith(expect.objectContaining({
expect(updateGlobalSettings).toHaveBeenCalledWith(expect.objectContaining({
remoteAccess: expect.objectContaining({ activeProvider: "tailscale" }),
}));
@@ -144,17 +145,17 @@ describe("remote access provider/lifecycle contracts", () => {
});
it("seeds defaults when activating a provider on a fresh project", async () => {
const updateSettings = vi.fn().mockResolvedValue(undefined);
const updateGlobalSettings = vi.fn().mockResolvedValue(undefined);
const store = createMockStore({
getSettings: vi.fn().mockResolvedValue({}),
updateSettings,
updateGlobalSettings,
});
const { app } = createApp({ store });
const activate = await REQUEST(app, "POST", "/api/remote/provider/activate", { provider: "cloudflare" });
expect(activate.status).toBe(200);
expect(updateSettings).toHaveBeenCalledWith(expect.objectContaining({
expect(updateGlobalSettings).toHaveBeenCalledWith(expect.objectContaining({
remoteAccess: expect.objectContaining({
activeProvider: "cloudflare",
}),

View File

@@ -199,8 +199,8 @@ describe("remote access API route contracts", () => {
lastError: null,
}),
};
const updateSettings = vi.fn().mockResolvedValue(undefined);
const store = createMockStore({ updateSettings });
const updateGlobalSettings = vi.fn().mockResolvedValue(undefined);
const store = createMockStore({ updateGlobalSettings });
const { app } = createApp({ store, engine });
const activateRes = await REQUEST(app, "POST", "/api/remote/provider/activate", { provider: "tailscale" });
@@ -219,7 +219,7 @@ describe("remote access API route contracts", () => {
expect(engine.startRemoteTunnel.mock.calls.length).toBeLessThanOrEqual(1);
expect(engine.stopRemoteTunnel.mock.calls.length).toBeLessThanOrEqual(1);
expect(updateSettings).toHaveBeenCalledWith(expect.objectContaining({
expect(updateGlobalSettings).toHaveBeenCalledWith(expect.objectContaining({
remoteAccess: expect.objectContaining({ activeProvider: "tailscale" }),
}));
});