-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d37c74d
commit 16a7682
Showing
5 changed files
with
246 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
test/functional/apps/discover/context_awareness/extensions/_get_default_ad_hoc_data_views.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const { common, discover, unifiedFieldList } = getPageObjects([ | ||
'common', | ||
'discover', | ||
'unifiedFieldList', | ||
]); | ||
const testSubjects = getService('testSubjects'); | ||
const dataViews = getService('dataViews'); | ||
const dataGrid = getService('dataGrid'); | ||
const toasts = getService('toasts'); | ||
const browser = getService('browser'); | ||
const esArchiver = getService('esArchiver'); | ||
const kibanaServer = getService('kibanaServer'); | ||
|
||
describe('extension getDefaultAdHocDataViews', () => { | ||
after(async () => { | ||
await kibanaServer.savedObjects.clean({ types: ['search'] }); | ||
}); | ||
|
||
it('should show the profile data view', async () => { | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await dataViews.getSelectedName()).not.to.be('Example profile data view'); | ||
await dataViews.switchTo('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T16:30:00.000Z'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T14:00:00.000Z'); | ||
}); | ||
|
||
it('should reload the profile data view on page refresh, and not show an error toast', async () => { | ||
await browser.refresh(); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await toasts.getCount({ timeout: 2000 })).to.be(0); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view'); | ||
}); | ||
|
||
it('should create a copy of the profile data view when saving the Discover session', async () => { | ||
await discover.saveSearch('Default profile data view session'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view (copy)'); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T16:30:00.000Z'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T14:00:00.000Z'); | ||
await dataViews.switchTo('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T16:30:00.000Z'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T14:00:00.000Z'); | ||
}); | ||
|
||
describe('fallback behaviour', function () { | ||
after(async () => { | ||
await esArchiver.load('test/functional/fixtures/es_archiver/discover/context_awareness'); | ||
await kibanaServer.importExport.load( | ||
'test/functional/fixtures/kbn_archiver/discover/context_awareness' | ||
); | ||
}); | ||
|
||
it('should fall back to the profile data view when no other data views are available', async () => { | ||
await kibanaServer.importExport.unload( | ||
'test/functional/fixtures/kbn_archiver/discover/context_awareness' | ||
); | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T16:30:00.000Z'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('2024-06-10T14:00:00.000Z'); | ||
}); | ||
|
||
it('should show the no data page when no ES data is available', async () => { | ||
await esArchiver.unload('test/functional/fixtures/es_archiver/discover/context_awareness'); | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await testSubjects.exists('kbnNoDataPage')).to.be(true); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
...est_suites/common/discover/context_awareness/extensions/_get_default_ad_hoc_data_views.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
import type { FtrProviderContext } from '../../../../../ftr_provider_context'; | ||
|
||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const { common, discover, unifiedFieldList, svlCommonPage } = getPageObjects([ | ||
'common', | ||
'discover', | ||
'unifiedFieldList', | ||
'svlCommonPage', | ||
]); | ||
const testSubjects = getService('testSubjects'); | ||
const dataViews = getService('dataViews'); | ||
const dataGrid = getService('dataGrid'); | ||
const toasts = getService('toasts'); | ||
const browser = getService('browser'); | ||
const esArchiver = getService('esArchiver'); | ||
const kibanaServer = getService('kibanaServer'); | ||
|
||
describe('extension getDefaultAdHocDataViews', () => { | ||
before(async () => { | ||
await svlCommonPage.loginAsAdmin(); | ||
}); | ||
|
||
after(async () => { | ||
await kibanaServer.savedObjects.clean({ types: ['search'] }); | ||
}); | ||
|
||
it('should show the profile data view', async () => { | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await dataViews.getSelectedName()).not.to.be('Example profile data view'); | ||
await dataViews.switchTo('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 16:30:00.000'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 14:00:00.000'); | ||
}); | ||
|
||
it('should reload the profile data view on page refresh, and not show an error toast', async () => { | ||
await browser.refresh(); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await toasts.getCount({ timeout: 2000 })).to.be(0); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view'); | ||
}); | ||
|
||
it('should create a copy of the profile data view when saving the Discover session', async () => { | ||
await discover.saveSearch('Default profile data view session'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view (copy)'); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 16:30:00.000'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 14:00:00.000'); | ||
await dataViews.switchTo('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 16:30:00.000'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 14:00:00.000'); | ||
}); | ||
|
||
describe('fallback behaviour', function () { | ||
// Search projects have a default data view, so these don't apply | ||
this.tags(['skipSvlSearch']); | ||
|
||
after(async () => { | ||
await esArchiver.load('test/functional/fixtures/es_archiver/discover/context_awareness'); | ||
await kibanaServer.importExport.load( | ||
'test/functional/fixtures/kbn_archiver/discover/context_awareness' | ||
); | ||
}); | ||
|
||
it('should fall back to the profile data view when no other data views are available', async () => { | ||
await kibanaServer.importExport.unload( | ||
'test/functional/fixtures/kbn_archiver/discover/context_awareness' | ||
); | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await dataViews.getSelectedName()).to.be('Example profile data view'); | ||
await discover.waitUntilSearchingHasFinished(); | ||
expect(await unifiedFieldList.getSidebarSectionFieldNames('available')).to.have.length(7); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(0, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 16:30:00.000'); | ||
expect( | ||
await (await dataGrid.getCellElementByColumnName(5, '@timestamp')).getVisibleText() | ||
).to.be('Jun 10, 2024 @ 14:00:00.000'); | ||
}); | ||
|
||
it('should show the no data page when no ES data is available', async () => { | ||
await esArchiver.unload('test/functional/fixtures/es_archiver/discover/context_awareness'); | ||
await common.navigateToActualUrl('discover', undefined, { | ||
ensureCurrentUrl: false, | ||
}); | ||
expect(await testSubjects.exists('kbnNoDataPage')).to.be(true); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters