Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tools/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { components, paths } from "../api"; // generated by openapi-typescr
import createClient, { Middleware } from "openapi-fetch";
import { loadConfig } from "../config";

const BASE_URL = process.env.OCTOMIND_API_URL || "https://app.octomind.dev/api";
export const BASE_URL =
process.env.OCTOMIND_API_URL || "https://app.octomind.dev/api";
type ErrorResponse = components["schemas"]["ZodResponse"] | string | undefined;

const client = createClient<paths>({ baseUrl: BASE_URL });
Expand Down
7 changes: 7 additions & 0 deletions src/tools/discoveries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { components } from "../api"; // generated by openapi-typescript
import { getUrl } from "../url";
import { client, handleError, ListOptions, logJson } from "./client";

export type CreateDiscoveryBody =
Expand Down Expand Up @@ -44,6 +45,12 @@ export const createDiscovery = async (
}

console.log("Discovery created successfully!");
console.log(
`${await getUrl({
testCaseId: response.testCaseId ?? "",
entityType: "discovery",
})}`,
);
console.log(`Discovery ID: ${response.discoveryId}`);
console.log(`Test Case ID: ${response.testCaseId}`);
};
14 changes: 10 additions & 4 deletions src/tools/test-cases.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { paths, components } from "../api"; // generated by openapi-typescript
import { getUrl } from "../url";
import { client, handleError, ListOptions, logJson } from "./client";

export type TestCaseResponse = components["schemas"]["TestCaseResponse"];
Expand Down Expand Up @@ -105,14 +106,19 @@ export const listTestCases = async (
}

console.log("Test Cases:");
testCases.forEach((testCase, idx) => {
for (let idx = 0; idx < testCases.length; idx++) {
const testCase = testCases[idx];
const idxString = `${idx + 1}. `.padEnd(
testCases.length.toString().length + 2,
);
const paddingString = " ".repeat(idxString.length);
console.log(`${idxString}Description: ${testCase.description}`);
console.log(`${paddingString}ID: ${testCase.id}`);
console.log(`${paddingString}Created At: ${testCase.createdAt}`);
console.log(`${paddingString}Updated At: ${testCase.updatedAt}`);
});
console.log(
`${paddingString}${await getUrl({
testCaseId: testCase.id,
entityType: "test-case",
})}`,
);
}
};
12 changes: 10 additions & 2 deletions src/tools/test-reports.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { paths, components } from "../api"; // generated by openapi-typescript
import { getUrl } from "../url";
import { client, handleError, ListOptions, logJson } from "./client";

export type ExecuteTestsBody =
Expand Down Expand Up @@ -84,14 +85,21 @@ export const listTestReport = async (

if ((response.testResults ?? []).length > 0) {
console.log("\nTest Results:");
(response.testResults ?? []).forEach((result) => {
for (const result of response.testResults ?? []) {
console.log(`- Test ${result.testCaseId}: ${result.status}`);
console.log(
` ${await getUrl({
testReportId: options.testReportId,
testResultId: result.id ?? "",
entityType: "test-result",
})}`,
);
if (result.errorMessage) {
console.log(` Error: ${result.errorMessage}`);
}
if (result.traceUrl) {
console.log(` Trace: ${result.traceUrl}`);
}
});
}
}
};
13 changes: 11 additions & 2 deletions src/tools/test-targets.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getUrl } from "../url";
import { client, handleError, ListOptions, logJson } from "./client";

export const getTestTargets = async () => {
Expand All @@ -21,12 +22,20 @@ export const listTestTargets = async (options: ListOptions): Promise<void> => {
}

console.log("Test Targets:");
testTargets.forEach((testTarget, idx) => {

for (let idx = 0; idx < testTargets.length; idx++) {
const testTarget = testTargets[idx];
const idxString = `${idx + 1}. `.padEnd(
testTargets.length.toString().length + 2,
);
const paddingString = " ".repeat(idxString.length);
console.log(`${idxString}ID: ${testTarget.id}`);
console.log(`${paddingString}App: ${testTarget.app}`);
});
console.log(
`${paddingString}${await getUrl({
testTargetId: testTarget.id,
entityType: "test-target",
})}`,
);
}
};
34 changes: 34 additions & 0 deletions src/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { loadConfig } from "./config";
import { BASE_URL } from "./tools/client";

export const getUrl = async (
input:
| { testTargetId: string; entityType: "test-target" }
| { testCaseId: string; entityType: "test-case" }
| { testReportId: string; entityType: "test-report" }
| {
testReportId: string;
testResultId: string;
entityType: "test-result";
}
| { testCaseId: string; entityType: "discovery" },
): Promise<string> => {
const relevantBaseUrl = new URL(BASE_URL).origin;
const config = await loadConfig();
const testTargetId = config.testTargetId;
if (!testTargetId) {
throw new Error("Test target id is not set");
}
switch (input.entityType) {
case "test-case":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testcases?testCaseId=${input.testCaseId}`;
case "test-target":
return `${relevantBaseUrl}/testtargets/${testTargetId}`;
case "test-report":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testreports/${input.testReportId}`;
case "test-result":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testreports/${input.testReportId}/testresults/${input.testResultId}`;
case "discovery":
return `${relevantBaseUrl}/testtargets/${testTargetId}/testcases/${input.testCaseId}`;
}
};