perf: run ui node tests without jsdom · openclaw/openclaw@f2f475e
steipete
·
2026-04-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { GATEWAY_EVENT_UPDATE_AVAILABLE } from "../../../src/gateway/events.js"; |
3 | 4 | import { ConnectErrorDetailCodes } from "../../../src/gateway/protocol/connect-error-details.js"; |
@@ -206,6 +207,9 @@ describe("connectGateway", () => {
|
206 | 207 | gatewayClientInstances.length = 0; |
207 | 208 | loadChatHistoryMock.mockClear(); |
208 | 209 | loadControlUiBootstrapConfigMock.mockClear(); |
| 210 | +vi.stubGlobal("window", { |
| 211 | +setTimeout: globalThis.setTimeout, |
| 212 | +}); |
209 | 213 | }); |
210 | 214 | |
211 | 215 | it("ignores stale client onGap callbacks after reconnect", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { describe, expect, it, vi } from "vitest"; |
2 | 3 | |
3 | 4 | const loadSessionsMock = vi.fn(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | |
3 | 4 | const { applySettingsFromUrlMock, connectGatewayMock, loadBootstrapMock } = vi.hoisted(() => ({ |
@@ -70,6 +71,9 @@ describe("handleConnected", () => {
|
70 | 71 | applySettingsFromUrlMock.mockReset(); |
71 | 72 | connectGatewayMock.mockReset(); |
72 | 73 | loadBootstrapMock.mockReset(); |
| 74 | +vi.stubGlobal("window", { |
| 75 | +addEventListener: vi.fn(), |
| 76 | +}); |
73 | 77 | }); |
74 | 78 | |
75 | 79 | it("waits for bootstrap load before first gateway connect", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { describe, expect, it, vi } from "vitest"; |
2 | 3 | import { handleDisconnected } from "./app-lifecycle.ts"; |
3 | 4 | |
@@ -28,6 +29,9 @@ function createHost() {
|
28 | 29 | |
29 | 30 | describe("handleDisconnected", () => { |
30 | 31 | it("stops and clears gateway client on teardown", () => { |
| 32 | +vi.stubGlobal("window", { |
| 33 | +removeEventListener: vi.fn(), |
| 34 | +}); |
31 | 35 | const removeSpy = vi.spyOn(window, "removeEventListener").mockImplementation(() => undefined); |
32 | 36 | const host = createHost(); |
33 | 37 | const disconnectSpy = ( |
@@ -43,5 +47,6 @@ describe("handleDisconnected", () => {
|
43 | 47 | expect(disconnectSpy).toHaveBeenCalledTimes(1); |
44 | 48 | expect(host.topbarObserver).toBeNull(); |
45 | 49 | removeSpy.mockRestore(); |
| 50 | +vi.unstubAllGlobals(); |
46 | 51 | }); |
47 | 52 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { describe, expect, it, vi } from "vitest"; |
2 | 3 | const { |
3 | 4 | refreshChatMock, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | |
3 | 4 | const mocks = vi.hoisted(() => ({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { beforeAll, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { handleAgentEvent, type FallbackStatus, type ToolStreamEntry } from "./app-tool-stream.ts"; |
3 | 4 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import { buildChatMarkdown } from "./export.ts"; |
3 | 4 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | createResolvedModelPatch, |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// @vitest-environment node |
1 | 2 | import { afterEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | parseSlashCommand, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。