Skip to content

Commit

Permalink
[8.9] convert more tests to use uiSettings for timePicker (#161737) (#…
Browse files Browse the repository at this point in the history
…162133)

# Backport

This will backport the following commits from `main` to `8.9`:
- [convert more tests to use uiSettings for timePicker
(#161737)](#161737)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dzmitry
Lemechko","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-07-18T11:27:47Z","message":"convert
more tests to use uiSettings for timePicker (#161737)\n\nWhile searching
in test files, I found few more places to
replace\r\n`PageObjects.timePicker.setAbsoluteRange`
with\r\n`PageObjects.common.setTime`.\r\n\r\nBefore changing I reviewed
tests if it is not important to select\r\ndatePicker via UI component,
but please double check scenarios because I\r\nmight miss the
context.","sha":"72907cfe1eca4019a2ba6565e690d15a7dbab49d","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","FTR","v8.10.0","v8.9.1"],"number":161737,"url":"https://github.com/elastic/kibana/pull/161737","mergeCommit":{"message":"convert
more tests to use uiSettings for timePicker (#161737)\n\nWhile searching
in test files, I found few more places to
replace\r\n`PageObjects.timePicker.setAbsoluteRange`
with\r\n`PageObjects.common.setTime`.\r\n\r\nBefore changing I reviewed
tests if it is not important to select\r\ndatePicker via UI component,
but please double check scenarios because I\r\nmight miss the
context.","sha":"72907cfe1eca4019a2ba6565e690d15a7dbab49d"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161737","number":161737,"mergeCommit":{"message":"convert
more tests to use uiSettings for timePicker (#161737)\n\nWhile searching
in test files, I found few more places to
replace\r\n`PageObjects.timePicker.setAbsoluteRange`
with\r\n`PageObjects.common.setTime`.\r\n\r\nBefore changing I reviewed
tests if it is not important to select\r\ndatePicker via UI component,
but please double check scenarios because I\r\nmight miss the
context.","sha":"72907cfe1eca4019a2ba6565e690d15a7dbab49d"}},{"branch":"8.9","label":"v8.9.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dzmitry Lemechko <[email protected]>
  • Loading branch information
kibanamachine and dmlemeshko authored Jul 18, 2023
1 parent c522a21 commit 2c773db
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
8 changes: 4 additions & 4 deletions test/functional/apps/dashboard/group1/embeddable_rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

// FLAKY: https://github.com/elastic/kibana/issues/158529
describe.skip('dashboard embeddable rendering', function describeIndexTests() {
const from = 'Jan 1, 2018 @ 00:00:00.000';
const to = 'Apr 13, 2018 @ 00:00:00.000';
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'animals', 'test_logstash_reader']);
await kibanaServer.savedObjects.cleanStandardList();
Expand All @@ -111,14 +113,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.setTime({ from, to });
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
await PageObjects.dashboard.clickNewDashboard();
await elasticChart.setNewChartUiDebugFlag(true);

const fromTime = 'Jan 1, 2018 @ 00:00:00.000';
const toTime = 'Apr 13, 2018 @ 00:00:00.000';
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
});

after(async () => {
Expand All @@ -127,6 +126,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const newUrl = currentUrl.replace(/\?.*$/, '');
await browser.get(newUrl, false);
await security.testUser.restoreDefaults();
await PageObjects.common.unsetTime();
await kibanaServer.savedObjects.cleanStandardList();
});

Expand Down
8 changes: 4 additions & 4 deletions test/functional/apps/dashboard/group5/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
const from = 'Sep 19, 2017 @ 06:31:44.000';
const to = 'Sep 23, 2018 @ 18:31:44.000';
await PageObjects.common.setTime({ from, to });
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
await PageObjects.dashboard.loadSavedDashboard('few panels');

await PageObjects.dashboard.switchToEditMode();
const from = 'Sep 19, 2017 @ 06:31:44.000';
const to = 'Sep 23, 2018 @ 18:31:44.000';
await PageObjects.timePicker.setAbsoluteRange(from, to);
await PageObjects.dashboard.waitForRenderComplete();
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await PageObjects.common.unsetTime();
});

describe('snapshot share', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const filterBar = getService('filterBar');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const { dashboardControls, timePicker, common, dashboard, header } = getPageObjects([
const { dashboardControls, common, dashboard, header } = getPageObjects([
'dashboardControls',
'timePicker',
'dashboard',
'common',
'header',
Expand All @@ -46,16 +45,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await common.setTime({
from: 'Oct 22, 2018 @ 00:00:00.000',
to: 'Dec 3, 2018 @ 00:00:00.000',
});
await common.navigateToApp('dashboard');
await dashboardControls.enableControlsLab();
await common.navigateToApp('dashboard');
await dashboard.preserveCrossAppState();
await dashboard.gotoDashboardLandingPage();
await dashboard.clickNewDashboard();
await timePicker.setAbsoluteRange(
'Oct 22, 2018 @ 00:00:00.000',
'Dec 3, 2018 @ 00:00:00.000'
);
await dashboard.saveDashboard(DASHBOARD_NAME, { exitFromEditMode: false });
});

Expand All @@ -66,6 +65,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
);
await esArchiver.unload('test/functional/fixtures/es_archiver/kibana_sample_data_flights');
await kibanaServer.uiSettings.unset('defaultIndex');
await common.unsetTime();
await security.testUser.restoreDefaults();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.setTime({
from: 'Sep 22, 2015 @ 00:00:00.000',
to: 'Sep 23, 2015 @ 00:00:00.000',
});
});

after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
await PageObjects.common.unsetTime();
});

beforeEach(async () => {
await PageObjects.common.navigateToApp('dashboard');
await filterBar.ensureFieldEditorModalIsClosed();
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.timePicker.setAbsoluteRange(
'Sep 22, 2015 @ 00:00:00.000',
'Sep 23, 2015 @ 00:00:00.000'
);
});

const addSearchEmbeddableToDashboard = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

before(async () => {
await PageObjects.visualize.initTests();
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await PageObjects.common.navigateToApp('discover');
await PageObjects.timePicker.setDefaultAbsoluteRange();
await filterBar.addFilter({ field: 'extension.raw', operation: 'is', value: 'jpg' });
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.discover.saveSearch(savedSearchName);
discoverSavedSearchUrlPath = (await browser.getCurrentUrl()).split('?')[0];
});

after(async () => {
await PageObjects.common.unsetTime();
});

it('should create a visualization from a saved search', async () => {
await PageObjects.visualize.navigateToNewAggBasedVisualization();
await PageObjects.visualize.clickDataTable();
await PageObjects.visualize.clickSavedSearch(savedSearchName);
await PageObjects.timePicker.setDefaultAbsoluteRange();
await retry.waitFor('wait for count to equal 9,109', async () => {
const data = await PageObjects.visChart.getTableVisContent();
return data[0][0] === '9,109';
Expand Down
16 changes: 10 additions & 6 deletions test/functional/apps/visualize/group6/_tsvb_markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { visualBuilder, timePicker, visualize, visChart } = getPageObjects([
const { visualBuilder, common, visualize, visChart } = getPageObjects([
'visualBuilder',
'timePicker',
'common',
'visualize',
'visChart',
]);
Expand All @@ -37,20 +37,24 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
describe('markdown', () => {
before(async () => {
await visualize.initTests();
await common.setTime({
to: 'Sep 22, 2015 @ 06:00:00.000',
from: 'Sep 22, 2015 @ 11:00:00.000',
});
await visualize.navigateToNewVisualization();
await visualize.clickVisualBuilder();
await visualBuilder.checkVisualBuilderIsPresent();
await visualBuilder.clickMarkdown();
await timePicker.setAbsoluteRange(
'Sep 22, 2015 @ 06:00:00.000',
'Sep 22, 2015 @ 11:00:00.000'
);
await visualBuilder.markdownSwitchSubTab('options');
await visualBuilder.setMetricsDataTimerangeMode('Last value');
await visualBuilder.setDropLastBucket(true);
await visualBuilder.markdownSwitchSubTab('markdown');
});

after(async () => {
await common.unsetTime();
});

it('should render subtabs and table variables markdown components', async () => {
const tabs = await visualBuilder.getSubTabs();
expect(tabs).to.have.length(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('Filtered Saved Search', () => {
const TEST_SEARCH_TITLE = 'Customer Betty';
const TEST_DASHBOARD_TITLE = 'Filtered Search Data';
const setTimeRange = async () => {
const fromTime = 'Jun 20, 2019 @ 23:56:51.374';
const toTime = 'Jun 25, 2019 @ 16:18:51.821';
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
};
const from = 'Jun 20, 2019 @ 23:56:51.374';
const to = 'Jun 25, 2019 @ 16:18:51.821';

before(async () => {
await reporting.initEcommerce();
await PageObjects.common.setTime({ from, to });
await navigateToDashboardApp();
log.info(`Creating empty dashboard`);
await PageObjects.dashboard.clickNewDashboard();
await setTimeRange();
log.info(`Adding "${TEST_SEARCH_TITLE}" to dashboard`);
await dashboardAddPanel.addSavedSearch(TEST_SEARCH_TITLE);
await PageObjects.dashboard.saveDashboard(TEST_DASHBOARD_TITLE);
Expand All @@ -154,6 +151,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
after(async () => {
await reporting.teardownEcommerce();
await esArchiver.emptyKibanaIndex();
await PageObjects.common.unsetTime();
});

it('Downloads filtered Discover saved search report', async () => {
Expand Down

0 comments on commit 2c773db

Please sign in to comment.