

























@@ -380,22 +380,22 @@ describe("node.pair.request", () => {
380380permissions: { camera: true },
381381}),
382382);
383-expect(broadcast.mock.calls[0]?.[0]).toBe("node.pair.resolved");
384-expect(broadcast.mock.calls[0]?.[1]).toEqual({
383+expect(broadcast.mock.calls.at(0)?.[0]).toBe("node.pair.resolved");
384+expect(broadcast.mock.calls.at(0)?.[1]).toEqual({
385385requestId: "req-old",
386386nodeId: "ios-node-1",
387387decision: "rejected",
388388ts: expect.any(Number),
389389});
390-expect(broadcast.mock.calls[1]?.[0]).toBe("node.pair.requested");
391-expect(broadcast.mock.calls[1]?.[1]).toEqual(
390+expect(broadcast.mock.calls.at(1)?.[0]).toBe("node.pair.requested");
391+expect(broadcast.mock.calls.at(1)?.[1]).toEqual(
392392expect.objectContaining({
393393requestId: "req-new",
394394nodeId: "ios-node-1",
395395permissions: { camera: true },
396396}),
397397);
398-expect(respond.mock.calls[0]?.[0]).toBe(true);
398+expect(respond.mock.calls.at(0)?.[0]).toBe(true);
399399});
400400});
401401@@ -426,7 +426,7 @@ describe("node plugin surface refresh", () => {
426426});
427427428428expect(respond).toHaveBeenCalledTimes(1);
429-const call = respond.mock.calls[0] as RespondCall | undefined;
429+const call = respond.mock.calls.at(0) as RespondCall | undefined;
430430expect(call?.[0]).toBe(true);
431431expect(call?.[2]).toBeUndefined();
432432const payload = requireRecord(call?.[1], "refresh payload");
@@ -482,7 +482,7 @@ describe("node.invoke APNs wake path", () => {
482482};
483483484484const respond = await invokeNode({ nodeRegistry });
485-const call = respond.mock.calls[0] as RespondCall | undefined;
485+const call = respond.mock.calls.at(0) as RespondCall | undefined;
486486expect(call?.[0]).toBe(false);
487487expect(call?.[2]?.code).toBe(ErrorCodes.UNAVAILABLE);
488488expect(call?.[2]?.message).toBe("node not connected");
@@ -591,11 +591,11 @@ describe("node.invoke APNs wake path", () => {
591591592592expect(mocks.sendApnsBackgroundWake).toHaveBeenCalledTimes(1);
593593expect(nodeRegistry.invoke).toHaveBeenCalledTimes(1);
594-expectRecordFields(nodeRegistry.invoke.mock.calls[0]?.[0], "node invoke payload", {
594+expectRecordFields(nodeRegistry.invoke.mock.calls.at(0)?.[0], "node invoke payload", {
595595nodeId: "ios-node-reconnect",
596596command: "camera.capture",
597597});
598-const call = respond.mock.calls[0] as RespondCall | undefined;
598+const call = respond.mock.calls.at(0) as RespondCall | undefined;
599599expect(call?.[0]).toBe(true);
600600expectRecordFields(call?.[1], "respond payload", { ok: true, nodeId: "ios-node-reconnect" });
601601});
@@ -635,12 +635,16 @@ describe("node.invoke APNs wake path", () => {
635635isWebchatConnect: () => false,
636636});
637637638-expect(respond.mock.calls[0]?.[0]).toBe(true);
639-expect(broadcast.mock.calls[0]?.[0]).toBe("talk.event");
640-const broadcastPayload = expectRecordFields(broadcast.mock.calls[0]?.[1], "broadcast payload", {
641-nodeId: "android-talk-node",
642-command: "talk.ptt.start",
643-});
638+expect(respond.mock.calls.at(0)?.[0]).toBe(true);
639+expect(broadcast.mock.calls.at(0)?.[0]).toBe("talk.event");
640+const broadcastPayload = expectRecordFields(
641+broadcast.mock.calls.at(0)?.[1],
642+"broadcast payload",
643+{
644+nodeId: "android-talk-node",
645+command: "talk.ptt.start",
646+},
647+);
644648const talkEvent = expectRecordFields(broadcastPayload.talkEvent, "talk event", {
645649type: "capture.started",
646650sessionId: "node:android-talk-node:talk:capture-1",
@@ -655,7 +659,7 @@ describe("node.invoke APNs wake path", () => {
655659nodeId: "android-talk-node",
656660command: "talk.ptt.start",
657661});
658-expect(broadcast.mock.calls[0]?.[2]).toEqual({ dropIfSlow: true });
662+expect(broadcast.mock.calls.at(0)?.[2]).toEqual({ dropIfSlow: true });
659663});
660664661665it("clears stale registrations after an invalid device token wake failure", async () => {
@@ -768,14 +772,14 @@ describe("node.invoke APNs wake path", () => {
768772idempotencyKey: "idem-queued",
769773},
770774});
771-const call = respond.mock.calls[0] as RespondCall | undefined;
775+const call = respond.mock.calls.at(0) as RespondCall | undefined;
772776expect(call?.[0]).toBe(false);
773777expect(call?.[2]?.code).toBe(ErrorCodes.UNAVAILABLE);
774778expect(call?.[2]?.message).toBe("node command queued until iOS returns to foreground");
775779expect(mocks.sendApnsBackgroundWake).not.toHaveBeenCalled();
776780777781const pullRespond = await pullPending("ios-node-queued", ["canvas.navigate"]);
778-const pullCall = pullRespond.mock.calls[0] as RespondCall | undefined;
782+const pullCall = pullRespond.mock.calls.at(0) as RespondCall | undefined;
779783const pullPayload = requireRespondPayload(pullCall, "pull response");
780784expectRecordFields(pullPayload, "pull payload", {
781785nodeId: "ios-node-queued",
@@ -786,7 +790,7 @@ describe("node.invoke APNs wake path", () => {
786790});
787791788792const repeatedPullRespond = await pullPending("ios-node-queued", ["canvas.navigate"]);
789-const repeatedPullCall = repeatedPullRespond.mock.calls[0] as RespondCall | undefined;
793+const repeatedPullCall = repeatedPullRespond.mock.calls.at(0) as RespondCall | undefined;
790794const repeatedPullPayload = requireRespondPayload(repeatedPullCall, "repeated pull response");
791795expectRecordFields(repeatedPullPayload, "repeated pull payload", {
792796nodeId: "ios-node-queued",
@@ -803,15 +807,15 @@ describe("node.invoke APNs wake path", () => {
803807expect(isUuidV4(queuedActionId)).toBe(true);
804808805809const ackRespond = await ackPending("ios-node-queued", [queuedActionId], ["canvas.navigate"]);
806-const ackCall = ackRespond.mock.calls[0] as RespondCall | undefined;
810+const ackCall = ackRespond.mock.calls.at(0) as RespondCall | undefined;
807811expectRecordFields(requireRespondPayload(ackCall, "ack response"), "ack payload", {
808812nodeId: "ios-node-queued",
809813ackedIds: [queuedActionId],
810814remainingCount: 0,
811815});
812816813817const emptyPullRespond = await pullPending("ios-node-queued", ["canvas.navigate"]);
814-const emptyPullCall = emptyPullRespond.mock.calls[0] as RespondCall | undefined;
818+const emptyPullCall = emptyPullRespond.mock.calls.at(0) as RespondCall | undefined;
815819expectRecordFields(
816820requireRespondPayload(emptyPullCall, "empty pull response"),
817821"empty pull payload",
@@ -867,7 +871,7 @@ describe("node.invoke APNs wake path", () => {
867871"camera.snap",
868872"canvas.navigate",
869873]);
870-const preChangePullCall = preChangePullRespond.mock.calls[0] as RespondCall | undefined;
874+const preChangePullCall = preChangePullRespond.mock.calls.at(0) as RespondCall | undefined;
871875const preChangePayload = requireRespondPayload(preChangePullCall, "pre-change pull response");
872876expectRecordFields(preChangePayload, "pre-change pull payload", {
873877nodeId: "ios-node-policy",
@@ -880,7 +884,7 @@ describe("node.invoke APNs wake path", () => {
880884allowlistedCommands.delete("camera.snap");
881885882886const pullRespond = await pullPending("ios-node-policy", ["camera.snap", "canvas.navigate"]);
883-const pullCall = pullRespond.mock.calls[0] as RespondCall | undefined;
887+const pullCall = pullRespond.mock.calls.at(0) as RespondCall | undefined;
884888expectRecordFields(requireRespondPayload(pullCall, "pull response"), "pull payload", {
885889nodeId: "ios-node-policy",
886890actions: [],
@@ -925,7 +929,7 @@ describe("node.invoke APNs wake path", () => {
925929});
926930927931const pullRespond = await pullPending("ios-node-dedupe", ["canvas.navigate"]);
928-const pullCall = pullRespond.mock.calls[0] as RespondCall | undefined;
932+const pullCall = pullRespond.mock.calls.at(0) as RespondCall | undefined;
929933const pullPayload = requireRespondPayload(pullCall, "pull response");
930934expectRecordFields(pullPayload, "pull payload", {
931935nodeId: "ios-node-dedupe",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。