mirror of https://github.com/openclaw/openclaw.git
test: share wake failure assertions
This commit is contained in:
parent
fd58268f04
commit
0229246f3b
|
|
@ -52,6 +52,24 @@ type RespondCall = [
|
|||
}?,
|
||||
];
|
||||
|
||||
function expectNodeNotConnected(respond: ReturnType<typeof vi.fn>) {
|
||||
const call = respond.mock.calls[0] as RespondCall | undefined;
|
||||
expect(call?.[0]).toBe(false);
|
||||
expect(call?.[2]?.message).toBe("node not connected");
|
||||
}
|
||||
|
||||
async function invokeDisconnectedNode(nodeId: string, idempotencyKey: string) {
|
||||
const nodeRegistry = {
|
||||
get: vi.fn(() => undefined),
|
||||
invoke: vi.fn().mockResolvedValue({ ok: true }),
|
||||
};
|
||||
|
||||
return await invokeNode({
|
||||
nodeRegistry,
|
||||
requestParams: { nodeId, idempotencyKey },
|
||||
});
|
||||
}
|
||||
|
||||
type TestNodeSession = {
|
||||
nodeId: string;
|
||||
commands: string[];
|
||||
|
|
@ -357,20 +375,9 @@ describe("node.invoke APNs wake path", () => {
|
|||
reason: "BadDeviceToken",
|
||||
});
|
||||
mocks.shouldClearStoredApnsRegistration.mockReturnValue(true);
|
||||
const respond = await invokeDisconnectedNode("ios-node-stale", "idem-stale");
|
||||
|
||||
const nodeRegistry = {
|
||||
get: vi.fn(() => undefined),
|
||||
invoke: vi.fn().mockResolvedValue({ ok: true }),
|
||||
};
|
||||
|
||||
const respond = await invokeNode({
|
||||
nodeRegistry,
|
||||
requestParams: { nodeId: "ios-node-stale", idempotencyKey: "idem-stale" },
|
||||
});
|
||||
|
||||
const call = respond.mock.calls[0] as RespondCall | undefined;
|
||||
expect(call?.[0]).toBe(false);
|
||||
expect(call?.[2]?.message).toBe("node not connected");
|
||||
expectNodeNotConnected(respond);
|
||||
expect(mocks.clearApnsRegistrationIfCurrent).toHaveBeenCalledWith({
|
||||
nodeId: "ios-node-stale",
|
||||
registration,
|
||||
|
|
@ -385,20 +392,9 @@ describe("node.invoke APNs wake path", () => {
|
|||
reason: "Unregistered",
|
||||
});
|
||||
mocks.shouldClearStoredApnsRegistration.mockReturnValue(false);
|
||||
const respond = await invokeDisconnectedNode("ios-node-relay", "idem-relay");
|
||||
|
||||
const nodeRegistry = {
|
||||
get: vi.fn(() => undefined),
|
||||
invoke: vi.fn().mockResolvedValue({ ok: true }),
|
||||
};
|
||||
|
||||
const respond = await invokeNode({
|
||||
nodeRegistry,
|
||||
requestParams: { nodeId: "ios-node-relay", idempotencyKey: "idem-relay" },
|
||||
});
|
||||
|
||||
const call = respond.mock.calls[0] as RespondCall | undefined;
|
||||
expect(call?.[0]).toBe(false);
|
||||
expect(call?.[2]?.message).toBe("node not connected");
|
||||
expectNodeNotConnected(respond);
|
||||
expect(mocks.resolveApnsRelayConfigFromEnv).toHaveBeenCalledWith(process.env, {
|
||||
push: {
|
||||
apns: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue