Skip to content

Commit ee62387

Browse files
authored
Merge pull request #98 from salesforcecli/wr/emptyExpectedActions
fix: allow no actions in generate test-spec W-17891598
2 parents 226a9b0 + 794f82a commit ee62387

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/commands/agent/generate/test-spec.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,27 @@ async function promptForTestCase(genAiPlugins: Record<string, string>, genAiFunc
7474
actions = castArray(parsed.GenAiPlugin.genAiFunctions ?? []).map((f) => f.functionName);
7575
}
7676

77-
const expectedActions = await checkbox<string>({
78-
message: 'Expected action(s)',
79-
choices: [...actions, ...genAiFunctions],
80-
theme,
81-
required: true,
82-
});
77+
const expectedActions = (
78+
await checkbox<string | null>({
79+
message: 'Expected action(s)',
80+
choices: [
81+
{ name: 'No Actions', value: null },
82+
...actions.concat(genAiFunctions).map((a) => ({ name: a, value: a })),
83+
],
84+
theme,
85+
validate: (choices) => {
86+
if (choices.find((c) => c.name === 'No Actions')?.checked && choices.length > 1) {
87+
// "no actions" selected, and other actions selected
88+
// returns as the error message to the user
89+
return 'Cannot select "No Actions" and other Actions';
90+
}
91+
return true;
92+
},
93+
required: true,
94+
})
95+
)
96+
// remove the 'No Actions', null entry to produce "expectedActions: []" in spec.yaml
97+
.filter((f) => f !== null);
8398

8499
const expectedOutcome = await input({
85100
message: 'Expected outcome',

0 commit comments

Comments
 (0)