Skip to content

Commit

Permalink
Add end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Sep 24, 2020
1 parent 7e773e2 commit 410940d
Show file tree
Hide file tree
Showing 4 changed files with 2,659 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ export default function actionsTests({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./builtin_action_types/es_index'));
loadTestFile(require.resolve('./builtin_action_types/webhook'));
loadTestFile(require.resolve('./type_not_enabled'));

// note that this test will destroy existing spaces
loadTestFile(require.resolve('./migrations'));
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { getUrlPrefix } from '../../../common/lib';
import { FtrProviderContext } from '../../../common/ftr_provider_context';

// eslint-disable-next-line import/no-default-export
export default function createGetTests({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('migrations', () => {
before(async () => {
await esArchiver.load('actions');
});

after(async () => {
await esArchiver.unload('actions');
});

it('7.10.0 migrates the `casesConfiguration` to be the `incidentConfiguration` in `config`', async () => {
const response = await supertest.get(
`${getUrlPrefix(``)}/api/actions/action/791a2ab1-784a-46ea-aa68-04c837e5da2d`
);

expect(response.status).to.eql(200);
expect(response.body.config).key('incidentConfiguration');
expect(response.body.config).not.key('casesConfiguration');
expect(response.body.config.incidentConfiguration).to.eql({
mapping: [
{
actionType: 'overwrite',
source: 'title',
target: 'summary',
},
{
actionType: 'overwrite',
source: 'description',
target: 'description',
},
{
actionType: 'append',
source: 'comments',
target: 'comments',
},
],
});
});
});
}
46 changes: 46 additions & 0 deletions x-pack/test/functional/es_archives/actions/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,49 @@
}
}
}

{
"type": "doc",
"value": {
"id": "action:791a2ab1-784a-46ea-aa68-04c837e5da2d",
"index": ".kibana_1",
"source": {
"action": {
"actionTypeId": ".jira",
"config": {
"apiUrl": "http://elastic:changeme@localhost:5620/api/_actions-FTS-external-service-simulators/jira",
"casesConfiguration": {
"mapping": [
{
"actionType": "overwrite",
"source": "title",
"target": "summary"
},
{
"actionType": "overwrite",
"source": "description",
"target": "description"
},
{
"actionType": "append",
"source": "comments",
"target": "comments"
}
]
},
"projectKey": "CK"
},
"name": "A jira action",
"secrets": "gUYVHxyvkY6I6rZrST16PzSBjwuPLzWYIm9Ow6qjJXiCimA1wHGgH1BR5nO/xZJjv9QqIGO3eKDSYsn7K9m39UJv83+oi5P4ZgtFktsFq0Jv6XEFQPFkuVY5sWno7w89CxgxlsTQFpYAJb0Hl0qf/6p6bKKaje48YRqNS5roebNAAribh9AWu80uxIJFWNo="
},
"migrationVersion": {
"alert": "7.10.0"
},
"references": [
],
"type": "action",
"updated_at": "2020-09-24T08:08:23.715Z"
},
"type": "_doc"
}
}
Loading

0 comments on commit 410940d

Please sign in to comment.