fix(tests): skip live container tests when OPENPROJECT_API_KEY is not set

This commit is contained in:
Lucas Winther
2026-09-06 21:05:36 +02:00
parent 03a1f44517
commit e56bd574e2
4 changed files with 24 additions and 27 deletions
+6 -12
View File
@@ -531,16 +531,12 @@ describe("OpenProjectClient (Mocked Unit Tests)", () => {
describe("OpenProject Live API Integration (Local Container)", () => {
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
const liveApiKey = process.env.OPENPROJECT_API_KEY;
const runLiveTests = liveApiKey ? test : test.skip;
test("fetches projects and work packages against live instance", async () => {
if (!liveApiKey) {
console.warn("Skipping live container test: OPENPROJECT_API_KEY not set");
return;
}
runLiveTests("fetches projects and work packages against live instance", async () => {
const client = new OpenProjectClient({
baseUrl: liveBaseUrl,
apiKey: liveApiKey,
apiKey: liveApiKey!,
});
// 1. Fetch projects
@@ -582,7 +578,7 @@ describe("OpenProject Live API Integration (Local Container)", () => {
expect(priorities.items.length).toBeGreaterThan(0);
});
test("live 401 authentication failure with invalid key", async () => {
runLiveTests("live 401 authentication failure with invalid key", async () => {
const client = new OpenProjectClient({
baseUrl: liveBaseUrl,
apiKey: "definitely-invalid-key-9999",
@@ -593,12 +589,10 @@ describe("OpenProject Live API Integration (Local Container)", () => {
);
});
test("live 404 not found failure with non-existent project", async () => {
if (!liveApiKey) return;
runLiveTests("live 404 not found failure with non-existent project", async () => {
const client = new OpenProjectClient({
baseUrl: liveBaseUrl,
apiKey: liveApiKey,
apiKey: liveApiKey!,
});
await expect(client.get("/api/v3/projects/9999999")).rejects.toBeInstanceOf(
+6 -5
View File
@@ -190,10 +190,11 @@ describe("MCP Server Factory", () => {
describe("End-to-End Live Tool Calling over MCP Client", () => {
const baseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
const apiKey = process.env.OPENPROJECT_API_KEY || "";
const apiKey = process.env.OPENPROJECT_API_KEY;
const runLiveTests = apiKey ? test : test.skip;
test("calls openproject_list_projects and openproject_get_work_package via Client", async () => {
const mcpServer = createServer({ baseUrl, apiKey, readOnly: false });
runLiveTests("calls openproject_list_projects and openproject_get_work_package via Client", async () => {
const mcpServer = createServer({ baseUrl, apiKey: apiKey || "skip", readOnly: false });
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await mcpServer.start(serverTransport);
@@ -230,8 +231,8 @@ describe("End-to-End Live Tool Calling over MCP Client", () => {
}
});
test("tool error propagation returns isError: true without crashing client", async () => {
const mcpServer = createServer({ baseUrl, apiKey, readOnly: false });
runLiveTests("tool error propagation returns isError: true without crashing client", async () => {
const mcpServer = createServer({ baseUrl, apiKey: apiKey || "skip", readOnly: false });
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
await mcpServer.start(serverTransport);
+5 -4
View File
@@ -240,10 +240,11 @@ describe("OpenApi MCP Tool Registration & Execution", () => {
describe("Live Container OpenAPI Integration", () => {
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
const liveApiKey = process.env.OPENPROJECT_API_KEY || "";
const liveClient = new OpenProjectClient({ baseUrl: liveBaseUrl, apiKey: liveApiKey });
const liveApiKey = process.env.OPENPROJECT_API_KEY;
const runLiveTests = liveApiKey ? test : test.skip;
const liveClient = new OpenProjectClient({ baseUrl: liveBaseUrl, apiKey: liveApiKey || "skip" });
test("live query returns OpenProject API summary with paths and tags", async () => {
runLiveTests("live query returns OpenProject API summary with paths and tags", async () => {
const summary = (await getOpenApiSpec({}, liveClient)) as OpenApiSummary;
expect(summary.title).toContain("OpenProject API");
expect(summary.totalPaths).toBeGreaterThan(200);
@@ -251,7 +252,7 @@ describe("Live Container OpenAPI Integration", () => {
expect(summary.availablePaths).toContain("/api/v3/work_packages");
});
test("live query fetches operation details for /api/v3/work_packages", async () => {
runLiveTests("live query fetches operation details for /api/v3/work_packages", async () => {
const res = (await getOpenApiSpec({ path: "/api/v3/work_packages" }, liveClient)) as {
path: string;
operations: {
+7 -6
View File
@@ -1156,10 +1156,11 @@ describe("Tool Execution Wrapper", () => {
describe("Live Container Integration (All 10 MCP Tools)", () => {
const baseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
const apiKey = process.env.OPENPROJECT_API_KEY || "";
const liveClient = new OpenProjectClient({ baseUrl, apiKey });
const apiKey = process.env.OPENPROJECT_API_KEY;
const runLiveTests = apiKey ? test : test.skip;
const liveClient = new OpenProjectClient({ baseUrl, apiKey: apiKey || "skip" });
test("live: list projects and get project tool execution", async () => {
runLiveTests("live: list projects and get project tool execution", async () => {
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
const listRes = await handleListProjects({ pageSize: 5 });
expect(listRes.isError).toBeUndefined();
@@ -1177,7 +1178,7 @@ describe("Live Container Integration (All 10 MCP Tools)", () => {
});
});
test("live: list work packages and get work package tool execution", async () => {
runLiveTests("live: list work packages and get work package tool execution", async () => {
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
const listRes = await handleListWorkPackages({ pageSize: 5 });
expect(listRes.isError).toBeUndefined();
@@ -1193,7 +1194,7 @@ describe("Live Container Integration (All 10 MCP Tools)", () => {
});
});
test("live: list queries and get query tool execution", async () => {
runLiveTests("live: list queries and get query tool execution", async () => {
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
const listRes = await handleListQueries({});
expect(listRes.isError).toBeUndefined();
@@ -1209,7 +1210,7 @@ describe("Live Container Integration (All 10 MCP Tools)", () => {
});
});
test("live: metadata tools execution (types, statuses, priorities, users)", async () => {
runLiveTests("live: metadata tools execution (types, statuses, priorities, users)", async () => {
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
const typesRes = await handleListTypes({});
expect(typesRes.isError).toBeUndefined();