First pass at pulling the v1.5 CLI, TUI, and Launcher clients into v2.
This commit is contained in:
parent
d5f12b2a82
commit
467b01edd6
2 changed files with 24043 additions and 203 deletions
27
clients/web/src/test/core/logging/logger.test.ts
Normal file
27
clients/web/src/test/core/logging/logger.test.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { describe, it, expect } from "vitest";
|
||||
import { silentLogger } from "../../../../../../core/logging/logger.js";
|
||||
|
||||
describe("silentLogger", () => {
|
||||
it("reports silent level", () => {
|
||||
expect(silentLogger.level).toBe("silent");
|
||||
});
|
||||
|
||||
it("accepts log calls at every level without throwing", () => {
|
||||
expect(() => {
|
||||
silentLogger.fatal("fatal");
|
||||
silentLogger.error("error");
|
||||
silentLogger.warn("warn");
|
||||
silentLogger.info("info");
|
||||
silentLogger.debug("debug");
|
||||
silentLogger.trace("trace");
|
||||
silentLogger.silent("silent");
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("child returns a logger that remains silent", () => {
|
||||
const child = silentLogger.child({ component: "test" });
|
||||
expect(child.level).toBe("silent");
|
||||
expect(() => child.info("nested")).not.toThrow();
|
||||
expect(child.child()).toBe(child);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
||||
import { mkdirSync, mkdtempSync, writeFileSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
|
|
@ -170,10 +170,16 @@ describe("resolveServerConfigs — single mode", () => {
|
|||
).toThrow(/Only stdio transport can be used with local commands/);
|
||||
});
|
||||
|
||||
it("rejects an empty target with no URL", () => {
|
||||
expect(() => resolveServerConfigs({ target: [] }, "single")).toThrow(
|
||||
/Target is required/,
|
||||
);
|
||||
it("uses the default config path when no target or --config is given", () => {
|
||||
const prevHome = process.env.HOME;
|
||||
process.env.HOME = tempDir;
|
||||
try {
|
||||
expect(() => resolveServerConfigs({ target: [] }, "single")).toThrow(
|
||||
/Config file not found/,
|
||||
);
|
||||
} finally {
|
||||
process.env.HOME = prevHome;
|
||||
}
|
||||
});
|
||||
|
||||
it("loads a named server from config", () => {
|
||||
|
|
@ -358,6 +364,26 @@ describe("resolveServerConfigs — multi mode", () => {
|
|||
expect(configs[0]?.type).toBe("stdio");
|
||||
});
|
||||
|
||||
it("loads the default config path when no args are given", () => {
|
||||
const prevHome = process.env.HOME;
|
||||
const homeDir = join(tempDir, "home");
|
||||
mkdirSync(homeDir, { recursive: true });
|
||||
const defaultConfig = join(homeDir, ".mcp-inspector", "mcp.json");
|
||||
mkdirSync(join(homeDir, ".mcp-inspector"), { recursive: true });
|
||||
writeFileSync(
|
||||
defaultConfig,
|
||||
JSON.stringify({ mcpServers: { a: { command: "a" } } }),
|
||||
);
|
||||
process.env.HOME = homeDir;
|
||||
try {
|
||||
const configs = resolveServerConfigs({}, "multi");
|
||||
expect(configs).toHaveLength(1);
|
||||
expect(configs[0]).toMatchObject({ type: "stdio", command: "a" });
|
||||
} finally {
|
||||
process.env.HOME = prevHome;
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects ad-hoc flags alongside a config path", () => {
|
||||
writeFileSync(
|
||||
configPath,
|
||||
|
|
|
|||
Loading…
Reference in a new issue