From 46ac225377852e9f2ae070a513ba4170713076c5 Mon Sep 17 00:00:00 2001 From: "tadeo.rosochacki" Date: Fri, 13 Feb 2026 13:02:40 -0300 Subject: [PATCH] feat(testmanagement): add optional test_case_bdd field for BDD/Gherkin template support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test_case_bdd as an optional parameter to createTestCase and updateTestCase. When provided, the BDD fields (feature, scenario, background) are flattened into the API body with template set to test_case_bdd. Fully backwards-compatible — no existing fields or behavior changed. --- .../testmanagement-utils/create-testcase.ts | 19 ++++++++++++++++++- .../testmanagement-utils/update-testcase.ts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/tools/testmanagement-utils/create-testcase.ts b/src/tools/testmanagement-utils/create-testcase.ts index 2cbeb3e..1ee9aba 100644 --- a/src/tools/testmanagement-utils/create-testcase.ts +++ b/src/tools/testmanagement-utils/create-testcase.ts @@ -24,6 +24,7 @@ export interface TestCaseCreateRequest { owner?: string; preconditions?: string; test_case_steps: TestCaseStep[]; + test_case_bdd?: { feature: string; scenario: string; background?: string }; issues?: string[]; issue_tracker?: IssueTracker; tags?: string[]; @@ -93,6 +94,14 @@ export const CreateTestCaseSchema = z.object({ }), ) .describe("List of steps and expected results."), + test_case_bdd: z + .object({ + feature: z.string().describe("Feature description for BDD/Gherkin test cases."), + scenario: z.string().describe("Gherkin scenario with Given/When/Then steps."), + background: z.string().optional().describe("Optional background steps shared across scenarios."), + }) + .optional() + .describe("BDD/Gherkin template fields. Mutually exclusive with test_case_steps."), issues: z .array(z.string()) .optional() @@ -153,7 +162,15 @@ export async function createTestCase( params: TestCaseCreateRequest, config: BrowserStackConfig, ): Promise { - const body = { test_case: params }; + const { test_case_bdd, ...rest } = params; + const testCase: Record = { ...rest }; + if (test_case_bdd) { + testCase.template = "test_case_bdd"; + testCase.feature = test_case_bdd.feature; + testCase.scenario = test_case_bdd.scenario; + if (test_case_bdd.background) testCase.background = test_case_bdd.background; + } + const body = { test_case: testCase }; const authString = getBrowserStackAuth(config); const [username, password] = authString.split(":"); diff --git a/src/tools/testmanagement-utils/update-testcase.ts b/src/tools/testmanagement-utils/update-testcase.ts index fc875d5..85c7656 100644 --- a/src/tools/testmanagement-utils/update-testcase.ts +++ b/src/tools/testmanagement-utils/update-testcase.ts @@ -18,6 +18,7 @@ export interface TestCaseUpdateRequest { step: string; result: string; }>; + test_case_bdd?: { feature: string; scenario: string; background?: string }; } export const UpdateTestCaseSchema = z.object({ @@ -49,6 +50,14 @@ export const UpdateTestCaseSchema = z.object({ ) .optional() .describe("Updated list of test case steps with expected results."), + test_case_bdd: z + .object({ + feature: z.string().describe("Updated feature description for BDD test cases."), + scenario: z.string().describe("Updated Gherkin scenario with Given/When/Then steps."), + background: z.string().optional().describe("Updated background steps for BDD test cases."), + }) + .optional() + .describe("BDD/Gherkin template fields. Mutually exclusive with test_case_steps."), }); /** @@ -80,6 +89,13 @@ export async function updateTestCase( testCaseBody.steps = params.test_case_steps; } + if (params.test_case_bdd !== undefined) { + testCaseBody.template = "test_case_bdd"; + testCaseBody.feature = params.test_case_bdd.feature; + testCaseBody.scenario = params.test_case_bdd.scenario; + if (params.test_case_bdd.background) testCaseBody.background = params.test_case_bdd.background; + } + const body = { test_case: testCaseBody }; try {