Skip to content

Commit ad932e4

Browse files
committed
Add tests
1 parent 2702efb commit ad932e4

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

  • x-pack
    • plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira
    • test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types

x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/jira/jira.test.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('jira action params validation', () => {
9696
};
9797

9898
expect(actionTypeModel.validateParams(actionParams)).toEqual({
99-
errors: { 'subActionParams.incident.summary': [] },
99+
errors: { 'subActionParams.incident.summary': [], 'subActionParams.incident.labels': [] },
100100
});
101101
});
102102

@@ -108,6 +108,23 @@ describe('jira action params validation', () => {
108108
expect(actionTypeModel.validateParams(actionParams)).toEqual({
109109
errors: {
110110
'subActionParams.incident.summary': ['Summary is required.'],
111+
'subActionParams.incident.labels': [],
112+
},
113+
});
114+
});
115+
116+
test('params validation fails when labels contain spaces', () => {
117+
const actionParams = {
118+
subActionParams: {
119+
incident: { summary: 'some title', labels: ['label with spaces'] },
120+
comments: [],
121+
},
122+
};
123+
124+
expect(actionTypeModel.validateParams(actionParams)).toEqual({
125+
errors: {
126+
'subActionParams.incident.summary': [],
127+
'subActionParams.incident.labels': ['Labels cannot contain spaces.'],
111128
},
112129
});
113130
});

x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/jira.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,34 @@ export default function jiraTest({ getService }: FtrProviderContext) {
375375
});
376376
});
377377
});
378+
379+
it('should handle failing with a simulated success when labels containing a space', async () => {
380+
await supertest
381+
.post(`/api/actions/action/${simulatedActionId}/_execute`)
382+
.set('kbn-xsrf', 'foo')
383+
.send({
384+
params: {
385+
...mockJira.params,
386+
subActionParams: {
387+
incident: {
388+
...mockJira.params.subActionParams.incident,
389+
issueType: '10006',
390+
labels: ['label with spaces'],
391+
},
392+
comments: [],
393+
},
394+
},
395+
})
396+
.then((resp: any) => {
397+
expect(resp.body).to.eql({
398+
actionId: simulatedActionId,
399+
status: 'error',
400+
retry: false,
401+
message:
402+
'error validating action params: types that failed validation:\n- [0.subAction]: expected value to equal [getFields]\n- [1.subAction]: expected value to equal [getIncident]\n- [2.subAction]: expected value to equal [handshake]\n- [3.subActionParams.incident.labels]: types that failed validation:\n - [subActionParams.incident.labels.0.0]: The label label with spaces cannot contain spaces\n - [subActionParams.incident.labels.1]: expected value to equal [null]\n- [4.subAction]: expected value to equal [issueTypes]\n- [5.subAction]: expected value to equal [fieldsByIssueType]\n- [6.subAction]: expected value to equal [issues]\n- [7.subAction]: expected value to equal [issue]',
403+
});
404+
});
405+
});
378406
});
379407

380408
describe('Execution', () => {

0 commit comments

Comments
 (0)