test(auth): cover completion machine affinity

Verify that an auth flow's terminal status refresh remains targeted at the flow's originating machine after the selected machine changes.\n\nRefs #74
This commit is contained in:
Federico Jaramillo Martinez
2026-07-18 21:18:53 +02:00
parent 62396c3165
commit 55cc1b7a3b
@@ -121,7 +121,11 @@ describe("AuthController", () => {
const statusCalls: { session: Parameters<typeof defaultApi.status>[0]; machineId: string | undefined }[] = []; const statusCalls: { session: Parameters<typeof defaultApi.status>[0]; machineId: string | undefined }[] = [];
const appliedStatuses: SessionStatus[] = []; const appliedStatuses: SessionStatus[] = [];
const { controller, getState } = createController( const { controller, getState } = createController(
{ selectedSession: session, authDialog: { step: "oauth", flow, machineId: "local", inputValue: "https://callback" } }, {
selectedMachine: remoteMachine("remote-2"),
selectedSession: session,
authDialog: { step: "oauth", flow, machineId: "remote-1", inputValue: "https://callback" },
},
{ {
respondOAuthFlow: (flowId, requestId, value, machineId) => { respondOAuthFlow: (flowId, requestId, value, machineId) => {
respondCalls.push({ flowId, requestId, value, machineId }); respondCalls.push({ flowId, requestId, value, machineId });
@@ -138,9 +142,9 @@ describe("AuthController", () => {
await controller.respondOAuth(); await controller.respondOAuth();
await flushMicrotasks(); await flushMicrotasks();
expect(respondCalls).toEqual([{ flowId: "flow-1", requestId: "request-1", value: "https://callback", machineId: "local" }]); expect(respondCalls).toEqual([{ flowId: "flow-1", requestId: "request-1", value: "https://callback", machineId: "remote-1" }]);
expect(getState().authDialog).toBeUndefined(); expect(getState().authDialog).toBeUndefined();
expect(statusCalls).toEqual([{ session, machineId: "local" }]); expect(statusCalls).toEqual([{ session, machineId: "remote-1" }]);
expect(appliedStatuses).toEqual([refreshedStatus]); expect(appliedStatuses).toEqual([refreshedStatus]);
}); });