Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"siem-ui-timeline": "e9d6b3a9fd7af6dc502293c21cbdb309409f3996",
"siem-ui-timeline-note": "13c9d4c142f96624a93a623c6d7cba7e1ae9b5a6",
"siem-ui-timeline-pinned-event": "96a43d59b9e2fc11f12255a0cb47ef0a3d83af4c",
"slo": "ee0e16abebba5779c37277bc3fe8da1fe1207b7a",
"slo": "aefffabdb35d15a6c388634af2cee1fa59ede83c",
"space": "7fc578a1f9f7708cb07479f03953d664ad9f1dae",
"spaces-usage-stats": "084bd0f080f94fb5735d7f3cf12f13ec92f36bad",
"synthetics-monitor": "96cc312bfa597022f83dfb3b5d1501e27a73e8d5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { createRoot } from '@kbn/core-test-helpers-kbn-server';

describe('SO default search fields', () => {
let root: ReturnType<typeof createRoot>;

afterEach(() => {
try {
root?.shutdown();
} catch (e) {
/* trap */
}
});

interface InvalidMappingTuple {
type: string;
field: string;
}

// identify / avoid scenarios of https://github.com/elastic/kibana/issues/130616
it('make sure management types have the correct mappings for default search fields', async () => {
root = createRoot({}, { oss: false });
await root.preboot();
const setup = await root.setup();

const allTypes = setup.savedObjects.getTypeRegistry().getAllTypes();

const defaultSearchFields = [
...allTypes.reduce((fieldSet, type) => {
if (type.management?.defaultSearchField) {
fieldSet.add(type.management.defaultSearchField);
}
return fieldSet;
}, new Set<string>()),
];

const invalidMappings: InvalidMappingTuple[] = [];

const managementTypes = setup.savedObjects
.getTypeRegistry()
.getImportableAndExportableTypes()
.filter((type) => type.management!.visibleInManagement ?? true);

managementTypes.forEach((type) => {
const mappingProps = type.mappings.properties;
defaultSearchFields.forEach((searchField) => {
if (mappingProps[searchField]) {
const fieldDef = mappingProps[searchField];
if (fieldDef.type !== 'text') {
invalidMappings.push({
type: type.name,
field: searchField,
});
}
}
});
});

if (invalidMappings.length > 0) {
// `fail()` no longer exists...
expect(
`fields registered as defaultSearchField by any type must be registered as text. Invalid mappings found: ${JSON.stringify(
invalidMappings
)}`
).toEqual('');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,18 @@ const previouslyRegisteredTypes = [
].sort();

describe('SO type registrations', () => {
let root: ReturnType<typeof createRoot>;

afterEach(() => {
try {
root?.shutdown();
} catch (e) {
/* trap */
}
});

it('does not remove types from registrations without updating excludeOnUpgradeQuery', async () => {
const root = createRoot({}, { oss: false });
root = createRoot({}, { oss: false });
await root.preboot();
const setup = await root.setup();
const currentlyRegisteredTypes = setup.savedObjects
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/observability/server/saved_objects/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const slo: SavedObjectsType = {
dynamic: false,
properties: {
id: { type: 'keyword' },
name: { type: 'keyword' },
name: { type: 'text' },
description: { type: 'text' },
indicator: {
properties: {
Expand Down