Skip to content

Commit

Permalink
Add more tests to the fire API
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Jun 21, 2019
1 parent c3211aa commit ad6ad69
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions x-pack/test/api_integration/apis/actions/fire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,41 @@ export default function({ getService }: KibanaFunctionalTestDefaultProviders) {
source: 'action:test.index-record',
});
});

it(`should return 404 when action doesn't exist`, async () => {
await supertest
.post('/api/action/1/_fire')
.set('kbn-xsrf', 'foo')
.send({
params: { foo: true },
})
.expect(404)
.then((resp: any) => {
expect(resp.body).to.eql({
statusCode: 404,
error: 'Not Found',
message: 'Saved object [action/1] not found',
});
});
});

it('should return 400 when payload is empty and invalid', async () => {
await supertest
.post(`/api/action/${ES_ARCHIVER_ACTION_ID}/_fire`)
.set('kbn-xsrf', 'foo')
.send({})
.expect(400)
.then((resp: any) => {
expect(resp.body).to.eql({
statusCode: 400,
error: 'Bad Request',
message: 'child "params" fails because ["params" is required]',
validation: {
source: 'payload',
keys: ['params'],
},
});
});
});
});
}

0 comments on commit ad6ad69

Please sign in to comment.