test(gateway): avoid hoisted export errors
This commit is contained in:
@@ -40,39 +40,41 @@ export type BridgeStartOpts = {
|
|||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const bridgeStartCalls = vi.hoisted(() => [] as BridgeStartOpts[]);
|
const hoisted = vi.hoisted(() => ({
|
||||||
export const bridgeInvoke = vi.hoisted(() =>
|
bridgeStartCalls: [] as BridgeStartOpts[],
|
||||||
vi.fn(async () => ({
|
bridgeInvoke: vi.fn(async () => ({
|
||||||
type: "invoke-res",
|
type: "invoke-res",
|
||||||
id: "1",
|
id: "1",
|
||||||
ok: true,
|
ok: true,
|
||||||
payloadJSON: JSON.stringify({ ok: true }),
|
payloadJSON: JSON.stringify({ ok: true }),
|
||||||
error: null,
|
error: null,
|
||||||
})),
|
})),
|
||||||
);
|
bridgeListConnected: vi.fn(() => [] as BridgeClientInfo[]),
|
||||||
export const bridgeListConnected = vi.hoisted(() =>
|
bridgeSendEvent: vi.fn(),
|
||||||
vi.fn(() => [] as BridgeClientInfo[]),
|
testTailnetIPv4: { value: undefined as string | undefined },
|
||||||
);
|
piSdkMock: {
|
||||||
export const bridgeSendEvent = vi.hoisted(() => vi.fn());
|
enabled: false,
|
||||||
export const testTailnetIPv4 = vi.hoisted(() => ({
|
discoverCalls: 0,
|
||||||
value: undefined as string | undefined,
|
models: [] as Array<{
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
provider: string;
|
||||||
|
contextWindow?: number;
|
||||||
|
reasoning?: boolean;
|
||||||
|
}>,
|
||||||
|
},
|
||||||
|
cronIsolatedRun: vi.fn(async () => ({ status: "ok", summary: "ok" })),
|
||||||
|
testIsNixMode: { value: false },
|
||||||
|
sessionStoreSaveDelayMs: { value: 0 },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const piSdkMock = vi.hoisted(() => ({
|
export const bridgeStartCalls = hoisted.bridgeStartCalls;
|
||||||
enabled: false,
|
export const bridgeInvoke = hoisted.bridgeInvoke;
|
||||||
discoverCalls: 0,
|
export const bridgeListConnected = hoisted.bridgeListConnected;
|
||||||
models: [] as Array<{
|
export const bridgeSendEvent = hoisted.bridgeSendEvent;
|
||||||
id: string;
|
export const testTailnetIPv4 = hoisted.testTailnetIPv4;
|
||||||
name?: string;
|
export const piSdkMock = hoisted.piSdkMock;
|
||||||
provider: string;
|
export const cronIsolatedRun = hoisted.cronIsolatedRun;
|
||||||
contextWindow?: number;
|
|
||||||
reasoning?: boolean;
|
|
||||||
}>,
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const cronIsolatedRun = vi.hoisted(() =>
|
|
||||||
vi.fn(async () => ({ status: "ok", summary: "ok" })),
|
|
||||||
);
|
|
||||||
|
|
||||||
export const testState = {
|
export const testState = {
|
||||||
sessionStorePath: undefined as string | undefined,
|
sessionStorePath: undefined as string | undefined,
|
||||||
@@ -89,8 +91,8 @@ export const testState = {
|
|||||||
migrationChanges: [] as string[],
|
migrationChanges: [] as string[],
|
||||||
};
|
};
|
||||||
|
|
||||||
export const testIsNixMode = vi.hoisted(() => ({ value: false }));
|
export const testIsNixMode = hoisted.testIsNixMode;
|
||||||
export const sessionStoreSaveDelayMs = vi.hoisted(() => ({ value: 0 }));
|
export const sessionStoreSaveDelayMs = hoisted.sessionStoreSaveDelayMs;
|
||||||
|
|
||||||
vi.mock("@mariozechner/pi-coding-agent", async () => {
|
vi.mock("@mariozechner/pi-coding-agent", async () => {
|
||||||
const actual = await vi.importActual<
|
const actual = await vi.importActual<
|
||||||
|
|||||||
Reference in New Issue
Block a user