refactor(ui): route query-building networking calls through apiClient (#29815)

This commit is contained in:
ryan-crabbe-berri 2026-06-06 09:18:44 -07:00 committed by GitHub
parent 1f171ee018
commit 001bda37d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 136 additions and 736 deletions

View File

@ -1504,7 +1504,7 @@
"count": 23
},
"no-restricted-syntax": {
"count": 175
"count": 154
}
},
"src/components/object_permissions_view.tsx": {

View File

@ -419,7 +419,7 @@ describe("teamInfoCall", () => {
it("should URL-encode team_id query param to handle special characters safely", async () => {
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: vi.fn().mockResolvedValue({ team_id: "team with spaces & special?chars" }),
text: vi.fn().mockResolvedValue(JSON.stringify({ team_id: "team with spaces & special?chars" })),
} as any);
global.fetch = mockFetch as any;
@ -432,16 +432,15 @@ describe("teamInfoCall", () => {
const parsed = typeof url === "string" ? new URL(url, "http://example.com") : new URL((url as Request).url);
expect(urlStr).toContain("/team/info");
// Encoded value is present in the raw URL string (verifies encodeURIComponent was used)
expect(urlStr).toContain(`team_id=${encodeURIComponent(teamID)}`);
// Round-trip parse returns the original team_id
// Special characters are encoded (not present raw) and round-trip back to the original
expect(urlStr).not.toContain("team with spaces");
expect(parsed.searchParams.get("team_id")).toBe(teamID);
});
it("should not append team_id when teamID is null", async () => {
const mockFetch = vi.fn().mockResolvedValue({
ok: true,
json: vi.fn().mockResolvedValue({}),
text: vi.fn().mockResolvedValue("{}"),
} as any);
global.fetch = mockFetch as any;

File diff suppressed because it is too large Load Diff