Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Stub confirm in #5498's disconnect test, since happy-dom has no window.confirm

milind-sonib1d7fbee136f
diff --git a/src/components/PluginsPanel.disconnect.test.ts b/src/components/PluginsPanel.disconnect.test.ts
index 8271507029..68cb90e376 100644
--- a/src/components/PluginsPanel.disconnect.test.ts
+++ b/src/components/PluginsPanel.disconnect.test.ts
@@ -64,6 +64,7 @@ beforeEach(() => {
vi.mocked(api).mockClear();
});
afterEach(async () => {
+ vi.unstubAllGlobals();
await act(async () => root.unmount());
host.remove();
document.body.querySelector("[role=alertdialog]")?.closest(".fixed")?.remove();
@@ -71,7 +72,8 @@ afterEach(async () => {
describe("disconnecting an app account", () => {
it("asks in the page, and removes only that account after the confirm button", async () => {
- const nativeConfirm = vi.spyOn(window, "confirm").mockReturnValue(true);
+ const nativeConfirm = vi.fn(() => true);
+ vi.stubGlobal("confirm", nativeConfirm);
await open();
await act(async () => { byLabel(tile(), "Disconnect work from Apollo")!.click(); });
expect(nativeConfirm).not.toHaveBeenCalled();
@@ -83,7 +85,6 @@ describe("disconnecting an app account", () => {
await flush();
expect(deletes()).toEqual([["/api/connectors/apollo/accounts/ca_old", { method: "DELETE" }]]);
expect(document.body.querySelector("[role=alertdialog]")).toBeNull();
- nativeConfirm.mockRestore();
});
it("leaves the account connected when the confirm is cancelled", async () => {