mirror of
https://github.com/elastic/kibana.git
synced 2025-04-18 23:21:39 -04:00
## Summary ~**DO NOT MERGE:** depends on https://github.com/elastic/kibana/issues/213468~ This PR reintegrates the work from the `workchat_m1` branch into `main`: - introduces a 4th solution type, `chat`, that will be used for the *WorkChat* project type. - edit things in various platform code to introduce/handle that new project type - add plugins and packages for the workchat app. ### To AppEx reviewers: File change count is scary, but you can safely ignore anything from `xpack/solutions/chat` (given it's solution code), and focus on your owned changes, which are way more reasonable --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Joe McElroy <joseph.mcelroy@elastic.co> Co-authored-by: Rodney Norris <rodney.norris@elastic.co> Co-authored-by: Jedr Blaszyk <jedrazb@gmail.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Meghan Murphy <meghan.murphy@elastic.co>
160 lines
4.8 KiB
TypeScript
160 lines
4.8 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
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { ConfigSchema } from './config';
|
|
import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
|
|
|
|
describe('config schema', () => {
|
|
it('generates proper defaults (no overrides)', () => {
|
|
expect(ConfigSchema.validate({})).toMatchInlineSnapshot(`Object {}`);
|
|
expect(ConfigSchema.validate({}, { serverless: true })).toMatchInlineSnapshot(`Object {}`);
|
|
});
|
|
|
|
it('does not allow overrides in non-serverless', () => {
|
|
expect(() =>
|
|
ConfigSchema.validate(
|
|
{ overrides: { featureA: { name: 'new name' } } },
|
|
{ serverless: false }
|
|
)
|
|
).toThrowErrorMatchingInlineSnapshot(`"[overrides]: a value wasn't expected to be present"`);
|
|
expect(
|
|
ConfigSchema.validate({ overrides: { featureA: { name: 'new name' } } }, { serverless: true })
|
|
).toMatchInlineSnapshot(`
|
|
Object {
|
|
"overrides": Object {
|
|
"featureA": Object {
|
|
"name": "new name",
|
|
},
|
|
},
|
|
}
|
|
`);
|
|
});
|
|
|
|
it('can override feature properties', () => {
|
|
expect(
|
|
ConfigSchema.validate(
|
|
{
|
|
overrides: {
|
|
featureA: { name: 'new name', hidden: true },
|
|
featureB: {
|
|
order: 100,
|
|
category: 'management',
|
|
privileges: {
|
|
all: {
|
|
disabled: true,
|
|
},
|
|
read: {
|
|
composedOf: [{ feature: 'featureC', privileges: ['all', 'read'] }],
|
|
},
|
|
},
|
|
},
|
|
featureC: {
|
|
subFeatures: {
|
|
privileges: {
|
|
subOne: {
|
|
disabled: true,
|
|
includeIn: 'all',
|
|
},
|
|
subTwo: {
|
|
includeIn: 'none',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{ serverless: true }
|
|
)
|
|
).toMatchInlineSnapshot(`
|
|
Object {
|
|
"overrides": Object {
|
|
"featureA": Object {
|
|
"hidden": true,
|
|
"name": "new name",
|
|
},
|
|
"featureB": Object {
|
|
"category": "management",
|
|
"order": 100,
|
|
"privileges": Object {
|
|
"all": Object {
|
|
"disabled": true,
|
|
},
|
|
"read": Object {
|
|
"composedOf": Array [
|
|
Object {
|
|
"feature": "featureC",
|
|
"privileges": Array [
|
|
"all",
|
|
"read",
|
|
],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
"featureC": Object {
|
|
"subFeatures": Object {
|
|
"privileges": Object {
|
|
"subOne": Object {
|
|
"disabled": true,
|
|
"includeIn": "all",
|
|
},
|
|
"subTwo": Object {
|
|
"includeIn": "none",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
`);
|
|
});
|
|
|
|
it('properly validates category override', () => {
|
|
for (const category of Object.keys(DEFAULT_APP_CATEGORIES)) {
|
|
expect(
|
|
ConfigSchema.validate({ overrides: { featureA: { category } } }, { serverless: true })
|
|
.overrides?.featureA.category
|
|
).toBe(category);
|
|
}
|
|
|
|
expect(() =>
|
|
ConfigSchema.validate(
|
|
{ overrides: { featureA: { category: 'unknown' } } },
|
|
{ serverless: true }
|
|
)
|
|
).toThrowErrorMatchingInlineSnapshot(
|
|
`"[overrides.featureA.category]: Unknown category \\"unknown\\". Should be one of kibana, enterpriseSearch, observability, security, chat, management"`
|
|
);
|
|
});
|
|
it('properly validates sub-feature privilege inclusion override', () => {
|
|
for (const includeIn of ['all', 'read', 'none']) {
|
|
expect(
|
|
ConfigSchema.validate(
|
|
{ overrides: { featureA: { subFeatures: { privileges: { subOne: { includeIn } } } } } },
|
|
{ serverless: true }
|
|
).overrides?.featureA.subFeatures?.privileges.subOne.includeIn
|
|
).toBe(includeIn);
|
|
}
|
|
|
|
expect(() =>
|
|
ConfigSchema.validate(
|
|
{
|
|
overrides: {
|
|
featureA: { subFeatures: { privileges: { subOne: { includeIn: 'write' } } } },
|
|
},
|
|
},
|
|
{ serverless: true }
|
|
)
|
|
).toThrowErrorMatchingInlineSnapshot(`
|
|
"[overrides.featureA.subFeatures.privileges.subOne.includeIn]: types that failed validation:
|
|
- [includeIn.0]: expected value to equal [all]
|
|
- [includeIn.1]: expected value to equal [read]
|
|
- [includeIn.2]: expected value to equal [none]"
|
|
`);
|
|
});
|
|
});
|