Archived
test: make working-directory tests pass on Windows
Drive-qualify resolved paths in fixtures and assert against normalized cwds so route tests match the values normalizeRequestCwd produces. Skip the POSIX-shell TerminalService suite on native Windows, where the terminal feature is unsupported.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { resolve } from "node:path";
|
||||
import Fastify, { type FastifyInstance } from "fastify";
|
||||
import fastifyWebsocket from "@fastify/websocket";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
@@ -32,11 +33,14 @@ describe("terminal routes", () => {
|
||||
});
|
||||
|
||||
it("closes all terminals for a cwd", async () => {
|
||||
const response = await app.inject({ method: "DELETE", url: `/terminals?cwd=${encodeURIComponent("/repo/worktree")}` });
|
||||
// The route normalizes the request cwd, so the service receives the
|
||||
// resolved absolute path (drive-qualified on Windows).
|
||||
const requestCwd = resolve("/repo/worktree");
|
||||
const response = await app.inject({ method: "DELETE", url: `/terminals?cwd=${encodeURIComponent(requestCwd)}` });
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.json()).toEqual({ closed: true });
|
||||
expect(terminals.events).toEqual(["close-cwd:/repo/worktree"]);
|
||||
expect(terminals.events).toEqual([`close-cwd:${requestCwd}`]);
|
||||
});
|
||||
|
||||
it("creates and lists terminal command runs with filters", async () => {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { TerminalService } from "./terminalService";
|
||||
|
||||
describe("TerminalService command runs", () => {
|
||||
// TerminalService spawns a POSIX shell (/bin/bash with -lc and commands like
|
||||
// printf/true/exit). The terminal feature is not supported on native Windows,
|
||||
// so these tests are skipped there rather than asserting Unix shell behavior.
|
||||
describe.skipIf(process.platform === "win32")("TerminalService command runs", () => {
|
||||
it("closes all terminal records for a cwd", () => {
|
||||
const service = new TerminalService();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user