


























@@ -27,6 +27,18 @@ vi.mock("./token.js", () => ({
2727resolveMSTeamsCredentials: resolveMSTeamsCredentialsMock,
2828}));
292930+vi.mock("../runtime-api.js", async (importOriginal) => {
31+const original = await importOriginal<typeof import("../runtime-api.js")>();
32+return {
33+ ...original,
34+fetchWithSsrFGuard: async (params: { url: string; init?: RequestInit }) => ({
35+response: await globalThis.fetch(params.url, params.init),
36+finalUrl: params.url,
37+release: async () => undefined,
38+}),
39+};
40+});
41+3042import { searchGraphUsers } from "./graph-users.js";
3143import {
3244deleteGraphRequest,
@@ -121,6 +133,14 @@ function expectFetchPathContains(index: number, expectedPath: string) {
121133expect(fetchCallUrl(index)).toContain(expectedPath);
122134}
123135136+function fetchCallSearchParam(index: number, name: string): string | null {
137+const url = fetchCallUrl(index);
138+if (!url) {
139+throw new Error(`Expected fetch call ${index}`);
140+}
141+return new URL(url).searchParams.get(name);
142+}
143+124144async function expectSearchGraphUsers(
125145query: string,
126146expected: Array<Record<string, unknown>>,
@@ -305,10 +325,10 @@ describe("msteams graph helpers", () => {
305325deploymentsChannel,
306326]);
307327308-expectFetchPathContains(
309-0,
310-"/groups?$filter=resourceProvisioningOptions%2FAny(x%3Ax%20eq%20'Team')%20and%20startsWith(displayName%2C'Bob''s%20Team')&$select=id,displayName",
328+expect(fetchCallSearchParam(0, "$filter")).toBe(
329+"resourceProvisioningOptions/Any(x:x eq 'Team') and startsWith(displayName,'Bob''s Team')",
311330);
331+expect(fetchCallSearchParam(0, "$select")).toBe("id,displayName");
312332expectFetchPathContains(1, "/teams/team%2Fops/channels?$select=id,displayName");
313333});
314334@@ -324,10 +344,10 @@ describe("msteams graph helpers", () => {
324344await expectSearchGraphUsers("alice.o'hara@example.com", [userOne], {
325345token: "token-2",
326346});
327-expectFetchPathContains(
328-0,
329-"/users?$filter=(mail%20eq%20'alice.o''hara%40example.com'%20or%20userPrincipalName%20eq%20'alice.o''hara%40example.com')&$select=id,displayName,mail,userPrincipalName",
347+expect(fetchCallSearchParam(0, "$filter")).toBe(
348+"(mail eq 'alice.o''hara@example.com' or userPrincipalName eq 'alice.o''hara@example.com')",
330349);
350+expect(fetchCallSearchParam(0, "$select")).toBe("id,displayName,mail,userPrincipalName");
331351});
332352333353it("uses displayName search with eventual consistency and default top handling", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。