kibana/x-pack/test/functional/apps/spaces/enter_space.ts
Pierre Gayvallet 83abc6e3c0
[uiSettings] always use the latest config document to create the new one (#159649)
## Summary

Fix https://github.com/elastic/kibana/issues/159646

Fix the config creation-from-previous-one logic by always using the
latest config for the new version's creation


## Release Note

Fix a bug that could cause old Kibana deployments to loose their
uiSettings after an upgrade

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-06-19 00:09:27 -07:00

85 lines
2.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 { stripVersionQualifier } from '@kbn/std';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function enterSpaceFunctionalTests({
getService,
getPageObjects,
}: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['security', 'spaceSelector']);
const spacesService = getService('spaces');
describe('Enter Space', function () {
this.tags('includeFirefox');
before(async () => {
await spacesService.create({
id: 'another-space',
name: 'Another Space',
disabledFeatures: [],
});
await kibanaServer.uiSettings.replace(
{
defaultRoute: '/app/canvas',
buildNum: 8467,
'dateFormat:tz': 'UTC',
},
{ space: 'another-space' }
);
const config = await kibanaServer.savedObjects.get({
id: stripVersionQualifier(await kibanaServer.version.get()),
type: 'config',
});
await kibanaServer.savedObjects.update({
id: config.id,
type: config.type,
attributes: { defaultRoute: 'http://example.com/evil' },
});
await PageObjects.security.forceLogout();
});
after(async () => {
await spacesService.delete('another-space');
await kibanaServer.savedObjects.cleanStandardList();
});
afterEach(async () => {
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
await PageObjects.security.forceLogout();
});
it('falls back to the default home page when the configured default route is malformed', async () => {
const spaceId = 'default';
await PageObjects.security.login(undefined, undefined, {
expectSpaceSelector: true,
});
await PageObjects.spaceSelector.clickSpaceCard(spaceId);
await PageObjects.spaceSelector.expectHomePage(spaceId);
});
it('allows user to navigate to different spaces, respecting the configured default route', async () => {
const spaceId = 'another-space';
await PageObjects.security.login(undefined, undefined, {
expectSpaceSelector: true,
});
await PageObjects.spaceSelector.clickSpaceCard(spaceId);
await PageObjects.spaceSelector.expectRoute(spaceId, '/app/canvas');
await PageObjects.spaceSelector.openSpacesNav();
// change spaces
const newSpaceId = 'default';
await PageObjects.spaceSelector.clickSpaceAvatar(newSpaceId);
await PageObjects.spaceSelector.expectHomePage(newSpaceId);
});
});
}