mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 18:03:44 +00:00
test(gateway): dedupe APNs wake fixture setup in node invoke tests
This commit is contained in:
@@ -95,6 +95,31 @@ async function invokeNode(params: {
|
|||||||
return respond;
|
return respond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mockSuccessfulWakeConfig(nodeId: string) {
|
||||||
|
mocks.loadApnsRegistration.mockResolvedValue({
|
||||||
|
nodeId,
|
||||||
|
token: "abcd1234abcd1234abcd1234abcd1234",
|
||||||
|
topic: "ai.openclaw.ios",
|
||||||
|
environment: "sandbox",
|
||||||
|
updatedAtMs: 1,
|
||||||
|
});
|
||||||
|
mocks.resolveApnsAuthConfigFromEnv.mockResolvedValue({
|
||||||
|
ok: true,
|
||||||
|
value: {
|
||||||
|
teamId: "TEAM123",
|
||||||
|
keyId: "KEY123",
|
||||||
|
privateKey: "-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
mocks.sendApnsBackgroundWake.mockResolvedValue({
|
||||||
|
ok: true,
|
||||||
|
status: 200,
|
||||||
|
tokenSuffix: "1234abcd",
|
||||||
|
topic: "ai.openclaw.ios",
|
||||||
|
environment: "sandbox",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe("node.invoke APNs wake path", () => {
|
describe("node.invoke APNs wake path", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mocks.loadConfig.mockReset();
|
mocks.loadConfig.mockReset();
|
||||||
@@ -135,28 +160,7 @@ describe("node.invoke APNs wake path", () => {
|
|||||||
|
|
||||||
it("wakes and retries invoke after the node reconnects", async () => {
|
it("wakes and retries invoke after the node reconnects", async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
mocks.loadApnsRegistration.mockResolvedValue({
|
mockSuccessfulWakeConfig("ios-node-reconnect");
|
||||||
nodeId: "ios-node-reconnect",
|
|
||||||
token: "abcd1234abcd1234abcd1234abcd1234",
|
|
||||||
topic: "ai.openclaw.ios",
|
|
||||||
environment: "sandbox",
|
|
||||||
updatedAtMs: 1,
|
|
||||||
});
|
|
||||||
mocks.resolveApnsAuthConfigFromEnv.mockResolvedValue({
|
|
||||||
ok: true,
|
|
||||||
value: {
|
|
||||||
teamId: "TEAM123",
|
|
||||||
keyId: "KEY123",
|
|
||||||
privateKey: "-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
mocks.sendApnsBackgroundWake.mockResolvedValue({
|
|
||||||
ok: true,
|
|
||||||
status: 200,
|
|
||||||
tokenSuffix: "1234abcd",
|
|
||||||
topic: "ai.openclaw.ios",
|
|
||||||
environment: "sandbox",
|
|
||||||
});
|
|
||||||
|
|
||||||
let connected = false;
|
let connected = false;
|
||||||
const session: TestNodeSession = { nodeId: "ios-node-reconnect", commands: ["camera.capture"] };
|
const session: TestNodeSession = { nodeId: "ios-node-reconnect", commands: ["camera.capture"] };
|
||||||
@@ -200,28 +204,7 @@ describe("node.invoke APNs wake path", () => {
|
|||||||
|
|
||||||
it("throttles repeated wake attempts for the same disconnected node", async () => {
|
it("throttles repeated wake attempts for the same disconnected node", async () => {
|
||||||
vi.useFakeTimers();
|
vi.useFakeTimers();
|
||||||
mocks.loadApnsRegistration.mockResolvedValue({
|
mockSuccessfulWakeConfig("ios-node-throttle");
|
||||||
nodeId: "ios-node-throttle",
|
|
||||||
token: "abcd1234abcd1234abcd1234abcd1234",
|
|
||||||
topic: "ai.openclaw.ios",
|
|
||||||
environment: "sandbox",
|
|
||||||
updatedAtMs: 1,
|
|
||||||
});
|
|
||||||
mocks.resolveApnsAuthConfigFromEnv.mockResolvedValue({
|
|
||||||
ok: true,
|
|
||||||
value: {
|
|
||||||
teamId: "TEAM123",
|
|
||||||
keyId: "KEY123",
|
|
||||||
privateKey: "-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
mocks.sendApnsBackgroundWake.mockResolvedValue({
|
|
||||||
ok: true,
|
|
||||||
status: 200,
|
|
||||||
tokenSuffix: "1234abcd",
|
|
||||||
topic: "ai.openclaw.ios",
|
|
||||||
environment: "sandbox",
|
|
||||||
});
|
|
||||||
|
|
||||||
const nodeRegistry = {
|
const nodeRegistry = {
|
||||||
get: vi.fn(() => undefined),
|
get: vi.fn(() => undefined),
|
||||||
|
|||||||
Reference in New Issue
Block a user