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

[Uptime] Add functional UI tests #29667

Merged
merged 78 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
80c4afd
Refactor es queries and associated components/endpoints.
justinkambic Jan 25, 2019
0889e35
Add unit tests, repair broken tests.
justinkambic Jan 25, 2019
bfd9029
[Uptime] Add API functional tests for uptime graphQL (#29128)
justinkambic Jan 25, 2019
737af05
Add HB 7.0 data for API tests.
justinkambic Jan 26, 2019
665a7b7
Configure first error_list test to work with 7.x data.
justinkambic Jan 26, 2019
cd16442
Configure error_list filtered by id to work with 7.x data.
justinkambic Jan 26, 2019
59a59f4
Configure error_list functional tests to work with 7.x data.
justinkambic Jan 27, 2019
a03fb9d
Update snapshot test to work with 7.x data.
justinkambic Jan 27, 2019
04e8818
Update snapshot down filtered test to work with 7.x data.
justinkambic Jan 27, 2019
91b961d
Configure snapshot up test to work with 7.x data.
justinkambic Jan 27, 2019
fecfe54
Configure ping list tests to work with 7.x data.
justinkambic Jan 27, 2019
28db77e
Configure monitor list tests to work with 7.x data.
justinkambic Jan 27, 2019
ab9d159
Configure monitor status bar tests to work with 7.x data.
justinkambic Jan 27, 2019
a3f6d6f
Configure filterBar tests to work with 7.x data.
justinkambic Jan 27, 2019
e911f62
Configure docCount tests to work with 7.x data.
justinkambic Jan 27, 2019
8b42129
Simplify code based on PR feedback.
justinkambic Jan 27, 2019
78f88c6
Add loading spinner to monitor page title based on PR feedback.
justinkambic Jan 27, 2019
3e7e918
Rename GQL type based on PR feedback.
justinkambic Jan 27, 2019
dd2916d
Remove use of 'undefined' in ES query based on PR feedback.
justinkambic Jan 27, 2019
8178a47
Simplify code based on PR feedback.
justinkambic Jan 27, 2019
81eb06c
Add definite size/shard_size for terms agg based on PR feedback.
justinkambic Jan 28, 2019
fd7f930
Simplify ES query based on PR feedback.
justinkambic Jan 28, 2019
a714129
Update x-pack/plugins/uptime/server/lib/adapters/monitors/elasticsear…
pickypg Jan 28, 2019
81baabd
Increase size for ES errors query based on PR feedback.
justinkambic Jan 28, 2019
c5b198b
Fix hardcoded field in terms filter based on PR feedback.
justinkambic Jan 28, 2019
ed4d83d
Simplify get code for monitors function.
justinkambic Jan 28, 2019
21a7b3b
Reduce unnecessarily large size for terms agg based on PR feedback.
justinkambic Jan 28, 2019
d2dc10a
Pluralize filter bar props.
justinkambic Jan 28, 2019
f4f863d
Refactor filter bar query based on PR feedback.
justinkambic Jan 28, 2019
6728fd6
Update test.
justinkambic Jan 28, 2019
6d542a8
Merge branch 'master' into uptime_port-func-tests-to-7.x
justinkambic Jan 28, 2019
5dd3fcd
Merge branch 'uptime_improve-es-queries' into uptime_port-func-tests-…
justinkambic Jan 28, 2019
c11f6f0
Fix busted GQL query.
justinkambic Jan 28, 2019
ea4e0ef
Update functional test docs to use data without buggy values.
justinkambic Jan 28, 2019
c82ca56
Update index name in HB functional api test docs.
justinkambic Jan 28, 2019
180196b
Update snapshot base functional test.
justinkambic Jan 28, 2019
9f6088e
Make snapshot filter tests pass, fix associated bug.
justinkambic Jan 28, 2019
ffbc297
Configure remaining snapshot e2e tests to work with 7.x data.
justinkambic Jan 29, 2019
1f4b1f1
Give better variable names and comments for ugly code.
justinkambic Jan 29, 2019
12df980
Configure ping list query tests to work with updated 7.x data.
justinkambic Jan 29, 2019
bafbcfb
Rename graphql describe block.
justinkambic Jan 29, 2019
7f77844
Update monitor status bar query tests to work with updated 7.x data.
justinkambic Jan 29, 2019
f70b731
Update monitor list query tests to work with updated 7.x data.
justinkambic Jan 29, 2019
3832749
Update filter bar query to work with updated 7.x data.
justinkambic Jan 29, 2019
ec731ca
Update error list query to work with updated 7.x data.
justinkambic Jan 29, 2019
b547914
Update doc count fixture to work with new 7.x data.
justinkambic Jan 29, 2019
096bb14
Merge branch 'master' into uptime_port-func-tests-to-7.x
justinkambic Jan 29, 2019
e111662
Merge branch 'master' into uptime_port-func-tests-to-7.x
justinkambic Jan 29, 2019
90752cb
Merge branch 'master' into uptime_port-func-tests-to-7.x
justinkambic Jan 30, 2019
14573f0
Create functional UI tests for Overview and Monitor pages.
justinkambic Jan 30, 2019
5aab60a
Merge branch 'master' into uptime_func-ui-test
justinkambic Jan 31, 2019
8d6df4a
Merge branch 'master' into uptime_func-ui-test
justinkambic Feb 1, 2019
d9a4128
Add additional waits to functional UI test to try to prevent flakiness.
justinkambic Feb 1, 2019
0027388
Merge branch 'master' of github.com:elastic/kibana into pr/29667
Feb 8, 2019
ee89320
[ftr/services/superDatePicker] make specialized service
Feb 8, 2019
3922254
Merge branch 'master' into uptime_func-ui-test
justinkambic Feb 11, 2019
24d06f2
Merge branch 'uptime_func-ui-test' of github.com:justinkambic/kibana …
justinkambic Feb 11, 2019
e6b377a
Add data-test-subj value to monitor link.
justinkambic Feb 11, 2019
dc40167
Remove wait calls from UI tests.
justinkambic Feb 11, 2019
4c544f5
Set default timezone for tests' kibana server.
justinkambic Feb 12, 2019
692bc12
Merge branch 'master' into uptime_func-ui-test
justinkambic Feb 12, 2019
39db8c9
Merge branch 'master' into uptime_func-ui-test
justinkambic Feb 13, 2019
6a0b011
Merge branch 'master' into uptime_func-ui-test
justinkambic Feb 13, 2019
472e422
Add @types for mocha and expect.js.
justinkambic Feb 14, 2019
ec0d53c
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 1, 2019
89d4d67
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 5, 2019
b15caac
Merge master
justinkambic Mar 7, 2019
14736ac
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 7, 2019
c9d1990
Implement PR feedback.
justinkambic Mar 7, 2019
dbf17e1
Remove added types.
justinkambic Mar 8, 2019
befa5f1
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 8, 2019
b22aa16
Re-add mocha types.
justinkambic Mar 8, 2019
c939399
Remove obsolete comment.
justinkambic Mar 8, 2019
f10c481
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 11, 2019
b50843f
Disable timestamp on uptime app navigation for functional tests.
justinkambic Mar 12, 2019
912e44b
Undo previous change for default value of function parameter.
justinkambic Mar 12, 2019
9c886e8
Add redirect hack to uptime client to change window location when exp…
justinkambic Mar 12, 2019
79902b3
Merge branch 'master' into uptime_func-ui-test
justinkambic Mar 12, 2019
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
14 changes: 14 additions & 0 deletions test/functional/page_objects/time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
await find.waitForElementStale(panelElement);
}

async setAbsoluteStart(startTime) {
await this.showStartEndTimes();

await testSubjects.click('superDatePickerstartDatePopoverButton');
const panel = await this.getTimePickerPanel();
await testSubjects.click('superDatePickerAbsoluteTab');
await testSubjects.setValue('superDatePickerAbsoluteDateInput', startTime);
await testSubjects.click('superDatePickerstartDatePopoverButton');
await this.waitPanelIsGone(panel);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
}

/**
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
* @param {String} fromTime YYYY-MM-DD HH:mm:ss.SSS
Expand Down Expand Up @@ -110,6 +122,8 @@ export function TimePickerPageProvider({ getService, getPageObjects }) {
}

async showStartEndTimes() {
// This first await makes sure the superDatePicker has loaded before we check for the ShowDatesButton
await testSubjects.exists('superDatePickerToggleQuickMenuButton', { timeout: 20000 });
const isShowDatesButton = await testSubjects.exists('superDatePickerShowDatesButton');
if (isShowDatesButton) {
await testSubjects.click('superDatePickerShowDatesButton');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const MonitorList = ({ dangerColor, loading, monitors, primaryColor }: Mo
defaultMessage: 'ID',
}),
render: (id: string, monitor: LatestMonitor) => (
<Link to={`/monitor/${id}`}>
<Link data-test-subj={`monitor-page-link-${id}`} to={`/monitor/${id}`}>
{monitor.ping && monitor.ping.monitor && monitor.ping.monitor.name
? monitor.ping.monitor.name
: id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const MonitorPageTitle = ({ pageTitle: { name, url, id } }: MonitorPageTi
<EuiFlexGroup alignItems="baseline">
<EuiFlexItem grow={false}>
<EuiTitle>
<h2>{name ? name : url}</h2>
<h2 data-test-subj="monitor-page-title">{name ? name : url}</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
const route = {
controllerAs: 'uptime',
// @ts-ignore angular
controller: ($scope, $route, $http, config) => {
controller: ($scope, $route, config, $location, $window) => {
const graphQLClient = createGraphQLClient(this.uriPath, this.xsrfHeader);
$scope.$$postDigest(() => {
const elem = document.getElementById('uptimeReactRoot');
Expand All @@ -57,6 +57,23 @@ export class UMKibanaFrameworkAdapter implements UMFrameworkAdapter {
const routerBasename = basePath.endsWith('/')
? `${basePath}/${PLUGIN.ROUTER_BASE_NAME}`
: basePath + PLUGIN.ROUTER_BASE_NAME;

/**
* TODO: this is a redirect hack to deal with a problem that largely
* in testing but rarely occurs in the real world, where the specified
* URL contains `.../app/uptime{SOME_URL_PARAM_TEXT}#` instead of
* a path like `.../app/uptime#{SOME_URL_PARAM_TEXT}`.
*
* This redirect will almost never be triggered in practice, but it makes more
* sense to include it here rather than altering the existing testing
* infrastructure underlying the rest of Kibana.
*
* We welcome a more permanent solution that will result in the deletion of the
* block below.
*/
if ($location.absUrl().indexOf(PLUGIN.ROUTER_BASE_NAME) === -1) {
$window.location.replace(routerBasename);
}
const persistedState = this.initializePersistedState();
const darkMode = config.get('theme:darkMode', false) || false;
const {
Expand Down
13 changes: 12 additions & 1 deletion x-pack/test/functional/apps/uptime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,22 @@

import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';

const ARCHIVE = 'uptime/full_heartbeat';

// tslint:disable-next-line:no-default-export
export default ({ loadTestFile }: KibanaFunctionalTestDefaultProviders) => {
export default ({ loadTestFile, getService }: KibanaFunctionalTestDefaultProviders) => {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');

describe('Uptime app', function() {
before(async () => {
await esArchiver.load(ARCHIVE);
await kibanaServer.uiSettings.replace({ 'dateFormat:tz': 'UTC' });
});
after(async () => await esArchiver.unload(ARCHIVE));
this.tags('ciGroup6');

loadTestFile(require.resolve('./overview'));
loadTestFile(require.resolve('./monitor'));
});
};
28 changes: 28 additions & 0 deletions x-pack/test/functional/apps/uptime/monitor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';

// tslint:disable-next-line:no-default-export
export default ({ getPageObjects, getService }: KibanaFunctionalTestDefaultProviders) => {
const esArchiver = getService('esArchiver');
const pageObjects = getPageObjects(['uptime']);
const archive = 'uptime/full_heartbeat';

describe('monitor page', () => {
before(async () => {
await esArchiver.load(archive);
});
after(async () => await esArchiver.unload(archive));
it('loads and displays uptime data based on date range', async () => {
await pageObjects.uptime.loadDataAndGoToMonitorPage(
'2019-01-28 12:40:08.078',
'auto-http-0X131221E73F825974',
'https://www.google.com/'
);
});
});
};
21 changes: 8 additions & 13 deletions x-pack/test/functional/apps/uptime/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
import { KibanaFunctionalTestDefaultProviders } from '../../../types/providers';

// tslint:disable-next-line:no-default-export
export default ({ getPageObjects, getService }: KibanaFunctionalTestDefaultProviders) => {
const esArchiver = getService('esArchiver');
export default ({ getPageObjects }: KibanaFunctionalTestDefaultProviders) => {
// TODO: add UI functional tests
// const pageObjects = getPageObjects(['uptime']);
const archive = 'uptime/full_heartbeat';

describe('Overview page', () => {
describe('this is a simple test', () => {
beforeEach(async () => {
await esArchiver.load(archive);
});
afterEach(async () => await esArchiver.unload(archive));

// TODO: add UI functional tests
const pageObjects = getPageObjects(['uptime']);
describe('overview page', () => {
it('loads and displays uptime data based on date range', async () => {
await pageObjects.uptime.goToUptimeOverviewAndLoadData(
'2019-01-28 12:40:08.078',
'monitor-page-link-auto-http-0X131221E73F825974'
);
});
});
};
31 changes: 24 additions & 7 deletions x-pack/test/functional/page_objects/uptime_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,30 @@ export const UptimePageProvider = ({
getPageObjects,
getService,
}: KibanaFunctionalTestDefaultProviders) => {
const pageObject = getPageObjects(['common']);
const pageObjects = getPageObjects(['common', 'timePicker']);
const uptimeService = getService('uptime');

return {
async goToUptimeOverview() {
await pageObject.common.navigateToApp('uptime');
await uptimeService.assertExists();
},
};
return new class UptimePage {
public async goToUptimeOverviewAndLoadData(
datePickerStartValue: string,
monitorIdToCheck: string
) {
await pageObjects.common.navigateToApp('uptime');
await pageObjects.timePicker.setAbsoluteStart(datePickerStartValue);
await uptimeService.monitorIdExists(monitorIdToCheck);
}

public async loadDataAndGoToMonitorPage(
datePickerStartValue: string,
monitorId: string,
monitorName: string
) {
await pageObjects.common.navigateToApp('uptime');
await pageObjects.timePicker.setAbsoluteStart(datePickerStartValue);
await uptimeService.navigateToMonitorWithId(monitorId);
if ((await uptimeService.getMonitorNameDisplayedOnPageTitle()) !== monitorName) {
throw new Error('Expected monitor name not found');
}
}
}();
};
10 changes: 9 additions & 1 deletion x-pack/test/functional/services/uptime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ import { KibanaFunctionalTestDefaultProviders } from '../../types/providers';

export const UptimeProvider = ({ getService }: KibanaFunctionalTestDefaultProviders) => {
const testSubjects = getService('testSubjects');

return {
async assertExists(key: string) {
if (!(await testSubjects.exists(key))) {
throw new Error(`Couldn't find expected element with key "${key}".`);
}
},
async monitorIdExists(key: string) {
await testSubjects.existOrFail(key);
},
async navigateToMonitorWithId(monitorId: string) {
await testSubjects.click(`monitor-page-link-${monitorId}`);
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this PR and I'm running it. It fails for me here;

       │ debg TestSubjects.exists(monitor-page-link-auto-http-0X131221E73F825974)
       │ debg existsByDisplayedByCssSelector [data-test-subj~="monitor-page-link-auto-http-0X131221E73F825974"]
       │ info Taking screenshot "C:\Users\LeeDr\git\kibana\x-pack\test\functional\screenshots\failure\Uptime app overview page loads and displays uptime data based on date range.png"
       │ info Current URL is: http://localhost:5620/app/uptime#/?_g=()
       │ info Browser output is:
       │ info Saving page source to: C:\Users\LeeDr\git\kibana\x-pack\test\functional\failure_debug\html\Uptime app overview page loads and displays uptime data based on date range.html
       └- × fail: "Uptime app overview page loads and displays uptime data based on date range"
       │      Error: expected testSubject(monitor-page-link-auto-http-0X131221E73F825974) to exist
       │       at TestSubjects.existOrFail (C:/Users/LeeDr/git/kibana/test/functional/services/test_subjects.js:54:15)
       │       at process._tickCallback (internal/process/next_tick.js:68:7)

And I don't see a data-test-subj on the element here;
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely it worked for me the last time I ran it locally. I'll revisit it when I get a second.

async getMonitorNameDisplayedOnPageTitle() {
return await testSubjects.getVisibleText('monitor-page-title');
},
};
};
2 changes: 2 additions & 0 deletions x-pack/test/types/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*/

import { EsArchiver } from '../../../src/es_archiver';
import { UptimeProvider } from '../functional/services/uptime';

export interface KibanaFunctionalTestDefaultProviders {
getService(serviceName: 'esArchiver'): EsArchiver;
getService(serviceName: 'uptime'): ReturnType<typeof UptimeProvider>;
getService(serviceName: string): any;
getPageObjects(pageObjectNames: string[]): any;
loadTestFile(path: string): void;
Expand Down