


























@@ -153,7 +153,35 @@ function expectPendingUploadFields(uploadId: string): void {
153153}
154154155155function expectUploadUrlCall(url: string): void {
156-expect(fileConsentMockState.uploadToConsentUrl.mock.calls[0]?.[0]?.url).toBe(url);
156+const [call] = fileConsentMockState.uploadToConsentUrl.mock.calls;
157+if (!call) {
158+throw new Error("expected uploadToConsentUrl call");
159+}
160+const [payload] = call;
161+if (!payload || typeof payload !== "object" || !("url" in payload)) {
162+throw new Error("expected uploadToConsentUrl payload");
163+}
164+expect(payload.url).toBe(url);
165+}
166+167+function readUpdatedActivity(updateActivity: ReturnType<typeof vi.fn>): {
168+id?: unknown;
169+type?: unknown;
170+attachments?: Array<{ contentType?: unknown }>;
171+} {
172+const [call] = updateActivity.mock.calls;
173+if (!call) {
174+throw new Error("expected updateActivity call");
175+}
176+const [activity] = call;
177+if (!activity || typeof activity !== "object") {
178+throw new Error("expected updated activity payload");
179+}
180+return activity as {
181+id?: unknown;
182+type?: unknown;
183+attachments?: Array<{ contentType?: unknown }>;
184+};
157185}
158186159187describe("msteams file consent invoke authz", () => {
@@ -195,13 +223,11 @@ describe("msteams file consent invoke authz", () => {
195223196224// Should replace the original consent card with the file info card
197225expect(updateActivity).toHaveBeenCalledTimes(1);
198-const updatedActivity = updateActivity.mock.calls[0]?.[0] as
199-| { id?: unknown; type?: unknown; attachments?: Array<{ contentType?: unknown }> }
200-| undefined;
201-expect(updatedActivity?.id).toBe("consent-card-activity-id-123");
202-expect(updatedActivity?.type).toBe("message");
226+const updatedActivity = readUpdatedActivity(updateActivity);
227+expect(updatedActivity.id).toBe("consent-card-activity-id-123");
228+expect(updatedActivity.type).toBe("message");
203229expect(
204-updatedActivity?.attachments?.some(
230+updatedActivity.attachments?.some(
205231(attachment) => attachment.contentType === "application/vnd.microsoft.teams.card.file.info",
206232),
207233).toBe(true);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。