Skip to content
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

[QA][refactor] Use ui settings - sample data #114530

Merged
merged 6 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions test/functional/apps/home/_sample_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

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

it('should display registered flights sample data sets', async () => {
Expand Down Expand Up @@ -74,6 +75,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('dashboard', () => {
beforeEach(async () => {
await time();
await PageObjects.common.navigateToUrl('home', '/tutorial_directory/sampleData', {
useActualUrl: true,
});
Expand All @@ -84,10 +86,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.home.launchSampleDashboard('flights');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const todayYearMonthDay = moment().format('MMM D, YYYY');
const fromTime = `${todayYearMonthDay} @ 00:00:00.000`;
const toTime = `${todayYearMonthDay} @ 23:59:59.999`;
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.be(17);
});
Expand All @@ -112,10 +110,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.home.launchSampleDashboard('logs');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const todayYearMonthDay = moment().format('MMM D, YYYY');
const fromTime = `${todayYearMonthDay} @ 00:00:00.000`;
const toTime = `${todayYearMonthDay} @ 23:59:59.999`;
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.be(13);
});
Expand All @@ -124,10 +118,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.home.launchSampleDashboard('ecommerce');
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
const todayYearMonthDay = moment().format('MMM D, YYYY');
const fromTime = `${todayYearMonthDay} @ 00:00:00.000`;
const toTime = `${todayYearMonthDay} @ 23:59:59.999`;
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.be(15);
});
Expand Down Expand Up @@ -160,5 +150,12 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(isInstalled).to.be(false);
});
});

async function time() {
const today = moment().format('MMM D, YYYY');
const from = `${today} @ 00:00:00.000`;
const to = `${today} @ 23:59:59.999`;
await PageObjects.common.setTime({ from, to });
}
});
}
9 changes: 9 additions & 0 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class CommonPageObject extends FtrService {
private readonly globalNav = this.ctx.getService('globalNav');
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly loginPage = this.ctx.getPageObject('login');
private readonly kibanaServer = this.ctx.getService('kibanaServer');

private readonly defaultTryTimeout = this.config.get('timeouts.try');
private readonly defaultFindTimeout = this.config.get('timeouts.find');
Expand Down Expand Up @@ -500,4 +501,12 @@ export class CommonPageObject extends FtrService {
await this.testSubjects.exists(validator);
}
}

async setTime(time: { from: string; to: string }) {
await this.kibanaServer.uiSettings.replace({ 'timepicker:timeDefaults': JSON.stringify(time) });
}

async unsetTime() {
await this.kibanaServer.uiSettings.unset('timepicker:timeDefaults');
}
}