chore: upgrade vitest (#1091)
* chore: upgrade vitest * chore: sync lock
This commit is contained in:
@@ -16,7 +16,7 @@ Replace the OpenCode provider's per-directory `/event` stream with OpenCode's `/
|
|||||||
Each OpenCode test file was run independently with:
|
Each OpenCode test file was run independently with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
/opt/homebrew/bin/timeout 420s npx vitest run <file> --maxWorkers=1 --minWorkers=1
|
/opt/homebrew/bin/timeout 420s npx vitest run <file> --maxWorkers=1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Baseline
|
## Baseline
|
||||||
@@ -44,6 +44,6 @@ One live reasoning-dedup matrix run returned no reasoning content; an immediate
|
|||||||
- `npm run typecheck`
|
- `npm run typecheck`
|
||||||
- `npm run lint`
|
- `npm run lint`
|
||||||
- `git diff --check`
|
- `git diff --check`
|
||||||
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.test.ts --maxWorkers=1 --minWorkers=1`
|
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.test.ts --maxWorkers=1`
|
||||||
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.error-handling.real.e2e.test.ts --maxWorkers=1 --minWorkers=1`
|
- `npx vitest run packages/server/src/server/agent/providers/opencode-agent.error-handling.real.e2e.test.ts --maxWorkers=1`
|
||||||
- `npx vitest run packages/server/src/server/daemon-e2e/opencode-initial-prompt-wait.real.e2e.test.ts --maxWorkers=1 --minWorkers=1`
|
- `npx vitest run packages/server/src/server/daemon-e2e/opencode-initial-prompt-wait.real.e2e.test.ts --maxWorkers=1`
|
||||||
|
|||||||
Generated
+1759
-274
File diff suppressed because it is too large
Load Diff
@@ -105,7 +105,8 @@
|
|||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@types/react": "~19.2.0",
|
"@types/react": "~19.2.0",
|
||||||
"@types/ws": "^8.18.1",
|
"@types/ws": "^8.18.1",
|
||||||
"@vitest/browser": "^3.2.4",
|
"@vitest/browser": "^4.1.7",
|
||||||
|
"@vitest/browser-playwright": "^4.1.7",
|
||||||
"@xterm/headless": "^6.0.0",
|
"@xterm/headless": "^6.0.0",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"eas-cli": "^16.24.1",
|
"eas-cli": "^16.24.1",
|
||||||
@@ -115,7 +116,7 @@
|
|||||||
"material-icon-theme": "^5.32.0",
|
"material-icon-theme": "^5.32.0",
|
||||||
"playwright": "^1.56.1",
|
"playwright": "^1.56.1",
|
||||||
"typescript": "~5.9.2",
|
"typescript": "~5.9.2",
|
||||||
"vitest": "^3.2.4",
|
"vitest": "^4.1.6",
|
||||||
"wrangler": "^4.75.0",
|
"wrangler": "^4.75.0",
|
||||||
"ws": "^8.20.0"
|
"ws": "^8.20.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
type AssistantFileLinkContext,
|
type AssistantFileLinkContext,
|
||||||
type DirectorySuggestionEntry,
|
type DirectorySuggestionEntry,
|
||||||
type DirectorySuggestionResult,
|
type DirectorySuggestionResult,
|
||||||
|
type GetDirectorySuggestions,
|
||||||
} from "./resolver";
|
} from "./resolver";
|
||||||
|
|
||||||
const CONTEXT: AssistantFileLinkContext = {
|
const CONTEXT: AssistantFileLinkContext = {
|
||||||
@@ -20,7 +21,7 @@ function resolvedSuggestions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function suggestionsFromMap(entriesByQuery: Record<string, DirectorySuggestionEntry[]>): {
|
function suggestionsFromMap(entriesByQuery: Record<string, DirectorySuggestionEntry[]>): {
|
||||||
getDirectorySuggestions: ReturnType<typeof vi.fn>;
|
getDirectorySuggestions: GetDirectorySuggestions;
|
||||||
searches: Array<{
|
searches: Array<{
|
||||||
query: string;
|
query: string;
|
||||||
cwd: string;
|
cwd: string;
|
||||||
@@ -34,7 +35,7 @@ function suggestionsFromMap(entriesByQuery: Record<string, DirectorySuggestionEn
|
|||||||
matchMode: "suffix";
|
matchMode: "suffix";
|
||||||
limit: number;
|
limit: number;
|
||||||
}> = [];
|
}> = [];
|
||||||
const getDirectorySuggestions = vi.fn(
|
const getDirectorySuggestions = vi.fn<GetDirectorySuggestions>(
|
||||||
async (input: {
|
async (input: {
|
||||||
query: string;
|
query: string;
|
||||||
cwd: string;
|
cwd: string;
|
||||||
@@ -192,7 +193,7 @@ describe("fetchDaemonResolution", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws a typed unresolved error when the daemon throws", async () => {
|
it("throws a typed unresolved error when the daemon throws", async () => {
|
||||||
const getDirectorySuggestions = vi.fn(async () => {
|
const getDirectorySuggestions = vi.fn<GetDirectorySuggestions>(async () => {
|
||||||
throw new Error("daemon unavailable");
|
throw new Error("daemon unavailable");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|||||||
import { act, renderHook, waitFor } from "@testing-library/react";
|
import { act, renderHook, waitFor } from "@testing-library/react";
|
||||||
import React, { useCallback, useMemo, useState, type ReactNode } from "react";
|
import React, { useCallback, useMemo, useState, type ReactNode } from "react";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import type { ToastApi } from "@/components/toast-host";
|
||||||
import type { InlinePathTarget } from "./parse";
|
import type { InlinePathTarget } from "./parse";
|
||||||
import { AssistantFileLinkResolverProvider } from "./provider";
|
import { AssistantFileLinkResolverProvider } from "./provider";
|
||||||
import type { DirectorySuggestionResult } from "./resolver";
|
import type { DirectorySuggestionResult } from "./resolver";
|
||||||
@@ -63,15 +64,15 @@ function createQueryClient(): QueryClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWrapper(input: {
|
function createToast(): ToastApi {
|
||||||
client: TestClient;
|
return {
|
||||||
openedFiles: OpenedFile[];
|
show: vi.fn<ToastApi["show"]>(),
|
||||||
toast?: {
|
copied: vi.fn<ToastApi["copied"]>(),
|
||||||
show: ReturnType<typeof vi.fn>;
|
error: vi.fn<ToastApi["error"]>(),
|
||||||
copied: ReturnType<typeof vi.fn>;
|
|
||||||
error: ReturnType<typeof vi.fn>;
|
|
||||||
};
|
};
|
||||||
}) {
|
}
|
||||||
|
|
||||||
|
function createWrapper(input: { client: TestClient; openedFiles: OpenedFile[]; toast?: ToastApi }) {
|
||||||
const queryClient = createQueryClient();
|
const queryClient = createQueryClient();
|
||||||
return function Wrapper({ children }: { children: ReactNode }) {
|
return function Wrapper({ children }: { children: ReactNode }) {
|
||||||
const openWorkspaceFile = useCallback(
|
const openWorkspaceFile = useCallback(
|
||||||
@@ -118,7 +119,7 @@ describe("useFileLink", () => {
|
|||||||
serverId: "server-1",
|
serverId: "server-1",
|
||||||
workspaceRoot: "/Users/test/project",
|
workspaceRoot: "/Users/test/project",
|
||||||
onOpenWorkspaceFile: () => {},
|
onOpenWorkspaceFile: () => {},
|
||||||
toast: { show: vi.fn(), copied: vi.fn(), error: vi.fn() },
|
toast: createToast(),
|
||||||
},
|
},
|
||||||
children,
|
children,
|
||||||
),
|
),
|
||||||
@@ -145,7 +146,7 @@ describe("useFileLink", () => {
|
|||||||
.mockResolvedValueOnce(resolvedSuggestions([]))
|
.mockResolvedValueOnce(resolvedSuggestions([]))
|
||||||
.mockResolvedValueOnce(resolvedSuggestions([{ path: "docs/dumm.md", kind: "file" }]));
|
.mockResolvedValueOnce(resolvedSuggestions([{ path: "docs/dumm.md", kind: "file" }]));
|
||||||
const openedFiles: OpenedFile[] = [];
|
const openedFiles: OpenedFile[] = [];
|
||||||
const toast = { show: vi.fn(), copied: vi.fn(), error: vi.fn() };
|
const toast = createToast();
|
||||||
const { result } = renderHook(() => useFileLink(SOURCE), {
|
const { result } = renderHook(() => useFileLink(SOURCE), {
|
||||||
wrapper: createWrapper({
|
wrapper: createWrapper({
|
||||||
client: { getDirectorySuggestions },
|
client: { getDirectorySuggestions },
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { act, renderHook, waitFor } from "@testing-library/react";
|
import { act, renderHook, waitFor } from "@testing-library/react";
|
||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import type { ToastApi } from "@/components/toast-host";
|
||||||
import { useSessionStore } from "@/stores/session-store";
|
import { useSessionStore } from "@/stores/session-store";
|
||||||
import { TIMELINE_FETCH_PAGE_SIZE } from "@/timeline/timeline-fetch-policy";
|
import { TIMELINE_FETCH_PAGE_SIZE } from "@/timeline/timeline-fetch-policy";
|
||||||
import { useLoadOlderAgentHistory } from "./use-load-older-agent-history";
|
import { useLoadOlderAgentHistory } from "./use-load-older-agent-history";
|
||||||
@@ -9,7 +10,19 @@ import { useLoadOlderAgentHistory } from "./use-load-older-agent-history";
|
|||||||
const serverId = "server-1";
|
const serverId = "server-1";
|
||||||
const agentId = "agent-1";
|
const agentId = "agent-1";
|
||||||
|
|
||||||
function makeClient(fetchAgentTimeline = vi.fn().mockResolvedValue(undefined)) {
|
type FetchAgentTimeline = (agentId: string, request: unknown) => Promise<void>;
|
||||||
|
|
||||||
|
function createToast(): ToastApi {
|
||||||
|
return {
|
||||||
|
show: vi.fn<ToastApi["show"]>(),
|
||||||
|
copied: vi.fn<ToastApi["copied"]>(),
|
||||||
|
error: vi.fn<ToastApi["error"]>(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeClient(
|
||||||
|
fetchAgentTimeline: FetchAgentTimeline = vi.fn<FetchAgentTimeline>().mockResolvedValue(undefined),
|
||||||
|
) {
|
||||||
return { fetchAgentTimeline };
|
return { fetchAgentTimeline };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +30,7 @@ function initialize(input?: {
|
|||||||
cursor?: { epoch: string; startSeq: number; endSeq: number };
|
cursor?: { epoch: string; startSeq: number; endSeq: number };
|
||||||
hasOlder?: boolean;
|
hasOlder?: boolean;
|
||||||
inFlight?: boolean;
|
inFlight?: boolean;
|
||||||
fetchAgentTimeline?: ReturnType<typeof vi.fn>;
|
fetchAgentTimeline?: FetchAgentTimeline;
|
||||||
}) {
|
}) {
|
||||||
const client = makeClient(input?.fetchAgentTimeline);
|
const client = makeClient(input?.fetchAgentTimeline);
|
||||||
useSessionStore.getState().initializeSession(serverId, client as never);
|
useSessionStore.getState().initializeSession(serverId, client as never);
|
||||||
@@ -69,7 +82,7 @@ describe("useLoadOlderAgentHistory", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("dedupes concurrent older-page requests", () => {
|
it("dedupes concurrent older-page requests", () => {
|
||||||
const fetchAgentTimeline = vi.fn(
|
const fetchAgentTimeline = vi.fn<FetchAgentTimeline>(
|
||||||
() =>
|
() =>
|
||||||
new Promise<void>((resolve) => {
|
new Promise<void>((resolve) => {
|
||||||
setTimeout(resolve, 20);
|
setTimeout(resolve, 20);
|
||||||
@@ -120,9 +133,9 @@ describe("useLoadOlderAgentHistory", () => {
|
|||||||
const client = initialize({
|
const client = initialize({
|
||||||
cursor: { epoch: "epoch-1", startSeq: 10, endSeq: 20 },
|
cursor: { epoch: "epoch-1", startSeq: 10, endSeq: 20 },
|
||||||
hasOlder: true,
|
hasOlder: true,
|
||||||
fetchAgentTimeline: vi.fn().mockRejectedValue(error),
|
fetchAgentTimeline: vi.fn<FetchAgentTimeline>().mockRejectedValue(error),
|
||||||
});
|
});
|
||||||
const toast = { show: vi.fn(), copied: vi.fn(), error: vi.fn() };
|
const toast = createToast();
|
||||||
const { result } = renderHook(() => useLoadOlderAgentHistory({ serverId, agentId, toast }));
|
const { result } = renderHook(() => useLoadOlderAgentHistory({ serverId, agentId, toast }));
|
||||||
|
|
||||||
act(() => {
|
act(() => {
|
||||||
|
|||||||
@@ -135,6 +135,8 @@ function queryRowIds(): string[] {
|
|||||||
).map((node) => node.getAttribute("data-testid")?.replace("subagents-section-row-", "") ?? "");
|
).map((node) => node.getAttribute("data-testid")?.replace("subagents-section-row-", "") ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SubagentAction = (id: string) => void;
|
||||||
|
|
||||||
describe("SubagentsSection", () => {
|
describe("SubagentsSection", () => {
|
||||||
let container: HTMLElement | null = null;
|
let container: HTMLElement | null = null;
|
||||||
let root: Root | null = null;
|
let root: Root | null = null;
|
||||||
@@ -169,9 +171,9 @@ describe("SubagentsSection", () => {
|
|||||||
|
|
||||||
function render(
|
function render(
|
||||||
rows: SubagentRow[],
|
rows: SubagentRow[],
|
||||||
onOpenSubagent: ReturnType<typeof vi.fn> = vi.fn(),
|
onOpenSubagent: SubagentAction = vi.fn<SubagentAction>(),
|
||||||
onArchiveSubagent: ReturnType<typeof vi.fn> = vi.fn(),
|
onArchiveSubagent: SubagentAction = vi.fn<SubagentAction>(),
|
||||||
): ReturnType<typeof vi.fn> {
|
): SubagentAction {
|
||||||
act(() => {
|
act(() => {
|
||||||
root?.render(
|
root?.render(
|
||||||
<SubagentsSection
|
<SubagentsSection
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { defineConfig, configDefaults } from "vitest/config";
|
import { defineConfig, configDefaults } from "vitest/config";
|
||||||
|
import { playwright } from "@vitest/browser-playwright";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ export default defineConfig({
|
|||||||
include: ["src/**/*.browser.{test,spec}.{ts,tsx}"],
|
include: ["src/**/*.browser.{test,spec}.{ts,tsx}"],
|
||||||
browser: {
|
browser: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
provider: "playwright",
|
provider: playwright(),
|
||||||
headless: true,
|
headless: true,
|
||||||
connectTimeout: 180_000,
|
connectTimeout: 180_000,
|
||||||
instances: [{ browser: "chromium" }],
|
instances: [{ browser: "chromium" }],
|
||||||
@@ -49,11 +50,7 @@ export default defineConfig({
|
|||||||
* keeps `process.send` intact so the app tests can boot before hitting the intentional failures.
|
* keeps `process.send` intact so the app tests can boot before hitting the intentional failures.
|
||||||
*/
|
*/
|
||||||
pool: "forks",
|
pool: "forks",
|
||||||
poolOptions: {
|
maxWorkers: 2,
|
||||||
forks: {
|
|
||||||
maxForks: 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
server: {
|
server: {
|
||||||
deps: {
|
deps: {
|
||||||
fallbackCJS: true,
|
fallbackCJS: true,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"@types/ws": "^8.5.8",
|
"@types/ws": "^8.5.8",
|
||||||
"tsx": "^4.6.0",
|
"tsx": "^4.6.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vitest": "^3.2.4",
|
"vitest": "^4.1.6",
|
||||||
"zx": "^8.8.5"
|
"zx": "^8.8.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
"electron-builder": "26.8.1",
|
"electron-builder": "26.8.1",
|
||||||
"typescript": "5.9.3",
|
"typescript": "5.9.3",
|
||||||
"unzip-crx-3": "^0.2.0",
|
"unzip-crx-3": "^0.2.0",
|
||||||
"vitest": "^3.2.4",
|
"vitest": "^4.1.6",
|
||||||
"wait-on": "8.0.5"
|
"wait-on": "8.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"vitest": "^3.2.4"
|
"vitest": "^4.1.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,6 @@
|
|||||||
"@types/node": "^20.9.0",
|
"@types/node": "^20.9.0",
|
||||||
"@types/ws": "^8.5.8",
|
"@types/ws": "^8.5.8",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vitest": "^3.2.4"
|
"vitest": "^4.1.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,14 +48,14 @@
|
|||||||
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
|
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
|
||||||
"test": "npm run test:unit && npm run test:integration",
|
"test": "npm run test:unit && npm run test:integration",
|
||||||
"test:unit": "vitest run --exclude \"**/*.e2e.test.ts\"",
|
"test:unit": "vitest run --exclude \"**/*.e2e.test.ts\"",
|
||||||
"test:integration": "vitest run --maxWorkers=1 --minWorkers=1 src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts",
|
"test:integration": "vitest run --maxWorkers=1 src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts",
|
||||||
"test:integration:all": "npm run test:e2e",
|
"test:integration:all": "npm run test:e2e",
|
||||||
"test:integration:real": "vitest run real.e2e.test.ts",
|
"test:integration:real": "vitest run real.e2e.test.ts",
|
||||||
"test:integration:local": "vitest run local.e2e.test.ts",
|
"test:integration:local": "vitest run local.e2e.test.ts",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:ui": "vitest --ui",
|
"test:ui": "vitest --ui",
|
||||||
"test:e2e": "vitest run e2e.test.ts --maxWorkers=1 --minWorkers=1 --exclude \"**/*.real.e2e.test.ts\" --exclude \"**/*.local.e2e.test.ts\"",
|
"test:e2e": "vitest run e2e.test.ts --maxWorkers=1 --exclude \"**/*.real.e2e.test.ts\" --exclude \"**/*.local.e2e.test.ts\"",
|
||||||
"test:e2e:all": "vitest run e2e.test.ts --maxWorkers=1 --minWorkers=1",
|
"test:e2e:all": "vitest run e2e.test.ts --maxWorkers=1",
|
||||||
"test:e2e:real": "npm run test:integration:real",
|
"test:e2e:real": "npm run test:integration:real",
|
||||||
"test:e2e:local": "npm run test:integration:local",
|
"test:e2e:local": "npm run test:integration:local",
|
||||||
"test:e2e:ui": "vitest --ui e2e.test.ts"
|
"test:e2e:ui": "vitest --ui e2e.test.ts"
|
||||||
@@ -103,11 +103,11 @@
|
|||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"@types/uuid": "^9.0.7",
|
"@types/uuid": "^9.0.7",
|
||||||
"@types/ws": "^8.5.8",
|
"@types/ws": "^8.5.8",
|
||||||
"@vitest/ui": "^3.2.4",
|
"@vitest/ui": "^4.1.6",
|
||||||
"cross-env": "^10.1.0",
|
"cross-env": "^10.1.0",
|
||||||
"tsx": "^4.6.0",
|
"tsx": "^4.6.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "^5.2.2",
|
||||||
"vitest": "^3.2.4"
|
"vitest": "^4.1.6"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"lightningcss": "1.30.1"
|
"lightningcss": "1.30.1"
|
||||||
|
|||||||
@@ -14,13 +14,7 @@ export default defineConfig({
|
|||||||
environment: "node",
|
environment: "node",
|
||||||
setupFiles: [path.resolve(__dirname, "./src/test-utils/vitest-setup.ts")],
|
setupFiles: [path.resolve(__dirname, "./src/test-utils/vitest-setup.ts")],
|
||||||
pool: "forks",
|
pool: "forks",
|
||||||
poolOptions: {
|
fileParallelism: false,
|
||||||
forks: {
|
|
||||||
singleFork: true,
|
|
||||||
minForks: 1,
|
|
||||||
maxForks: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
exclude: ["**/node_modules/**", "**/dist/**", "**/.claude/**"],
|
exclude: ["**/node_modules/**", "**/dist/**", "**/.claude/**"],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user