Skip to content
Open
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
19 changes: 18 additions & 1 deletion src/tools/testmanagement-utils/create-testcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -153,7 +162,15 @@ export async function createTestCase(
params: TestCaseCreateRequest,
config: BrowserStackConfig,
): Promise<CallToolResult> {
const body = { test_case: params };
const { test_case_bdd, ...rest } = params;
const testCase: Record<string, any> = { ...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(":");

Expand Down
16 changes: 16 additions & 0 deletions src/tools/testmanagement-utils/update-testcase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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."),
});

/**
Expand Down Expand Up @@ -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 {
Expand Down