mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
minimize number of so fild asserted in tests. it creates flakines when implementation details change (#97374)
This commit is contained in:
parent
c187270b5e
commit
6c7d776fc1
3 changed files with 36 additions and 210 deletions
|
@ -9,7 +9,6 @@
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||||
import { SavedObject } from '../../../../src/core/server';
|
import { SavedObject } from '../../../../src/core/server';
|
||||||
import { getKibanaVersion } from './lib/saved_objects_test_utils';
|
|
||||||
|
|
||||||
export default function ({ getService }: FtrProviderContext) {
|
export default function ({ getService }: FtrProviderContext) {
|
||||||
const supertest = getService('supertest');
|
const supertest = getService('supertest');
|
||||||
|
@ -17,12 +16,6 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
const esDeleteAllIndices = getService('esDeleteAllIndices');
|
const esDeleteAllIndices = getService('esDeleteAllIndices');
|
||||||
|
|
||||||
describe('find', () => {
|
describe('find', () => {
|
||||||
let KIBANA_VERSION: string;
|
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
KIBANA_VERSION = await getKibanaVersion(getService);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('with kibana index', () => {
|
describe('with kibana index', () => {
|
||||||
before(() => esArchiver.load('saved_objects/basic'));
|
before(() => esArchiver.load('saved_objects/basic'));
|
||||||
after(() => esArchiver.unload('saved_objects/basic'));
|
after(() => esArchiver.unload('saved_objects/basic'));
|
||||||
|
@ -32,33 +25,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.get('/api/saved_objects/_find?type=visualization&fields=title')
|
.get('/api/saved_objects/_find?type=visualization&fields=title')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([
|
||||||
page: 1,
|
'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
||||||
per_page: 20,
|
]);
|
||||||
total: 1,
|
|
||||||
saved_objects: [
|
|
||||||
{
|
|
||||||
type: 'visualization',
|
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
version: 'WzE4LDJd',
|
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
},
|
|
||||||
score: 0,
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
namespaces: ['default'],
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
expect(resp.body.saved_objects[0].migrationVersion).to.be.ok();
|
expect(resp.body.saved_objects[0].migrationVersion).to.be.ok();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -129,33 +98,12 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=default')
|
.get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=default')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(
|
||||||
page: 1,
|
resp.body.saved_objects.map((so: { id: string; namespaces: string[] }) => ({
|
||||||
per_page: 20,
|
id: so.id,
|
||||||
total: 1,
|
namespaces: so.namespaces,
|
||||||
saved_objects: [
|
}))
|
||||||
{
|
).to.eql([{ id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['default'] }]);
|
||||||
type: 'visualization',
|
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
version: 'WzE4LDJd',
|
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
},
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
namespaces: ['default'],
|
|
||||||
score: 0,
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
expect(resp.body.saved_objects[0].migrationVersion).to.be.ok();
|
expect(resp.body.saved_objects[0].migrationVersion).to.be.ok();
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -166,53 +114,15 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=*')
|
.get('/api/saved_objects/_find?type=visualization&fields=title&namespaces=*')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(
|
||||||
page: 1,
|
resp.body.saved_objects.map((so: { id: string; namespaces: string[] }) => ({
|
||||||
per_page: 20,
|
id: so.id,
|
||||||
total: 2,
|
namespaces: so.namespaces,
|
||||||
saved_objects: [
|
}))
|
||||||
{
|
).to.eql([
|
||||||
type: 'visualization',
|
{ id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['default'] },
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
{ id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', namespaces: ['foo-ns'] },
|
||||||
version: 'WzE4LDJd',
|
]);
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
},
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
namespaces: ['default'],
|
|
||||||
score: 0,
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
},
|
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
namespaces: ['foo-ns'],
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
score: 0,
|
|
||||||
type: 'visualization',
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
version: 'WzIyLDJd',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -224,42 +134,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
)
|
)
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([
|
||||||
page: 1,
|
'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
||||||
per_page: 20,
|
]);
|
||||||
total: 1,
|
|
||||||
saved_objects: [
|
|
||||||
{
|
|
||||||
type: 'visualization',
|
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
visState: resp.body.saved_objects[0].attributes.visState,
|
|
||||||
uiStateJSON: '{"spy":{"mode":{"name":null,"fill":false}}}',
|
|
||||||
description: '',
|
|
||||||
version: 1,
|
|
||||||
kibanaSavedObjectMeta: {
|
|
||||||
searchSourceJSON:
|
|
||||||
resp.body.saved_objects[0].attributes.kibanaSavedObjectMeta
|
|
||||||
.searchSourceJSON,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
namespaces: ['default'],
|
|
||||||
score: 0,
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
version: 'WzE4LDJd',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('wrong type should return 400 with Bad Request', async () =>
|
it('wrong type should return 400 with Bad Request', async () =>
|
||||||
|
|
|
@ -34,44 +34,9 @@ export default function ({ getService }: FtrProviderContext) {
|
||||||
.get('/api/kibana/management/saved_objects/_find?type=visualization&fields=title')
|
.get('/api/kibana/management/saved_objects/_find?type=visualization&fields=title')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp: Response) => {
|
.then((resp: Response) => {
|
||||||
expect(resp.body).to.eql({
|
expect(resp.body.saved_objects.map((so: { id: string }) => so.id)).to.eql([
|
||||||
page: 1,
|
'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
||||||
per_page: 20,
|
]);
|
||||||
total: 1,
|
|
||||||
saved_objects: [
|
|
||||||
{
|
|
||||||
type: 'visualization',
|
|
||||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
version: 'WzE4LDJd',
|
|
||||||
attributes: {
|
|
||||||
title: 'Count of requests',
|
|
||||||
},
|
|
||||||
migrationVersion: resp.body.saved_objects[0].migrationVersion,
|
|
||||||
coreMigrationVersion: KIBANA_VERSION,
|
|
||||||
namespaces: ['default'],
|
|
||||||
references: [
|
|
||||||
{
|
|
||||||
id: '91200a00-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
|
|
||||||
type: 'index-pattern',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
score: 0,
|
|
||||||
updated_at: '2017-09-21T18:51:23.794Z',
|
|
||||||
meta: {
|
|
||||||
editUrl:
|
|
||||||
'/management/kibana/objects/savedVisualizations/dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
icon: 'visualizeApp',
|
|
||||||
inAppUrl: {
|
|
||||||
path: '/app/visualize#/edit/dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
|
||||||
uiCapabilitiesPath: 'visualize.show',
|
|
||||||
},
|
|
||||||
title: 'Count of requests',
|
|
||||||
namespaceType: 'single',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('unknown type', () => {
|
describe('unknown type', () => {
|
||||||
|
|
|
@ -33,28 +33,17 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
|
||||||
.set('kbn-xsrf', 'true')
|
.set('kbn-xsrf', 'true')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(
|
||||||
page: 1,
|
resp.body.saved_objects.map((so: { id: string; type: string }) => ({
|
||||||
per_page: 20,
|
id: so.id,
|
||||||
total: 1,
|
type: so.type,
|
||||||
saved_objects: [
|
}))
|
||||||
|
).to.eql([
|
||||||
{
|
{
|
||||||
type: 'test-hidden-importable-exportable',
|
type: 'test-hidden-importable-exportable',
|
||||||
id: 'ff3733a0-9fty-11e7-ahb3-3dcb94193fab',
|
id: 'ff3733a0-9fty-11e7-ahb3-3dcb94193fab',
|
||||||
attributes: {
|
|
||||||
title: 'Hidden Saved object type that is importable/exportable.',
|
|
||||||
},
|
},
|
||||||
references: [],
|
]);
|
||||||
updated_at: '2021-02-11T18:51:23.794Z',
|
|
||||||
version: 'WzIsMl0=',
|
|
||||||
namespaces: ['default'],
|
|
||||||
score: 0,
|
|
||||||
meta: {
|
|
||||||
namespaceType: 'single',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('returns empty response for non importableAndExportable types', async () =>
|
it('returns empty response for non importableAndExportable types', async () =>
|
||||||
|
@ -65,12 +54,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
|
||||||
.set('kbn-xsrf', 'true')
|
.set('kbn-xsrf', 'true')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
expect(resp.body).to.eql({
|
expect(resp.body.saved_objects).to.eql([]);
|
||||||
page: 1,
|
|
||||||
per_page: 20,
|
|
||||||
total: 0,
|
|
||||||
saved_objects: [],
|
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue