perf: run ui node tests without jsdom

This commit is contained in:
Peter Steinberger
2026-04-23 20:17:16 +01:00
parent b957493ef7
commit f2f475e869
19 changed files with 29 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
import { GATEWAY_EVENT_UPDATE_AVAILABLE } from "../../../src/gateway/events.js";
import { ConnectErrorDetailCodes } from "../../../src/gateway/protocol/connect-error-details.js";
@@ -206,6 +207,9 @@ describe("connectGateway", () => {
gatewayClientInstances.length = 0;
loadChatHistoryMock.mockClear();
loadControlUiBootstrapConfigMock.mockClear();
vi.stubGlobal("window", {
setTimeout: globalThis.setTimeout,
});
});
it("ignores stale client onGap callbacks after reconnect", () => {

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it, vi } from "vitest";
const loadSessionsMock = vi.fn();

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
const { applySettingsFromUrlMock, connectGatewayMock, loadBootstrapMock } = vi.hoisted(() => ({
@@ -70,6 +71,9 @@ describe("handleConnected", () => {
applySettingsFromUrlMock.mockReset();
connectGatewayMock.mockReset();
loadBootstrapMock.mockReset();
vi.stubGlobal("window", {
addEventListener: vi.fn(),
});
});
it("waits for bootstrap load before first gateway connect", async () => {

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it, vi } from "vitest";
import { handleDisconnected } from "./app-lifecycle.ts";
@@ -28,6 +29,9 @@ function createHost() {
describe("handleDisconnected", () => {
it("stops and clears gateway client on teardown", () => {
vi.stubGlobal("window", {
removeEventListener: vi.fn(),
});
const removeSpy = vi.spyOn(window, "removeEventListener").mockImplementation(() => undefined);
const host = createHost();
const disconnectSpy = (
@@ -43,5 +47,6 @@ describe("handleDisconnected", () => {
expect(disconnectSpy).toHaveBeenCalledTimes(1);
expect(host.topbarObserver).toBeNull();
removeSpy.mockRestore();
vi.unstubAllGlobals();
});
});

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it, vi } from "vitest";
const {
refreshChatMock,

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { beforeEach, describe, expect, it, vi } from "vitest";
const mocks = vi.hoisted(() => ({

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { beforeAll, describe, expect, it, vi } from "vitest";
import { handleAgentEvent, type FallbackStatus, type ToolStreamEntry } from "./app-tool-stream.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { buildChatMarkdown } from "./export.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it, vi } from "vitest";
import {
createResolvedModelPatch,

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { afterEach, describe, expect, it, vi } from "vitest";
import {
parseSlashCommand,

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { formatConnectError } from "./connect-error.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import type { JsonSchema } from "../../views/config-form.shared.ts";
import { coerceFormValues } from "./form-coerce.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
__test,

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createStorageMock } from "../test-helpers/storage.ts";
import { loadDeviceAuthToken, storeDeviceAuthToken } from "./device-auth.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createStorageMock } from "../test-helpers/storage.ts";
import {

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { extractQueryTerms, filterSessionsByQuery, parseToolSummary } from "./usage-helpers.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { matchesNodeSearch, parseConfigSearchQuery } from "./config-form.node.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { draftToCronFormPatch, type CronQuickCreateDraft } from "./cron-quick-create.ts";

View File

@@ -1,3 +1,4 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { ConnectErrorDetailCodes } from "../../../../src/gateway/protocol/connect-error-details.js";
import {