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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This way even entityIds like environmentIds or testCaseIds will be autocompleted

# octomind

Octomind cli tool. Version: 1.3.2. Additional documentation see https://octomind.dev/docs/api-reference/
Octomind cli tool. Version: 1.3.1. Additional documentation see https://octomind.dev/docs/api-reference/

**Usage:** `octomind [options] [command]`

Expand Down Expand Up @@ -351,6 +351,22 @@ Delete a test case
| `-c, --test-case-id <id>` | Test case ID | Yes | |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

## code

Get code of a specific test case

**Usage:** `code [options]`

### Options

| Option | Description | Required | Default |
|:-------|:----------|:---------|:--------|
| `-j, --json` | Output raw JSON response | No | |
| `-c, --test-case-id <id>` | Test case ID | Yes | |
| `-u, --url <url>` | URL to execute the test case against | Yes | |
| `-e, --environment-id [id]` | Environment ID | No | default |
| `-t, --test-target-id [id]` | Test target ID, if not provided will use the test target id from the config | No | |

## test-case

Get details of a specific test case
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@octomind/octomind",
"version": "1.3.2",
"version": "1.3.3",
"description": "a command line client for octomind apis",
"main": "./dist/index.js",
"packageManager": "pnpm@10.13.1",
Expand Down
12 changes: 12 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
GetTestCaseParams,
GetTestReportParams,
getEnvironment,
getTestCaseCode,
listEnvironments,
listNotifications,
listPrivateLocations,
Expand Down Expand Up @@ -299,6 +300,17 @@ export const buildCmd = (): CompletableCommand => {
.helpGroup("test-cases")
.action(addTestTargetWrapper(deleteTestCase));

createCommandWithCommonOptions(program, "code")
.completer(testCaseIdCompleter)
.completer(testTargetIdCompleter)
.description("Get code of a specific test case")
.helpGroup("test-cases")
.requiredOption("-c, --test-case-id <id>", "Test case ID")
.requiredOption("-u, --url <url>", "URL to execute the test case against")
.option("-e, --environment-id [id]", "Environment ID", "default")
.addOption(testTargetIdOption)
.action(addTestTargetWrapper(getTestCaseCode));

createCommandWithCommonOptions(program, "test-case")
.completer(testCaseIdCompleter)
.completer(testTargetIdCompleter)
Expand Down
2 changes: 2 additions & 0 deletions src/tools/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import createClient, { Middleware } from "openapi-fetch";

import type { components, paths } from "../api"; // generated by openapi-typescript
import { loadConfig } from "../config";
import { version } from "../version";

export const BASE_URL =
process.env.OCTOMIND_API_URL || "https://app.octomind.dev/api";
Expand All @@ -23,6 +24,7 @@ const authMiddleware: Middleware = {
);
}
request.headers.set("x-api-key", apiKey);
request.headers.set("user-agent", `octomind-cli/${version}`);
return request;
},
async onResponse({ response }) {
Expand Down
47 changes: 47 additions & 0 deletions src/tools/test-cases.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { components, paths } from "../api"; // generated by openapi-typescript
import { getUrl } from "../url";
import { client, handleError, ListOptions, logJson } from "./client";
import { getEnvironments } from "./environments";

export type TestCaseResponse = components["schemas"]["TestCaseResponse"];
export type TestCasesResponse = components["schemas"]["TestCasesResponse"];
Expand Down Expand Up @@ -122,6 +123,52 @@ export const getTestCases = async (

return data;
};

export const getTestCaseCode = async (
options: GetTestCaseParams &
ListOptions & {
url: string;
environmentId?: string;
},
): Promise<void> => {
if (options.environmentId === "default") {
const environments = await getEnvironments({
testTargetId: options.testTargetId,
});
options.environmentId = environments.find((e) => e.type === "DEFAULT")?.id;
if (!options.environmentId) {
throw new Error("no default environment found");
}
}
const { data, error } = await client.GET(
"/apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}/code",
{
params: {
path: {
testTargetId: options.testTargetId,
testCaseId: options.testCaseId,
},
query: {
executionUrl: options.url,
environmentId: options.environmentId,
},
},
},
);

handleError(error);

if (options.json) {
logJson(data);
return;
}

if (!data) {
throw new Error("no test code found");
}
console.log(data.testCode);
Comment thread
sker65 marked this conversation as resolved.
};

export const listTestCases = async (
options: GetTestCasesOptions & ListOptions,
): Promise<void> => {
Expand Down