diff --git a/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts b/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts index 4991aa5f36ee1..7e057da66b764 100644 --- a/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts +++ b/test/functional/apps/discover/context_awareness/extensions/_get_default_app_state.ts @@ -11,19 +11,29 @@ import kbnRison from '@kbn/rison'; import type { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'unifiedFieldList']); + const PageObjects = getPageObjects(['common', 'discover', 'unifiedFieldList', 'header']); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); const queryBar = getService('queryBar'); const monacoEditor = getService('monacoEditor'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); + const retry = getService('retry'); describe('extension getDefaultAppState', () => { afterEach(async () => { await kibanaServer.uiSettings.unset('defaultColumns'); }); + async function expectColumns(columns: string[]) { + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await retry.try(async () => { + const actualColumns = await PageObjects.discover.getColumnHeaders(); + expect(actualColumns).to.eql(columns); + }); + } + describe('ES|QL mode', () => { it('should render default columns and row height', async () => { const state = kbnRison.encode({ @@ -35,9 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); const rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -55,9 +63,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -65,9 +71,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(rowHeightNumber).to.be(3); await monacoEditor.setCodeEditorValue('from my-example-logs'); await queryBar.clickQuerySubmitButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -88,16 +92,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Single'); await testSubjects.click('discoverNewButton'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -118,9 +119,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message', 'data_stream.type']); + await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); }); }); @@ -130,9 +129,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); const rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -145,18 +142,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); let rowHeightNumber = await dataGrid.getCustomRowHeightNumber(); expect(rowHeightNumber).to.be(3); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -172,16 +165,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Single'); await testSubjects.click('discoverNewButton'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -197,9 +187,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message', 'data_stream.type']); + await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); }); }); }); diff --git a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_default_app_state.ts b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_default_app_state.ts index c99f556b2f52d..7203793330590 100644 --- a/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_default_app_state.ts +++ b/x-pack/test_serverless/functional/test_suites/common/discover/context_awareness/extensions/_get_default_app_state.ts @@ -10,13 +10,20 @@ import kbnRison from '@kbn/rison'; import type { FtrProviderContext } from '../../../../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'discover', 'svlCommonPage', 'unifiedFieldList']); + const PageObjects = getPageObjects([ + 'common', + 'discover', + 'svlCommonPage', + 'unifiedFieldList', + 'header', + ]); const dataViews = getService('dataViews'); const dataGrid = getService('dataGrid'); const queryBar = getService('queryBar'); const monacoEditor = getService('monacoEditor'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); + const retry = getService('retry'); describe('extension getDefaultAppState', () => { before(async () => { @@ -27,6 +34,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await kibanaServer.uiSettings.unset('defaultColumns'); }); + async function expectColumns(columns: string[]) { + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.discover.waitUntilSearchingHasFinished(); + await retry.try(async () => { + const actualColumns = await PageObjects.discover.getColumnHeaders(); + expect(actualColumns).to.eql(columns); + }); + } + describe('ES|QL mode', () => { it('should render default columns and row height', async () => { const state = kbnRison.encode({ @@ -38,9 +54,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); const rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -58,9 +72,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -68,9 +80,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { expect(rowHeightNumber).to.be(3); await monacoEditor.setCodeEditorValue('from my-example-logs'); await queryBar.clickQuerySubmitButton(); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -91,16 +101,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Single'); await testSubjects.click('discoverNewButton'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -121,22 +128,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.common.navigateToActualUrl('discover', `?_a=${state}`, { ensureCurrentUrl: false, }); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message', 'data_stream.type']); + await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); }); }); - // FLAKY: https://github.com/elastic/kibana/issues/189994 - describe.skip('data view mode', () => { + describe('data view mode', () => { it('should render default columns and row height', async () => { await PageObjects.common.navigateToActualUrl('discover', undefined, { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); const rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -149,18 +151,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-*'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); let rowHeightNumber = await dataGrid.getCustomRowHeightNumber(); expect(rowHeightNumber).to.be(3); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -176,16 +174,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.discover.waitUntilSearchingHasFinished(); await PageObjects.unifiedFieldList.clickFieldListItemRemove('log.level'); await PageObjects.unifiedFieldList.clickFieldListItemRemove('message'); - let columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'Document']); + await expectColumns(['@timestamp', 'Document']); await dataGrid.clickGridSettings(); await dataGrid.changeRowHeightValue('Single'); let rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Single'); await testSubjects.click('discoverNewButton'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message']); + await expectColumns(['@timestamp', 'log.level', 'message']); await dataGrid.clickGridSettings(); rowHeightValue = await dataGrid.getCurrentRowHeightValue(); expect(rowHeightValue).to.be('Custom'); @@ -201,9 +196,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { ensureCurrentUrl: false, }); await dataViews.switchTo('my-example-logs'); - await PageObjects.discover.waitUntilSearchingHasFinished(); - const columns = await PageObjects.discover.getColumnHeaders(); - expect(columns).to.eql(['@timestamp', 'log.level', 'message', 'data_stream.type']); + await expectColumns(['@timestamp', 'log.level', 'message', 'data_stream.type']); }); }); });