Skip to content

Commit

Permalink
Improve intergration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Mar 18, 2020
1 parent e08ab39 commit 2651848
Showing 1 changed file with 110 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) {
title: 'a title',
description: 'a description',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: null },
createdBy: { fullName: 'Elastic User', username: 'elastic' },
updatedAt: null,
updatedBy: null,
incidentId: null,
Expand All @@ -63,7 +63,7 @@ export default function servicenowTest({ getService }: FtrProviderContext) {
version: 'WzU3LDFd',
comment: 'first comment',
createdAt: '2020-03-13T08:34:53.450Z',
createdBy: { fullName: 'Elastic User', username: null },
createdBy: { fullName: 'Elastic User', username: 'elastic' },
updatedAt: null,
updatedBy: null,
},
Expand Down Expand Up @@ -315,5 +315,113 @@ export default function servicenowTest({ getService }: FtrProviderContext) {
});
});
});

it('should handle failing with a simulated success without title', async () => {
await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: { caseId: 'success' },
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'error validating action params: [title]: expected value of type [string] but got [undefined]',
});
});
});

it('should handle failing with a simulated success without createdAt', async () => {
await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: { caseId: 'success', title: 'success' },
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'error validating action params: [createdAt]: expected value of type [string] but got [undefined]',
});
});
});

it('should handle failing with a simulated success without commentId', async () => {
await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: {
caseId: 'success',
title: 'success',
createdAt: 'success',
createdBy: { username: 'elastic' },
comments: [{}],
},
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'error validating action params: [comments.0.commentId]: expected value of type [string] but got [undefined]',
});
});
});

it('should handle failing with a simulated success without comment message', async () => {
await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: {
caseId: 'success',
title: 'success',
createdAt: 'success',
createdBy: { username: 'elastic' },
comments: [{ commentId: 'success' }],
},
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'error validating action params: [comments.0.comment]: expected value of type [string] but got [undefined]',
});
});
});

it('should handle failing with a simulated success without comment.createdAt', async () => {
await supertest
.post(`/api/action/${simulatedActionId}/_execute`)
.set('kbn-xsrf', 'foo')
.send({
params: {
caseId: 'success',
title: 'success',
createdAt: 'success',
createdBy: { username: 'elastic' },
comments: [{ commentId: 'success', comment: 'success' }],
},
})
.then((resp: any) => {
expect(resp.body).to.eql({
actionId: simulatedActionId,
status: 'error',
retry: false,
message:
'error validating action params: [comments.0.createdAt]: expected value of type [string] but got [undefined]',
});
});
});
});
}

0 comments on commit 2651848

Please sign in to comment.