mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
* make space a hidden saved object type * bulk_create api tests * bulk_get tests * create functional tests * delete space tests * export space tests * find space tests * get space tests * import space tests * resolve_import_errirs space tests * update space tests * standardize test names where appropriate * remove unused import * Switching tests from using the space type directly to a "hidden t… (#21) * add space saved object api tests Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com>
101 lines
3.3 KiB
TypeScript
101 lines
3.3 KiB
TypeScript
/*
|
|
* 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/expect.js';
|
|
import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default function({ getService }: KibanaFunctionalTestDefaultProviders) {
|
|
const supertest = getService('supertest');
|
|
|
|
describe('`space` saved object type', () => {
|
|
describe('GET /api/saved_objects/space/default', () => {
|
|
it('should not return the default space', async () => {
|
|
await supertest
|
|
.get('/api/saved_objects/space/default')
|
|
.set('kbn-xsrf', 'xxx')
|
|
.send()
|
|
.expect(404)
|
|
.then((response: Record<string, any>) => {
|
|
expect(response.body).to.eql({
|
|
message: `Saved object [space/default] not found`,
|
|
statusCode: 404,
|
|
error: 'Not Found',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('GET /api/saved_objects/_find?type=space', () => {
|
|
it('should not locate any spaces', async () => {
|
|
await supertest
|
|
.get('/api/saved_objects/_find?type=space')
|
|
.set('kbn-xsrf', 'xxx')
|
|
.send()
|
|
.expect(200)
|
|
.then((response: Record<string, any>) => {
|
|
expect(response.body).to.eql({
|
|
page: 1,
|
|
per_page: 20,
|
|
total: 0,
|
|
saved_objects: [],
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('POST /api/saved_objects/space/my-space', () => {
|
|
it('should not allow a space to be created', async () => {
|
|
await supertest
|
|
.post('/api/saved_objects/space/my-space')
|
|
.set('kbn-xsrf', 'xxx')
|
|
.send({ attributes: {} })
|
|
.expect(400)
|
|
.then((response: Record<string, any>) => {
|
|
expect(response.body).to.eql({
|
|
message: "Unsupported saved object type: 'space': Bad Request",
|
|
statusCode: 400,
|
|
error: 'Bad Request',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('PUT /api/saved_objects/space/default', () => {
|
|
it('should not allow a space to be updated', async () => {
|
|
await supertest
|
|
.post('/api/saved_objects/space/default')
|
|
.set('kbn-xsrf', 'xxx')
|
|
.send({ attributes: {} })
|
|
.expect(400)
|
|
.then((response: Record<string, any>) => {
|
|
expect(response.body).to.eql({
|
|
message: "Unsupported saved object type: 'space': Bad Request",
|
|
statusCode: 400,
|
|
error: 'Bad Request',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('DELETE /api/saved_objects/space/default', () => {
|
|
it('should not allow a space to be deleted', async () => {
|
|
await supertest
|
|
.delete('/api/saved_objects/space/default')
|
|
.set('kbn-xsrf', 'xxx')
|
|
.send()
|
|
.expect(404)
|
|
.then((response: Record<string, any>) => {
|
|
expect(response.body).to.eql({
|
|
message: 'Not Found',
|
|
statusCode: 404,
|
|
error: 'Not Found',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|