Elffuss BraidHub

kikocis/continue public

fix: address feedback
Changeset60acd6c5ca132bab7f1de25f8789fa5f7d0eb2d2c9ccb06080b79c76ebcd173f
AuthorNate <sestinj@gmail.com> · 2025-08-24 18:51 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-24 18:51 -07:00
Parentsc4ec337463d8

Browse the files at this changeset

4 files changed

modified extensions/cli/src/auth/workos-org.test.ts +8 −3
@@ -13,6 +13,10 @@
1313 })),
1414 }));
1515
16+vi.mock("../init.js", () => ({
17+ safeStderr: vi.fn(),
18+}));
19+
1620 vi.mock("fs", () => ({
1721 default: {
1822 existsSync: vi.fn(() => false),
@@ -91,7 +95,8 @@
9195
9296 describe("Mode restriction", () => {
9397 test("should reject --org flag in interactive mode", async () => {
94- const consoleErrorSpy = vi.spyOn(console, "error");
98+ const { safeStderr } = await import("../init.js");
99+ const safeStderrSpy = vi.mocked(safeStderr);
95100 const processExitSpy = vi
96101 .spyOn(process, "exit")
97102 .mockImplementation(() => {
@@ -102,9 +107,9 @@
102107 ensureOrganization(mockAuthConfig, false, "org-one"),
103108 ).rejects.toThrow("Process exit");
104109
105- expect(consoleErrorSpy).toHaveBeenCalledWith(
110+ expect(safeStderrSpy).toHaveBeenCalledWith(
106111 chalk.red(
107- "The --org flag is only supported in headless mode (with -p/--print flag)",
112+ "The --org flag is only supported in headless mode (with -p/--print flag)\n",
108113 ),
109114 );
110115 expect(processExitSpy).toHaveBeenCalledWith(1);
modified extensions/cli/src/hubLoader.test.ts +0 −2
@@ -71,7 +71,6 @@
7171 }));
7272 } else {
7373 // If mock doesn't work, skip this test
74- console.log("JSZip mock not working, skipping test");
7574 return;
7675 }
7776
@@ -121,7 +120,6 @@
121120 }));
122121 } else {
123122 // If mock doesn't work, skip this test
124- console.log("JSZip mock not working, skipping test");
125123 return;
126124 }
127125
modified extensions/cli/src/hubLoader.ts +4 −2
@@ -231,9 +231,11 @@
231231
232232 // If it looks like a file path
233233 if (
234- ruleSpec.includes(".") ||
234+ ruleSpec.startsWith(".") ||
235+ ruleSpec.startsWith("/") ||
235236 ruleSpec.includes("/") ||
236- ruleSpec.includes("\\")
237+ ruleSpec.includes("\\") ||
238+ /\.[a-zA-Z]+$/.test(ruleSpec) // Has file extension at the end
237239 ) {
238240 const fs = await import("fs");
239241 const path = await import("path");
modified extensions/cli/src/loadMcpFromHub.test.ts +10 −3
@@ -1,10 +1,10 @@
1-import { beforeEach, describe, expect, it, vi } from "vitest";
1+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22
33 import { loadMcpFromHub } from "./args.js";
44
5-// Mock fetch globally
5+// Store original fetch to restore later
6+const originalFetch = global.fetch;
67 const mockFetch = vi.fn();
7-global.fetch = mockFetch;
88
99 // Mock JSZip
1010 vi.mock("jszip", () => {
@@ -18,12 +18,19 @@
1818
1919 beforeEach(async () => {
2020 vi.clearAllMocks();
21+ // Set mock fetch for each test
22+ global.fetch = mockFetch;
2123
2224 // Get the mocked JSZip constructor
2325 const JSZip = (await import("jszip")).default;
2426 mockJSZip = new JSZip();
2527 });
2628
29+ afterEach(() => {
30+ // Restore original fetch after each test
31+ global.fetch = originalFetch;
32+ });
33+
2734 it("should validate slug format", async () => {
2835 await expect(loadMcpFromHub("invalid-slug")).rejects.toThrow(
2936 'Invalid hub slug format. Expected "owner/package", got: invalid-slug',