From 5024bb18867ee29d370b776a3fa8322beb130d2a Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 8 Jun 2020 10:57:42 +0200 Subject: [PATCH 1/3] Unskip test --- test/functional/apps/context/_discover_navigation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index 7c1494fb41ef1..6bed445e24215 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -31,8 +31,8 @@ export default function ({ getService, getPageObjects }) { const filterBar = getService('filterBar'); const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); - // FLAKY: https://github.com/elastic/kibana/issues/53308 - describe.skip('context link in discover', function contextSize() { + // eslint-disable-next-line mocha/no-exclusive-tests + describe.only('context link in discover', function contextSize() { before(async function () { await PageObjects.common.navigateToApp('discover'); await PageObjects.timePicker.setDefaultAbsoluteRange(); From 69344d1c29d7d5fe118d2049e8ccdb92f499a731 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 8 Jun 2020 12:05:03 +0200 Subject: [PATCH 2/3] Improve code --- .../apps/context/_discover_navigation.js | 63 ++++++++++--------- test/functional/page_objects/time_picker.ts | 16 +++++ 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index 6bed445e24215..bb4351c2efbc7 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -32,51 +32,54 @@ export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); // eslint-disable-next-line mocha/no-exclusive-tests - describe.only('context link in discover', function contextSize() { - before(async function () { + describe.only('context link in discover', () => { + before(async () => { + await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); - await PageObjects.timePicker.setDefaultAbsoluteRange(); - await Promise.all( - TEST_COLUMN_NAMES.map((columnName) => - PageObjects.discover.clickFieldListItemAdd(columnName) - ) - ); + + for (const columnName of TEST_COLUMN_NAMES) { + await PageObjects.discover.clickFieldListItemAdd(columnName); + } + for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { await PageObjects.discover.clickFieldListItem(columnName); await PageObjects.discover.clickFieldListPlusFilter(columnName, value); } }); + after(async () => { + await PageObjects.timePicker.resetDefaultAbsoluteRangeViaUiSettings(); + }); - it('should open the context view with the selected document as anchor', async function () { - // get the timestamp of the first row - const firstTimestamp = (await docTable.getFields())[0][0]; - - // navigate to the context view - await docTable.clickRowToggle({ rowIndex: 0 }); - await (await docTable.getRowActions({ rowIndex: 0 }))[0].click(); - + it('should open the context view with the selected document as anchor', async () => { // check the anchor timestamp in the context view - await retry.try(async () => { - const anchorTimestamp = (await docTable.getFields({ isAnchorRow: true }))[0][0]; - expect(anchorTimestamp).to.equal(firstTimestamp); + await retry.waitFor('selected document timestamp matches anchor timestamp ', async () => { + // get the timestamp of the first row + const discoverFields = await docTable.getFields(); + const firstTimestamp = discoverFields[0][0]; + + // navigate to the context view + await docTable.clickRowToggle({ rowIndex: 0 }); + const rowActions = await docTable.getRowActions({ rowIndex: 0 }); + await rowActions[0].click(); + const contextFields = await docTable.getFields({ isAnchorRow: true }); + const anchorTimestamp = contextFields[0][0]; + return anchorTimestamp === firstTimestamp; }); }); - it('should open the context view with the same columns', async function () { + it('should open the context view with the same columns', async () => { const columnNames = await docTable.getHeaderFields(); expect(columnNames).to.eql(['Time', ...TEST_COLUMN_NAMES]); }); - it('should open the context view with the filters disabled', async function () { - const hasDisabledFilters = ( - await Promise.all( - TEST_FILTER_COLUMN_NAMES.map(([columnName, value]) => - filterBar.hasFilter(columnName, value, false) - ) - ) - ).reduce((result, hasDisabledFilter) => result && hasDisabledFilter, true); - - expect(hasDisabledFilters).to.be(true); + it('should open the context view with the filters disabled', async () => { + let disabledFilterCounter = 0; + for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) { + if (await filterBar.hasFilter(columnName, value, false)) { + disabledFilterCounter++; + } + } + expect(disabledFilterCounter).to.be(TEST_FILTER_COLUMN_NAMES.length); }); }); } diff --git a/test/functional/page_objects/time_picker.ts b/test/functional/page_objects/time_picker.ts index c755a6655e71f..25ca4a52c74eb 100644 --- a/test/functional/page_objects/time_picker.ts +++ b/test/functional/page_objects/time_picker.ts @@ -28,6 +28,7 @@ export function TimePickerProvider({ getService, getPageObjects }: FtrProviderCo const browser = getService('browser'); const testSubjects = getService('testSubjects'); const { header, common } = getPageObjects(['header', 'common']); + const kibanaServer = getService('kibanaServer'); type CommonlyUsed = | 'Today' @@ -44,11 +45,26 @@ export function TimePickerProvider({ getService, getPageObjects }: FtrProviderCo class TimePicker { defaultStartTime = 'Sep 19, 2015 @ 06:31:44.000'; defaultEndTime = 'Sep 23, 2015 @ 18:31:44.000'; + defaultStartTimeUTC = '2015-09-18T19:37:13.000Z'; + defaultEndTimeUTC = 'Sep 23, 2015 @ 18:31:44.000'; async setDefaultAbsoluteRange() { await this.setAbsoluteRange(this.defaultStartTime, this.defaultEndTime); } + /** + * the provides a quicker way to set the timepicker to the default range, saves a few seconds + */ + async setDefaultAbsoluteRangeViaUiSettings() { + await kibanaServer.uiSettings.update({ + 'timepicker:timeDefaults': `{ "from": "${this.defaultStartTimeUTC}", "to": "${this.defaultEndTimeUTC}"}`, + }); + } + + async resetDefaultAbsoluteRangeViaUiSettings() { + await kibanaServer.uiSettings.replace({}); + } + private async getTimePickerPanel() { return await find.byCssSelector('div.euiPopover__panel-isOpen'); } From 7eb1755d51617b95ccb260c2faa03fd08e06d3fd Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Mon, 8 Jun 2020 15:24:21 +0200 Subject: [PATCH 3/3] Remove describe.only, improve time_picker.ts modification --- test/functional/apps/context/_discover_navigation.js | 3 +-- test/functional/page_objects/time_picker.ts | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/functional/apps/context/_discover_navigation.js b/test/functional/apps/context/_discover_navigation.js index bb4351c2efbc7..6d7f7165e1b38 100644 --- a/test/functional/apps/context/_discover_navigation.js +++ b/test/functional/apps/context/_discover_navigation.js @@ -31,8 +31,7 @@ export default function ({ getService, getPageObjects }) { const filterBar = getService('filterBar'); const PageObjects = getPageObjects(['common', 'discover', 'timePicker']); - // eslint-disable-next-line mocha/no-exclusive-tests - describe.only('context link in discover', () => { + describe('context link in discover', () => { before(async () => { await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings(); await PageObjects.common.navigateToApp('discover'); diff --git a/test/functional/page_objects/time_picker.ts b/test/functional/page_objects/time_picker.ts index 25ca4a52c74eb..b7c1599fd48c5 100644 --- a/test/functional/page_objects/time_picker.ts +++ b/test/functional/page_objects/time_picker.ts @@ -45,8 +45,8 @@ export function TimePickerProvider({ getService, getPageObjects }: FtrProviderCo class TimePicker { defaultStartTime = 'Sep 19, 2015 @ 06:31:44.000'; defaultEndTime = 'Sep 23, 2015 @ 18:31:44.000'; - defaultStartTimeUTC = '2015-09-18T19:37:13.000Z'; - defaultEndTimeUTC = 'Sep 23, 2015 @ 18:31:44.000'; + defaultStartTimeUTC = '2015-09-18T06:31:44.000Z'; + defaultEndTimeUTC = '2015-09-23T18:31:44.000Z'; async setDefaultAbsoluteRange() { await this.setAbsoluteRange(this.defaultStartTime, this.defaultEndTime);