From 85fcda43dce4e9ab4b637fcadfafa5a64ce4f00d Mon Sep 17 00:00:00 2001 From: Tre' Seymour Date: Wed, 6 Jul 2022 10:33:59 +0100 Subject: [PATCH 1/2] [Archive Migration] x-pack-banners/multispace I've the before() fn loading the new kbn archive containing one config, for the default space. Then, the fn creates a new space and changes the ui settings of this new space, w/o using an archive. --- .../test/banners_functional/tests/spaces.ts | 23 +- .../es_archives/banners/multispace/data.json | 62 ----- .../banners/multispace/mappings.json | 248 ------------------ .../kbn_archiver/banners/multispace.json | 15 ++ 4 files changed, 35 insertions(+), 313 deletions(-) delete mode 100644 x-pack/test/functional/es_archives/banners/multispace/data.json delete mode 100644 x-pack/test/functional/es_archives/banners/multispace/mappings.json create mode 100644 x-pack/test/functional/fixtures/kbn_archiver/banners/multispace.json diff --git a/x-pack/test/banners_functional/tests/spaces.ts b/x-pack/test/banners_functional/tests/spaces.ts index f6e2fbf544557..e793cad89c4da 100644 --- a/x-pack/test/banners_functional/tests/spaces.ts +++ b/x-pack/test/banners_functional/tests/spaces.ts @@ -9,7 +9,8 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); + const spacesService = getService('spaces'); + const kibanaServer = getService('kibanaServer'); const PageObjects = getPageObjects([ 'common', 'security', @@ -20,11 +21,27 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('per-spaces banners', () => { before(async () => { - await esArchiver.load('x-pack/test/functional/es_archives/banners/multispace'); + await kibanaServer.importExport.load( + 'x-pack/test/functional/fixtures/kbn_archiver/banners/multispace' + ); + 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' } + ); }); after(async () => { - await esArchiver.unload('x-pack/test/functional/es_archives/banners/multispace'); + await spacesService.delete('another-space'); + await kibanaServer.savedObjects.cleanStandardList(); }); before(async () => { diff --git a/x-pack/test/functional/es_archives/banners/multispace/data.json b/x-pack/test/functional/es_archives/banners/multispace/data.json deleted file mode 100644 index fc0e0dc7b7eee..0000000000000 --- a/x-pack/test/functional/es_archives/banners/multispace/data.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "type": "doc", - "value": { - "id": "config:6.0.0", - "index": ".kibana", - "source": { - "config": { - "buildNum": 8467, - "dateFormat:tz": "UTC", - "defaultRoute": "http://example.com/evil" - }, - "type": "config" - } - } -} - -{ - "type": "doc", - "value": { - "id": "another-space:config:6.0.0", - "index": ".kibana", - "source": { - "namespace": "another-space", - "config": { - "buildNum": 8467, - "dateFormat:tz": "UTC", - "defaultRoute": "/app/canvas" - }, - "type": "config" - } - } -} - -{ - "type": "doc", - "value": { - "id": "space:default", - "index": ".kibana", - "source": { - "space": { - "description": "This is the default space!", - "name": "Default" - }, - "type": "space" - } - } -} - -{ - "type": "doc", - "value": { - "id": "space:another-space", - "index": ".kibana", - "source": { - "space": { - "description": "This is another space", - "name": "Another Space" - }, - "type": "space" - } - } -} diff --git a/x-pack/test/functional/es_archives/banners/multispace/mappings.json b/x-pack/test/functional/es_archives/banners/multispace/mappings.json deleted file mode 100644 index f813fca64c328..0000000000000 --- a/x-pack/test/functional/es_archives/banners/multispace/mappings.json +++ /dev/null @@ -1,248 +0,0 @@ -{ - "type": "index", - "value": { - "aliases": { - ".kibana": {} - }, - "index": ".kibana_1", - "mappings": { - "properties": { - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultRoute": { - "type": "keyword" - } - } - }, - "dashboard": { - "dynamic": "strict", - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "index-pattern": { - "dynamic": "strict", - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - } - } - }, - "search": { - "dynamic": "strict", - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "dynamic": "strict", - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "spaceId": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "url": { - "dynamic": "strict", - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "dynamic": "strict", - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchId": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "number_of_replicas": "1", - "number_of_shards": "1" - } - } - } -} diff --git a/x-pack/test/functional/fixtures/kbn_archiver/banners/multispace.json b/x-pack/test/functional/fixtures/kbn_archiver/banners/multispace.json new file mode 100644 index 0000000000000..bea7c21c10157 --- /dev/null +++ b/x-pack/test/functional/fixtures/kbn_archiver/banners/multispace.json @@ -0,0 +1,15 @@ +{ + "attributes": { + "buildNum": 8467, + "dateFormat:tz": "UTC", + "defaultRoute": "http://example.com/evil" + }, + "coreMigrationVersion": "8.4.0", + "id": "6.0.0", + "migrationVersion": { + "config": "8.1.0" + }, + "references": [], + "type": "config", + "version": "WzMsMl0=" +} \ No newline at end of file From 4cd6de0335b251720d3acb874553e1bf2c3a0f47 Mon Sep 17 00:00:00 2001 From: Lee Drengenberg Date: Fri, 8 Jul 2022 10:16:46 -0500 Subject: [PATCH 2/2] WIP changes to almost make tests pass --- test/functional/page_objects/settings_page.ts | 5 ++ .../test/banners_functional/tests/spaces.ts | 47 ++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/test/functional/page_objects/settings_page.ts b/test/functional/page_objects/settings_page.ts index 0d6549b2e46b3..d4ea2a2aec523 100644 --- a/test/functional/page_objects/settings_page.ts +++ b/test/functional/page_objects/settings_page.ts @@ -122,6 +122,7 @@ export class SettingsPageObject extends FtrService { const wrapper = await this.testSubjects.find(`advancedSetting-editField-${propertyName}`); const textarea = await wrapper.findByTagName('textarea'); await textarea.focus(); + await this.common.sleep(2000); // only way to properly replace the value of the ace editor is via the JS api await this.browser.execute( (editor: string, value: string) => { @@ -130,7 +131,11 @@ export class SettingsPageObject extends FtrService { `advancedSetting-editField-${propertyName}-editor`, propertyValue ); + await textarea.focus(); + await textarea.type(this.browser.keys.RETURN); + await this.common.sleep(20000); await this.testSubjects.click(`advancedSetting-saveButton`); + await this.common.sleep(20000); await this.header.waitUntilLoadingHasFinished(); } diff --git a/x-pack/test/banners_functional/tests/spaces.ts b/x-pack/test/banners_functional/tests/spaces.ts index e793cad89c4da..f2a559da98c51 100644 --- a/x-pack/test/banners_functional/tests/spaces.ts +++ b/x-pack/test/banners_functional/tests/spaces.ts @@ -19,44 +19,47 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { 'spaceSelector', ]); - describe('per-spaces banners', () => { + describe.only('per-spaces banners', () => { before(async () => { - await kibanaServer.importExport.load( - 'x-pack/test/functional/fixtures/kbn_archiver/banners/multispace' - ); + // await kibanaServer.importExport.load( + // 'x-pack/test/functional/fixtures/kbn_archiver/banners/multispace' + // ); 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' } + // ); await kibanaServer.uiSettings.replace( { - defaultRoute: '/app/canvas', - buildNum: 8467, - 'dateFormat:tz': 'UTC', + 'banners:textContent': 'default space banner text', }, - { space: 'another-space' } + { space: 'default' } ); - }); - - after(async () => { - await spacesService.delete('another-space'); - await kibanaServer.savedObjects.cleanStandardList(); - }); - - before(async () => { await PageObjects.security.login(undefined, undefined, { expectSpaceSelector: true, }); await PageObjects.spaceSelector.clickSpaceCard('default'); - await PageObjects.settings.navigateTo(); - await PageObjects.settings.clickKibanaSettings(); + // await PageObjects.settings.navigateTo(); + // await PageObjects.settings.clickKibanaSettings(); - await PageObjects.settings.setAdvancedSettingsTextArea( - 'banners:textContent', - 'default space banner text' - ); + // await PageObjects.settings.setAdvancedSettingsTextArea( + // 'banners:textContent', + // 'default space banner text' + // ); + }); + + after(async () => { + await spacesService.delete('another-space'); + await kibanaServer.savedObjects.cleanStandardList(); }); it('displays the space-specific banner within the space', async () => {