Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Feb 8, 2021
1 parent 2702efb commit ad932e4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('jira action params validation', () => {
};

expect(actionTypeModel.validateParams(actionParams)).toEqual({
errors: { 'subActionParams.incident.summary': [] },
errors: { 'subActionParams.incident.summary': [], 'subActionParams.incident.labels': [] },
});
});

Expand All @@ -108,6 +108,23 @@ describe('jira action params validation', () => {
expect(actionTypeModel.validateParams(actionParams)).toEqual({
errors: {
'subActionParams.incident.summary': ['Summary is required.'],
'subActionParams.incident.labels': [],
},
});
});

test('params validation fails when labels contain spaces', () => {
const actionParams = {
subActionParams: {
incident: { summary: 'some title', labels: ['label with spaces'] },
comments: [],
},
};

expect(actionTypeModel.validateParams(actionParams)).toEqual({
errors: {
'subActionParams.incident.summary': [],
'subActionParams.incident.labels': ['Labels cannot contain spaces.'],
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,34 @@ export default function jiraTest({ getService }: FtrProviderContext) {
});
});
});

it('should handle failing with a simulated success when labels containing a space', async () => {
await supertest
.post(`/api/actions/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: {
...mockJira.params,
subActionParams: {
incident: {
...mockJira.params.subActionParams.incident,
issueType: '10006',
labels: ['label with spaces'],
},
comments: [],
},
},
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'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]',
});
});
});
});

describe('Execution', () => {
Expand Down

0 comments on commit ad932e4

Please sign in to comment.