mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
* Don't save the current timezone in visualizations (#34795) * Don't save the current timezone in visualizations * Add additional test * Add test and switch migration number * Don't clone object according to review feedback * Better documentation * Update src/legacy/core_plugins/kibana/migrations.js Co-Authored-By: timroes <mail@timroes.de> * Fix migrationVersion in integration tests * Fix tests * Fix migrationVersion in tests * Fix more tests
97 lines
3.4 KiB
JavaScript
97 lines
3.4 KiB
JavaScript
/*
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
* license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
* not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
import expect from 'expect.js';
|
|
|
|
export default function ({ getService }) {
|
|
const supertest = getService('supertest');
|
|
const es = getService('es');
|
|
const esArchiver = getService('esArchiver');
|
|
|
|
describe('get', () => {
|
|
describe('with kibana index', () => {
|
|
before(() => esArchiver.load('saved_objects/basic'));
|
|
after(() => esArchiver.unload('saved_objects/basic'));
|
|
|
|
it('should return 200', async () => (
|
|
await supertest
|
|
.get(`/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab`)
|
|
.expect(200)
|
|
.then(resp => {
|
|
expect(resp.body).to.eql({
|
|
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
migrationVersion: {
|
|
visualization: '6.7.2',
|
|
},
|
|
type: 'visualization',
|
|
updated_at: '2017-09-21T18:51:23.794Z',
|
|
version: resp.body.version,
|
|
attributes: {
|
|
title: 'Count of requests',
|
|
description: '',
|
|
version: 1,
|
|
// cheat for some of the more complex attributes
|
|
visState: resp.body.attributes.visState,
|
|
uiStateJSON: resp.body.attributes.uiStateJSON,
|
|
kibanaSavedObjectMeta: resp.body.attributes.kibanaSavedObjectMeta
|
|
}
|
|
});
|
|
})
|
|
));
|
|
|
|
describe('doc does not exist', () => {
|
|
it('should return same generic error as when index does not exist', async () => (
|
|
await supertest
|
|
.get(`/api/saved_objects/visualization/foobar`)
|
|
.expect(404)
|
|
.then(resp => {
|
|
expect(resp.body).to.eql({
|
|
error: 'Not Found',
|
|
message: 'Saved object [visualization/foobar] not found',
|
|
statusCode: 404,
|
|
});
|
|
})
|
|
));
|
|
});
|
|
});
|
|
|
|
describe('without kibana index', () => {
|
|
before(async () => (
|
|
// just in case the kibana server has recreated it
|
|
await es.indices.delete({
|
|
index: '.kibana',
|
|
ignore: [404],
|
|
})
|
|
));
|
|
|
|
it('should return basic 404 without mentioning index', async () => (
|
|
await supertest
|
|
.get('/api/saved_objects/visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab')
|
|
.expect(404)
|
|
.then(resp => {
|
|
expect(resp.body).to.eql({
|
|
error: 'Not Found',
|
|
message: 'Saved object [visualization/dd7caf20-9efd-11e7-acb3-3dab96693fab] not found',
|
|
statusCode: 404,
|
|
});
|
|
})
|
|
));
|
|
});
|
|
});
|
|
}
|