fix(tests): skip live container tests when OPENPROJECT_API_KEY is not set
This commit is contained in:
+6
-12
@@ -531,16 +531,12 @@ describe("OpenProjectClient (Mocked Unit Tests)", () => {
|
|||||||
describe("OpenProject Live API Integration (Local Container)", () => {
|
describe("OpenProject Live API Integration (Local Container)", () => {
|
||||||
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
||||||
const liveApiKey = process.env.OPENPROJECT_API_KEY;
|
const liveApiKey = process.env.OPENPROJECT_API_KEY;
|
||||||
|
const runLiveTests = liveApiKey ? test : test.skip;
|
||||||
|
|
||||||
test("fetches projects and work packages against live instance", async () => {
|
runLiveTests("fetches projects and work packages against live instance", async () => {
|
||||||
if (!liveApiKey) {
|
|
||||||
console.warn("Skipping live container test: OPENPROJECT_API_KEY not set");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = new OpenProjectClient({
|
const client = new OpenProjectClient({
|
||||||
baseUrl: liveBaseUrl,
|
baseUrl: liveBaseUrl,
|
||||||
apiKey: liveApiKey,
|
apiKey: liveApiKey!,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 1. Fetch projects
|
// 1. Fetch projects
|
||||||
@@ -582,7 +578,7 @@ describe("OpenProject Live API Integration (Local Container)", () => {
|
|||||||
expect(priorities.items.length).toBeGreaterThan(0);
|
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({
|
const client = new OpenProjectClient({
|
||||||
baseUrl: liveBaseUrl,
|
baseUrl: liveBaseUrl,
|
||||||
apiKey: "definitely-invalid-key-9999",
|
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 () => {
|
runLiveTests("live 404 not found failure with non-existent project", async () => {
|
||||||
if (!liveApiKey) return;
|
|
||||||
|
|
||||||
const client = new OpenProjectClient({
|
const client = new OpenProjectClient({
|
||||||
baseUrl: liveBaseUrl,
|
baseUrl: liveBaseUrl,
|
||||||
apiKey: liveApiKey,
|
apiKey: liveApiKey!,
|
||||||
});
|
});
|
||||||
|
|
||||||
await expect(client.get("/api/v3/projects/9999999")).rejects.toBeInstanceOf(
|
await expect(client.get("/api/v3/projects/9999999")).rejects.toBeInstanceOf(
|
||||||
|
|||||||
@@ -190,10 +190,11 @@ describe("MCP Server Factory", () => {
|
|||||||
|
|
||||||
describe("End-to-End Live Tool Calling over MCP Client", () => {
|
describe("End-to-End Live Tool Calling over MCP Client", () => {
|
||||||
const baseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
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 () => {
|
runLiveTests("calls openproject_list_projects and openproject_get_work_package via Client", async () => {
|
||||||
const mcpServer = createServer({ baseUrl, apiKey, readOnly: false });
|
const mcpServer = createServer({ baseUrl, apiKey: apiKey || "skip", readOnly: false });
|
||||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||||
await mcpServer.start(serverTransport);
|
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 () => {
|
runLiveTests("tool error propagation returns isError: true without crashing client", async () => {
|
||||||
const mcpServer = createServer({ baseUrl, apiKey, readOnly: false });
|
const mcpServer = createServer({ baseUrl, apiKey: apiKey || "skip", readOnly: false });
|
||||||
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
||||||
await mcpServer.start(serverTransport);
|
await mcpServer.start(serverTransport);
|
||||||
|
|
||||||
|
|||||||
@@ -240,10 +240,11 @@ describe("OpenApi MCP Tool Registration & Execution", () => {
|
|||||||
|
|
||||||
describe("Live Container OpenAPI Integration", () => {
|
describe("Live Container OpenAPI Integration", () => {
|
||||||
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
const liveBaseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
||||||
const liveApiKey = process.env.OPENPROJECT_API_KEY || "";
|
const liveApiKey = process.env.OPENPROJECT_API_KEY;
|
||||||
const liveClient = new OpenProjectClient({ baseUrl: liveBaseUrl, apiKey: liveApiKey });
|
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;
|
const summary = (await getOpenApiSpec({}, liveClient)) as OpenApiSummary;
|
||||||
expect(summary.title).toContain("OpenProject API");
|
expect(summary.title).toContain("OpenProject API");
|
||||||
expect(summary.totalPaths).toBeGreaterThan(200);
|
expect(summary.totalPaths).toBeGreaterThan(200);
|
||||||
@@ -251,7 +252,7 @@ describe("Live Container OpenAPI Integration", () => {
|
|||||||
expect(summary.availablePaths).toContain("/api/v3/work_packages");
|
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 {
|
const res = (await getOpenApiSpec({ path: "/api/v3/work_packages" }, liveClient)) as {
|
||||||
path: string;
|
path: string;
|
||||||
operations: {
|
operations: {
|
||||||
|
|||||||
+7
-6
@@ -1156,10 +1156,11 @@ describe("Tool Execution Wrapper", () => {
|
|||||||
|
|
||||||
describe("Live Container Integration (All 10 MCP Tools)", () => {
|
describe("Live Container Integration (All 10 MCP Tools)", () => {
|
||||||
const baseUrl = process.env.OPENPROJECT_BASE_URL || "http://localhost:8080";
|
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 liveClient = new OpenProjectClient({ baseUrl, apiKey });
|
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 () => {
|
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
|
||||||
const listRes = await handleListProjects({ pageSize: 5 });
|
const listRes = await handleListProjects({ pageSize: 5 });
|
||||||
expect(listRes.isError).toBeUndefined();
|
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 () => {
|
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
|
||||||
const listRes = await handleListWorkPackages({ pageSize: 5 });
|
const listRes = await handleListWorkPackages({ pageSize: 5 });
|
||||||
expect(listRes.isError).toBeUndefined();
|
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 () => {
|
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
|
||||||
const listRes = await handleListQueries({});
|
const listRes = await handleListQueries({});
|
||||||
expect(listRes.isError).toBeUndefined();
|
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 () => {
|
await runWithContext({ client: liveClient, isReadOnly: false }, async () => {
|
||||||
const typesRes = await handleListTypes({});
|
const typesRes = await handleListTypes({});
|
||||||
expect(typesRes.isError).toBeUndefined();
|
expect(typesRes.isError).toBeUndefined();
|
||||||
|
|||||||
Reference in New Issue
Block a user