-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes lint issue and adds a base read_lists end to end test
- Loading branch information
1 parent
7d1d940
commit 55bc2ad
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
x-pack/test/lists_api_integration/security_and_spaces/tests/read_lists.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../common/ftr_provider_context'; | ||
import { LIST_URL } from '../../../../plugins/lists/common/constants'; | ||
|
||
import { | ||
getCreateMinimalListSchemaMock, | ||
getCreateMinimalListSchemaMockWithoutId, | ||
} from '../../../../plugins/lists/common/schemas/request/create_list_schema.mock'; | ||
import { createListsIndex, deleteListsIndex, removeServerGeneratedProperties } from '../../utils'; | ||
import { getListResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_schema.mock'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default ({ getService }: FtrProviderContext) => { | ||
const supertest = getService('supertest'); | ||
|
||
describe('read_lists', () => { | ||
describe('reading lists', () => { | ||
beforeEach(async () => { | ||
await createListsIndex(supertest); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteListsIndex(supertest); | ||
}); | ||
|
||
it('should be able to read a single list using id', async () => { | ||
// create a simple list to read | ||
await supertest | ||
.post(LIST_URL) | ||
.set('kbn-xsrf', 'true') | ||
.send(getCreateMinimalListSchemaMock()) | ||
.expect(200); | ||
|
||
const { body } = await supertest | ||
.get(`${LIST_URL}?id=some-list-id`) | ||
.set('kbn-xsrf', 'true') | ||
.send(getCreateMinimalListSchemaMock()) | ||
.expect(200); | ||
|
||
const bodyToCompare = removeServerGeneratedProperties(body); | ||
expect(bodyToCompare).to.eql(getListResponseMockWithoutAutoGeneratedValues()); | ||
}); | ||
|
||
it('should be able to read a single list with an auto-generated list id', async () => { | ||
// create a simple list to read | ||
const { body: createListBody } = await supertest | ||
.post(LIST_URL) | ||
.set('kbn-xsrf', 'true') | ||
.send(getCreateMinimalListSchemaMockWithoutId()) | ||
.expect(200); | ||
|
||
const { body } = await supertest | ||
.get(`${LIST_URL}?id=${createListBody.id}`) | ||
.set('kbn-xsrf', 'true') | ||
.send(getCreateMinimalListSchemaMock()) | ||
.expect(200); | ||
|
||
const bodyToCompare = removeServerGeneratedProperties(body); | ||
expect(bodyToCompare).to.eql(getListResponseMockWithoutAutoGeneratedValues()); | ||
}); | ||
|
||
it('should return 404 if given a fake id', async () => { | ||
const { body } = await supertest | ||
.get(`${LIST_URL}?id=c1e1b359-7ac1-4e96-bc81-c683c092436f`) | ||
.set('kbn-xsrf', 'true') | ||
.expect(404); | ||
|
||
expect(body).to.eql({ | ||
status_code: 404, | ||
message: 'list id: "c1e1b359-7ac1-4e96-bc81-c683c092436f" does not exist', | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters