-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discover] Fix csv export with relative time filter from discover main view #123206
Changes from 19 commits
6f282a7
b1c777d
403132c
b5c36d9
cb16297
5666be9
22c12c4
1199e7d
c914287
0565dd7
762d51c
b2c7fbb
23f21ef
26b0493
25a87bb
2831c1c
2040d86
17927ed
d1a345a
135fb18
4198cb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { Key } from 'selenium-webdriver'; | ||
import moment from 'moment'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
|
@@ -17,8 +18,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
const kibanaServer = getService('kibanaServer'); | ||
const browser = getService('browser'); | ||
const retry = getService('retry'); | ||
const PageObjects = getPageObjects(['reporting', 'common', 'discover', 'timePicker']); | ||
const PageObjects = getPageObjects(['reporting', 'common', 'discover', 'timePicker', 'share']); | ||
const filterBar = getService('filterBar'); | ||
const find = getService('find'); | ||
const testSubjects = getService('testSubjects'); | ||
|
||
const setFieldsFromSource = async (setValue: boolean) => { | ||
await kibanaServer.uiSettings.update({ 'discover:searchFieldsFromSource': setValue }); | ||
|
@@ -76,6 +79,55 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |
await PageObjects.discover.selectIndexPattern('ecommerce'); | ||
}); | ||
|
||
it('generates a report with single timefilter', async () => { | ||
await PageObjects.discover.clickNewSearchButton(); | ||
await PageObjects.timePicker.setCommonlyUsedTime('Last_24 hours'); | ||
await PageObjects.discover.saveSearch('single-timefilter-search'); | ||
|
||
// get shared URL value | ||
await PageObjects.share.clickShareTopNavButton(); | ||
const sharedURL = await PageObjects.share.getSharedUrl(); | ||
|
||
// click 'Copy POST URL' | ||
await PageObjects.share.clickShareTopNavButton(); | ||
await PageObjects.reporting.openCsvReportingPanel(); | ||
const advOpt = await find.byXPath(`//button[descendant::*[text()='Advanced options']]`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should really try to avoid this kind of selector in tests because it is tied to copy which can change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll make this easier for tests in a separate issue: #127842 |
||
await advOpt.click(); | ||
const postUrl = await find.byXPath(`//button[descendant::*[text()='Copy POST URL']]`); | ||
await postUrl.click(); | ||
|
||
// get clipboard value using field search input, since | ||
// 'browser.getClipboardValue()' doesn't work, due to permissions | ||
const pastToElement = await testSubjects.find('fieldFilterSearchInput'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should come up with a better way to expose the POST URL content for functional tests like this, and expose a simple method to access it in https://github.com/elastic/kibana/blob/main/x-pack/test/reporting_functional/services/scenarios.ts Let's do that within the Reporting team, in a separate issue. |
||
await pastToElement.click(); | ||
await browser.getActions().keyDown(Key.CONTROL).perform(); | ||
await browser.getActions().keyDown('v').perform(); | ||
|
||
const reportURL = decodeURIComponent(await pastToElement.getAttribute('value')); | ||
|
||
// get number of filters in URLs | ||
const timeFiltersNumberInReportURL = | ||
reportURL.split('query:(range:(order_date:(format:strict_date_optional_time').length - 1; | ||
const timeFiltersNumberInSharedURL = sharedURL.split('time:').length - 1; | ||
|
||
expect(timeFiltersNumberInSharedURL).to.be(1); | ||
expect(sharedURL.includes('time:(from:now-24h%2Fh,to:now))')).to.be(true); | ||
|
||
expect(timeFiltersNumberInReportURL).to.be(1); | ||
expect( | ||
reportURL.includes( | ||
'query:(range:(order_date:(format:strict_date_optional_time,gte:now-24h/h,lte:now))))' | ||
) | ||
).to.be(true); | ||
|
||
// return keyboard state | ||
await browser.getActions().keyUp(Key.CONTROL).perform(); | ||
await browser.getActions().keyUp('v').perform(); | ||
|
||
// return field search input state | ||
await pastToElement.clearValue(); | ||
}); | ||
|
||
it('generates a report from a new search with data: default', async () => { | ||
await PageObjects.discover.clickNewSearchButton(); | ||
await PageObjects.reporting.setTimepickerInEcommerceDataRange(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ppisljar we could simplify consumer code by always returning
Filter[]
fromgetField('filter')
instead ofFilter[] | Filter | (() => Filter[] | Filter | undefined)
. WDYT?It may have to be
Filter[] | (() => Filter[])
. Still, currently seems like a lot of things to check 😅