Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Dec 4, 2019
1 parent 2485fe7 commit f88be6d
Showing 1 changed file with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,41 @@ export default function createFindTests({ getService }: FtrProviderContext) {
});

it('should handle find alert request with filter appropriately', async () => {
const { body: createdAction } = await supertest
.post(`${getUrlPrefix(space.id)}/api/action`)
.set('kbn-xsrf', 'foo')
.send({
name: 'My action',
actionTypeId: 'test.noop',
config: {},
secrets: {},
})
.expect(200);

const { body: createdAlert } = await supertest
.post(`${getUrlPrefix(space.id)}/api/alert`)
.set('kbn-xsrf', 'foo')
.send(getTestAlertData())
.send(
getTestAlertData({
enabled: false,
actions: [
{
id: createdAction.id,
group: 'default',
actionTypeId: 'test.noop',
params: {},
},
],
})
)
.expect(200);
objectRemover.add(space.id, createdAlert.id, 'alert');

const response = await supertestWithoutAuth
.get(
`${getUrlPrefix(
space.id
)}/api/alert/_find?filter=alert.attributes.alertTypeId:test.noop`
)}/api/alert/_find?filter=alert.attributes.actions:{ actionTypeId: test.noop }`
)
.auth(user.username, user.password);

Expand Down Expand Up @@ -117,11 +140,17 @@ export default function createFindTests({ getService }: FtrProviderContext) {
tags: ['foo'],
alertTypeId: 'test.noop',
interval: '1m',
enabled: true,
actions: [],
enabled: false,
actions: [
{
id: createdAction.id,
group: 'default',
actionTypeId: 'test.noop',
params: {},
},
],
params: {},
createdBy: 'elastic',
scheduledTaskId: match.scheduledTaskId,
throttle: '1m',
updatedBy: 'elastic',
apiKeyOwner: 'elastic',
Expand Down

0 comments on commit f88be6d

Please sign in to comment.