diff --git a/openapi.yaml b/openapi.yaml index 5e1901d..8401074 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -391,6 +391,247 @@ components: example: "https://app.octomind.dev/testreports/826c15af-644b-4b28-89b4-f50ff34e46b7" testReport: $ref: "#/components/schemas/TestReport" + + TestCasesResponse: + type: array + items: + $ref: "#/components/schemas/TestCaseResponse" + TestCaseResponse: + type: object + properties: + id: + type: string + format: uuid + testTargetId: + type: string + format: uuid + type: + type: string + nullable: true + elements: + type: array + items: + type: object + properties: + id: + type: string + format: uuid + index: + type: integer + interaction: + type: object + nullable: true + properties: + id: + type: string + format: uuid + action: + type: string + enum: [EXTRACT, ENTER_TEXT, CLICK, SELECT_OPTION, TYPE_TEXT, KEY_PRESS, HOVER,UPLOAD, GO_TO, DRAG_AND_DROP, CLOSE_PAGE, OPEN_EMAIL] + calledWith: + type: string + nullable: true + testCaseElementId: + type: string + format: uuid + assertion: + type: object + nullable: true + properties: + id: + type: string + format: uuid + expectation: + type: string + enum: [VISIBLE, NOT_VISIBLE, TO_BE_CHECKED, NOT_TO_BE_CHECKED, TO_HAVE_VALUE, TO_CONTAIN_TEXT, TO_HAVE_STYLE] + calledWith: + type: string + nullable: true + testCaseElementId: + type: string + format: uuid + scrollState: + type: object + nullable: true + selectors: + type: array + items: + type: object + properties: + id: + type: string + format: uuid + index: + type: integer + selector: + type: string + selectorType: + type: string + enum: [TEXT, LABEL, PLACEHOLDER, ROLE] + options: + type: object + nullable: true + properties: + name: + type: string + testCaseElementId: + type: string + format: uuid + scrollStateId: + type: string + nullable: true + testCaseId: + type: string + format: uuid + ignoreFailure: + type: boolean + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + description: + type: string + status: + type: string + enum: [ENABLED, DRAFT] + externalId: + type: string + nullable: true + entryPointUrlPath: + type: string + nullable: true + tags: + type: array + items: + type: string + createdBy: + type: string + enum: [EDIT] + runStatus: + type: string + enum: [ON, OFF] + prerequisiteId: + type: string + nullable: true + proposalRunId: + type: string + nullable: true + folderId: + type: string + nullable: true + discovery: + type: object + properties: + id: + type: string + format: uuid + freePrompt: + type: string + traceUrl: + type: string + nullable: true + traceJsonManifestUrl: + type: string + nullable: true + status: + type: string + enum: [OUTDATED] + abortCause: + type: string + nullable: true + message: + type: string + nullable: true + testCaseId: + type: string + format: uuid + lastJobExecutionName: + type: string + nullable: true + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + executedTestCaseElements: + type: array + items: + type: string + testCase: + type: object + properties: + id: + type: string + format: uuid + testTargetId: + type: string + format: uuid + description: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + entryPointUrlPath: + type: string + nullable: true + type: + type: string + nullable: true + status: + type: string + enum: [ENABLED] + runStatus: + type: string + enum: [ON] + interactionStatus: + type: string + enum: [NEW] + createdBy: + type: string + enum: [EDIT] + proposalRunId: + type: string + nullable: true + externalId: + type: string + nullable: true + folderId: + type: string + nullable: true + prerequisiteId: + type: string + nullable: true + predecessorId: + type: string + format: uuid + testTarget: + type: object + properties: + id: + type: string + format: uuid + app: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + orgId: + type: string + format: uuid + testIdAttribute: + type: string + nullable: true + timeoutPerStep: + type: integer SuccessResponse: type: object @@ -1163,6 +1404,67 @@ paths: "500": description: Internal server error + /apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}/code: + get: + summary: Retrieve code for a test case + description: Get the code representation of a specific test case + security: + - ApiKeyAuth: [] + tags: + - Test Cases + parameters: + - name: testTargetId + in: path + required: true + schema: + type: string + format: uuid + description: The ID of the test target + - name: testCaseId + in: path + required: true + schema: + type: string + format: uuid + description: The ID of the test case + responses: + '200': + description: Code for the test case + content: + application/json: + schema: + type: object + properties: + testCode: + type: string + description: The code representation of the test case + '404': + description: Test case not found + + /apiKey/v2/test-targets/{testTargetId}/test-cases: + get: + summary: Retrieve test cases + description: Get a list of test cases for a specific test target + security: + - ApiKeyAuth: [] + tags: + - Test Cases + parameters: + - name: testTargetId + in: path + required: true + schema: + type: string + format: uuid + description: The ID of the test target + responses: + '200': + description: List of test cases + content: + application/json: + schema: + $ref: "#/components/schemas/TestCasesResponse" + /apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}: get: summary: Retrieve a test case @@ -1192,246 +1494,43 @@ paths: content: application/json: schema: - type: object - properties: - id: - type: string - format: uuid - testTargetId: - type: string - format: uuid - type: - type: string - nullable: true - elements: - type: array - items: - type: object - properties: - id: - type: string - format: uuid - index: - type: integer - interaction: - type: object - nullable: true - properties: - id: - type: string - format: uuid - action: - type: string - enum: [EXTRACT, ENTER_TEXT, CLICK, SELECT_OPTION, TYPE_TEXT, KEY_PRESS, HOVER,UPLOAD, GO_TO, DRAG_AND_DROP, CLOSE_PAGE, OPEN_EMAIL] - calledWith: - type: string - nullable: true - testCaseElementId: - type: string - format: uuid - assertion: - type: object - nullable: true - properties: - id: - type: string - format: uuid - expectation: - type: string - enum: [VISIBLE, NOT_VISIBLE, TO_BE_CHECKED, NOT_TO_BE_CHECKED, TO_HAVE_VALUE, TO_CONTAIN_TEXT, TO_HAVE_STYLE] - calledWith: - type: string - nullable: true - testCaseElementId: - type: string - format: uuid - scrollState: - type: object - nullable: true - selectors: - type: array - items: - type: object - properties: - id: - type: string - format: uuid - index: - type: integer - selector: - type: string - selectorType: - type: string - enum: [TEXT, LABEL, PLACEHOLDER, ROLE] - options: - type: object - nullable: true - properties: - name: - type: string - testCaseElementId: - type: string - format: uuid - scrollStateId: - type: string - nullable: true - testCaseId: - type: string - format: uuid - ignoreFailure: - type: boolean - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - description: - type: string - status: - type: string - enum: [ENABLED, DRAFT] - externalId: - type: string - nullable: true - entryPointUrlPath: - type: string - nullable: true - tags: - type: array - items: - type: string - createdBy: - type: string - enum: [EDIT] - runStatus: - type: string - enum: [ON, OFF] - prerequisiteId: - type: string - nullable: true - proposalRunId: - type: string - nullable: true - folderId: - type: string - nullable: true - discovery: - type: object - properties: - id: - type: string - format: uuid - freePrompt: - type: string - traceUrl: - type: string - nullable: true - traceJsonManifestUrl: - type: string - nullable: true - status: - type: string - enum: [OUTDATED] - abortCause: - type: string - nullable: true - message: - type: string - nullable: true - testCaseId: - type: string - format: uuid - lastJobExecutionName: - type: string - nullable: true - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - executedTestCaseElements: - type: array - items: - type: string - testCase: - type: object - properties: - id: - type: string - format: uuid - testTargetId: - type: string - format: uuid - description: - type: string - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - entryPointUrlPath: - type: string - nullable: true - type: - type: string - nullable: true - status: - type: string - enum: [ENABLED] - runStatus: - type: string - enum: [ON] - interactionStatus: - type: string - enum: [NEW] - createdBy: - type: string - enum: [EDIT] - proposalRunId: - type: string - nullable: true - externalId: - type: string - nullable: true - folderId: - type: string - nullable: true - prerequisiteId: - type: string - nullable: true - predecessorId: - type: string - format: uuid - testTarget: - type: object - properties: - id: - type: string - format: uuid - app: - type: string - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - orgId: - type: string - format: uuid - testIdAttribute: - type: string - nullable: true - timeoutPerStep: - type: integer + $ref: "#/components/schemas/TestCaseResponse" '401': description: Unauthorized - Invalid or missing API key '404': description: Test target or test case not found + /apiKey/v2/test-targets/{testTargetId}/config: + get: + summary: Retrieve test target configuration + description: Get the configuration of a specific test target + security: + - ApiKeyAuth: [] + tags: + - Test Targets + parameters: + - name: testTargetId + in: path + required: true + schema: + type: string + format: uuid + description: The ID of the test target + - name: environmentId + in: query + required: false + schema: + type: string + format: uuid + description: Optional ID of the environment to use for the test target configuration + responses: + "200": + description: Test target configuration + content: + text/plain: + schema: + type: string + example: "Test target configuration details" /apiKey/v2/test-targets/{testTargetId}/discoveries: post: summary: Create a discovery diff --git a/src/api.ts b/src/api.ts index 0d5c655..693fc8b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -796,6 +796,102 @@ export interface paths { patch?: never; trace?: never; }; + "/apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}/code": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * Retrieve code for a test case + * @description Get the code representation of a specific test case + */ + get: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the test target */ + testTargetId: string; + /** @description The ID of the test case */ + testCaseId: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Code for the test case */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + /** @description The code representation of the test case */ + testCode?: string; + }; + }; + }; + /** @description Test case not found */ + 404: { + headers: { + [name: string]: unknown; + }; + content?: never; + }; + }; + }; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/apiKey/v2/test-targets/{testTargetId}/test-cases": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * Retrieve test cases + * @description Get a list of test cases for a specific test target + */ + get: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the test target */ + testTargetId: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description List of test cases */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["TestCasesResponse"]; + }; + }; + }; + }; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}": { parameters: { query?: never; @@ -827,149 +923,7 @@ export interface paths { [name: string]: unknown; }; content: { - "application/json": { - /** Format: uuid */ - id?: string; - /** Format: uuid */ - testTargetId?: string; - type?: string | null; - elements?: { - /** Format: uuid */ - id?: string; - index?: number; - interaction?: { - /** Format: uuid */ - id?: string; - /** @enum {string} */ - action?: - | "EXTRACT" - | "ENTER_TEXT" - | "CLICK" - | "SELECT_OPTION" - | "TYPE_TEXT" - | "KEY_PRESS" - | "HOVER" - | "UPLOAD" - | "GO_TO" - | "DRAG_AND_DROP" - | "CLOSE_PAGE" - | "OPEN_EMAIL"; - calledWith?: string | null; - /** Format: uuid */ - testCaseElementId?: string; - } | null; - assertion?: { - /** Format: uuid */ - id?: string; - /** @enum {string} */ - expectation?: - | "VISIBLE" - | "NOT_VISIBLE" - | "TO_BE_CHECKED" - | "NOT_TO_BE_CHECKED" - | "TO_HAVE_VALUE" - | "TO_CONTAIN_TEXT" - | "TO_HAVE_STYLE"; - calledWith?: string | null; - /** Format: uuid */ - testCaseElementId?: string; - } | null; - scrollState?: Record | null; - selectors?: { - /** Format: uuid */ - id?: string; - index?: number; - selector?: string; - /** @enum {string} */ - selectorType?: "TEXT" | "LABEL" | "PLACEHOLDER" | "ROLE"; - options?: { - name?: string; - } | null; - /** Format: uuid */ - testCaseElementId?: string; - scrollStateId?: string | null; - }[]; - /** Format: uuid */ - testCaseId?: string; - ignoreFailure?: boolean; - }[]; - /** Format: date-time */ - createdAt?: string; - /** Format: date-time */ - updatedAt?: string; - description?: string; - /** @enum {string} */ - status?: "ENABLED" | "DRAFT"; - externalId?: string | null; - entryPointUrlPath?: string | null; - tags?: string[]; - /** @enum {string} */ - createdBy?: "EDIT"; - /** @enum {string} */ - runStatus?: "ON" | "OFF"; - prerequisiteId?: string | null; - proposalRunId?: string | null; - folderId?: string | null; - discovery?: { - /** Format: uuid */ - id?: string; - freePrompt?: string; - traceUrl?: string | null; - traceJsonManifestUrl?: string | null; - /** @enum {string} */ - status?: "OUTDATED"; - abortCause?: string | null; - message?: string | null; - /** Format: uuid */ - testCaseId?: string; - lastJobExecutionName?: string | null; - /** Format: date-time */ - createdAt?: string; - /** Format: date-time */ - updatedAt?: string; - executedTestCaseElements?: string[]; - testCase?: { - /** Format: uuid */ - id?: string; - /** Format: uuid */ - testTargetId?: string; - description?: string; - /** Format: date-time */ - createdAt?: string; - /** Format: date-time */ - updatedAt?: string; - entryPointUrlPath?: string | null; - type?: string | null; - /** @enum {string} */ - status?: "ENABLED"; - /** @enum {string} */ - runStatus?: "ON"; - /** @enum {string} */ - interactionStatus?: "NEW"; - /** @enum {string} */ - createdBy?: "EDIT"; - proposalRunId?: string | null; - externalId?: string | null; - folderId?: string | null; - prerequisiteId?: string | null; - /** Format: uuid */ - predecessorId?: string; - testTarget?: { - /** Format: uuid */ - id?: string; - app?: string; - /** Format: date-time */ - createdAt?: string; - /** Format: date-time */ - updatedAt?: string; - /** Format: uuid */ - orgId?: string; - testIdAttribute?: string | null; - timeoutPerStep?: number; - }; - }; - }; - }; + "application/json": components["schemas"]["TestCaseResponse"]; }; }; /** @description Unauthorized - Invalid or missing API key */ @@ -996,6 +950,51 @@ export interface paths { patch?: never; trace?: never; }; + "/apiKey/v2/test-targets/{testTargetId}/config": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** + * Retrieve test target configuration + * @description Get the configuration of a specific test target + */ + get: { + parameters: { + query?: { + /** @description Optional ID of the environment to use for the test target configuration */ + environmentId?: string; + }; + header?: never; + path: { + /** @description The ID of the test target */ + testTargetId: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Test target configuration */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "text/plain": string; + }; + }; + }; + }; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/apiKey/v2/test-targets/{testTargetId}/discoveries": { parameters: { query?: never; @@ -1438,6 +1437,150 @@ export interface components { testReportUrl?: string; testReport?: components["schemas"]["TestReport"]; }; + TestCasesResponse: components["schemas"]["TestCaseResponse"][]; + TestCaseResponse: { + /** Format: uuid */ + id?: string; + /** Format: uuid */ + testTargetId?: string; + type?: string | null; + elements?: { + /** Format: uuid */ + id?: string; + index?: number; + interaction?: { + /** Format: uuid */ + id?: string; + /** @enum {string} */ + action?: + | "EXTRACT" + | "ENTER_TEXT" + | "CLICK" + | "SELECT_OPTION" + | "TYPE_TEXT" + | "KEY_PRESS" + | "HOVER" + | "UPLOAD" + | "GO_TO" + | "DRAG_AND_DROP" + | "CLOSE_PAGE" + | "OPEN_EMAIL"; + calledWith?: string | null; + /** Format: uuid */ + testCaseElementId?: string; + } | null; + assertion?: { + /** Format: uuid */ + id?: string; + /** @enum {string} */ + expectation?: + | "VISIBLE" + | "NOT_VISIBLE" + | "TO_BE_CHECKED" + | "NOT_TO_BE_CHECKED" + | "TO_HAVE_VALUE" + | "TO_CONTAIN_TEXT" + | "TO_HAVE_STYLE"; + calledWith?: string | null; + /** Format: uuid */ + testCaseElementId?: string; + } | null; + scrollState?: Record | null; + selectors?: { + /** Format: uuid */ + id?: string; + index?: number; + selector?: string; + /** @enum {string} */ + selectorType?: "TEXT" | "LABEL" | "PLACEHOLDER" | "ROLE"; + options?: { + name?: string; + } | null; + /** Format: uuid */ + testCaseElementId?: string; + scrollStateId?: string | null; + }[]; + /** Format: uuid */ + testCaseId?: string; + ignoreFailure?: boolean; + }[]; + /** Format: date-time */ + createdAt?: string; + /** Format: date-time */ + updatedAt?: string; + description?: string; + /** @enum {string} */ + status?: "ENABLED" | "DRAFT"; + externalId?: string | null; + entryPointUrlPath?: string | null; + tags?: string[]; + /** @enum {string} */ + createdBy?: "EDIT"; + /** @enum {string} */ + runStatus?: "ON" | "OFF"; + prerequisiteId?: string | null; + proposalRunId?: string | null; + folderId?: string | null; + discovery?: { + /** Format: uuid */ + id?: string; + freePrompt?: string; + traceUrl?: string | null; + traceJsonManifestUrl?: string | null; + /** @enum {string} */ + status?: "OUTDATED"; + abortCause?: string | null; + message?: string | null; + /** Format: uuid */ + testCaseId?: string; + lastJobExecutionName?: string | null; + /** Format: date-time */ + createdAt?: string; + /** Format: date-time */ + updatedAt?: string; + executedTestCaseElements?: string[]; + testCase?: { + /** Format: uuid */ + id?: string; + /** Format: uuid */ + testTargetId?: string; + description?: string; + /** Format: date-time */ + createdAt?: string; + /** Format: date-time */ + updatedAt?: string; + entryPointUrlPath?: string | null; + type?: string | null; + /** @enum {string} */ + status?: "ENABLED"; + /** @enum {string} */ + runStatus?: "ON"; + /** @enum {string} */ + interactionStatus?: "NEW"; + /** @enum {string} */ + createdBy?: "EDIT"; + proposalRunId?: string | null; + externalId?: string | null; + folderId?: string | null; + prerequisiteId?: string | null; + /** Format: uuid */ + predecessorId?: string; + testTarget?: { + /** Format: uuid */ + id?: string; + app?: string; + /** Format: date-time */ + createdAt?: string; + /** Format: date-time */ + updatedAt?: string; + /** Format: uuid */ + orgId?: string; + testIdAttribute?: string | null; + timeoutPerStep?: number; + }; + }; + }; + }; SuccessResponse: { /** * @description Indicates whether the operation was successful. diff --git a/src/tools.ts b/src/tools.ts index 7af6a08..9ddf246 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -15,6 +15,10 @@ export type PostEnvironmentOptions = testTargetId: string; }; +export type TestCaseResponse = components["schemas"]["TestCaseResponse"]; + +export type TestCasesResponse = components["schemas"]["TestCasesResponse"]; + export type UpdateEnvironmentOptions = paths["/apiKey/v2/test-targets/{testTargetId}/environments/{environmentId}"]["patch"]["requestBody"]["content"]["application/json"]; export type EnvironmentResponse = components["schemas"]["EnvironmentResponse"]; @@ -380,3 +384,84 @@ export const deleteEnvironment = async (options: { console.log("Environment deleted successfully!"); }; + +export const getPlaywrightConfig = async (options: { + testTargetId: string; + environmentId?: string; + json?: boolean; +}): Promise => { + const { data, error } = await client.GET( + "/apiKey/v2/test-targets/{testTargetId}/config", + { + params: { + path: { + testTargetId: options.testTargetId, + }, + query: { + environmentId: options.environmentId, + }, + }, + }, + ); + + handleError(error); + + if (options.json) { + outputResult(data); + return; + } + + return data; +}; + +export const getPlaywrightCode = async (options: { + testTargetId: string; + testCaseId: string; + json?: boolean; +}): Promise => { + const { data, error } = await client.GET( + "/apiKey/v2/test-targets/{testTargetId}/test-cases/{testCaseId}/code", + { + params: { + path: { + testTargetId: options.testTargetId, + testCaseId: options.testCaseId, + }, + }, + }, + ); + + handleError(error); + + if (options.json) { + outputResult(data); + return; + } + + return data?.testCode; +}; + +export const getTestCases = async (options: { + testTargetId: string; + json?: boolean; +}): Promise => { + const { data, error } = await client.GET( + "/apiKey/v2/test-targets/{testTargetId}/test-cases", + { + params: { + path: { + testTargetId: options.testTargetId, + }, + }, + }, + ); + + handleError(error); + + if (options.json) { + outputResult(data); + return; + } + + return data; +};