kibana/test/functional/page_objects/common_page.js

277 lines
9.7 KiB
JavaScript
Raw Normal View History

import { delay } from 'bluebird';
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
[ftr] make room for more projects (#11848) Squashed commit of the following: commit 659ea986fdeb9a5ff2ca1fa5360cccb01c671ede Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 09:19:22 2017 -0700 [test/*/fixtures] rename es_archives to es_archiver commit d3667457c78e88e2d6974f3c38dd0fe61b846b91 Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 08:22:03 2017 -0700 [ftr/config] fix default directory value functions commit 9a6a2cc0b295e2281e83da04fcea40e9d6f00781 Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 07:30:52 2017 -0700 fix import paths commit fcb65a877d54b5b1d36b8c81f1264b36845e826e Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 21:39:57 2017 -0700 [grunt/ftr] use named exports for configs commit 7d7f38c7615cdbf8eb0119efc0f2a5188bca8792 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:50:04 2017 -0700 [test] remove unnecessary directory definitions commit 0c28984669768482f0a2ee7fc2800d5bcaf49025 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:46:29 2017 -0700 [ftr/config] make default directories relative to config path commit cd2f33612624cacffec138797f3fc0f4ecb46cca Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:32:12 2017 -0700 [test/common] put server config into common commit 7851ed811a236576c63bd20850b3ef2099be2a4e Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:18:20 2017 -0700 [grunt] "deprecate" test:api:runner task commit b2ac4c26593a1947c94f0168191fe8123ff74122 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:15:41 2017 -0700 [ftr] accept the project name as an unnamed arg commit 47e292894fc70c0a04883403c50c5d2ae0738d76 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:56:34 2017 -0700 [ftr/grunt] convert ftr task to multi-task with config commit 83375855f88e5e7b3fa8b6a1c5d24a9f54766ce5 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:54:54 2017 -0700 [test/functional] move fixtures into test/functional project commit 05994e9c92cf134c58f831c285b3b522a801acbc Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:02:51 2017 -0700 [src/test_utils] merge with test/utils directory commit c77ee5ed36b8b7eadf876cb6d9482a49dfc92b66 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:53:00 2017 -0700 [test/api_integration] migrate api tests to functional test runner commit ca328c34648dd7e07f70e1844e07cfc392e41103 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:50:12 2017 -0700 [esArchiver] refresh modified indices after load commit cde74a540850fd97578f441d6dccaefd1444e656 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:46:48 2017 -0700 [test/functional] move shared services into test/common commit 0ea2646aea5817f6d1595e6ae0d356c426f138f0 Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 22:51:23 2017 -0700 [scripts/mocha] run _mocha script when debugging commit 1cc80600d90e318d4738920aa557d124075a4570 Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 22:48:12 2017 -0700 [ftr/config] allow child config files to have no testFiles config commit 2bb6c957443b18cebc419baa6f9db301c8f4dc4f Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 21:52:26 2017 -0700 [ftr] move screenshots into test/functional
2017-05-18 03:53:45 +02:00
import getUrl from '../../../src/test_utils/get_url';
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
export function CommonPageProvider({ getService, getPageObjects, getPageObject }) {
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
const log = getService('log');
const config = getService('config');
const remote = getService('remote');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['shield']);
const defaultTryTimeout = config.get('timeouts.try');
const defaultFindTimeout = config.get('timeouts.find');
class CommonPage {
getHostPort() {
return getUrl.baseUrl(config.get('servers.kibana'));
}
getEsHostPort() {
return getUrl.baseUrl(config.get('servers.elasticsearch'));
}
Getting Started page (#11805) * Getting Started page (#11673) * Initial code * Renaming files/folders * Notes and changes from HTML/CSS review * CSS changes * Fixing transform units * Fleshing out logo circle * Adding logos * Un-nesting styles * Adding kuiText class on <p> elements * Making shield icon 404 go away * Using trustAsHtml filter; using registry * Adding code for registry * Adding images * Hooking up the opt-out link * Fixing linter issues * Fix issue with refresh bringing back nav * Removing load_default module * Use GETTING_STARTED_ROUTE constant * Allow topMessage to be a directive * Adding kuiLink CSS class to anchor elements * Adding alt text to images * Replace getters with regular methods * Remove leftover comment * Removing unnecessary comment * Fixing typo in comment * Adding comments for message properties * Fixing typo in method name * Defining custom CSS class * Fixing method call * Creating custom CSS classes * Adding documentation links * Use a instead of button for demo link * Allow directives in manage and monitor messages * Refactoring shared code into single ui/public/getting_started folder * Adding README * Fixing whitespace in/around links * Trim messages before setting them * Decorate in-app links with opt-out attribute * Opt out of the Getting Started page if the user already has index patterns * Adding more commentary around expectations of setTopMessage use * Using ng-src and ng-href attributes where attr values are angular expressions * Importing the directive before using it * Using ui/registry for message registries * Renaming service => helpers to clarify intent * Adding explanatory comment * Adding "or" * Fixing div id * Breaks out the inject logic into another directive * Adding Getting Started page object for functional tests * Consolidate into one registry * Fixes incorrect classes * Changes how styles are applied to injected-items items * Modifying class name per CSS style guide * Adding getting started doc link * Removing unused import * Attempting to fix breaking build Apparently the Getting Started page is preventing access to Console (Dev Tools, really) so the functional tests for Console are failing. This commit opts the user out of the Getting Started page before attempting to navigate to Console. * Cleanup on aisle testbed! (#11765) * Navigate to getting started page so we can opt out of it
2017-05-15 23:04:16 +02:00
/**
[ftr] make room for more projects (#11848) Squashed commit of the following: commit 659ea986fdeb9a5ff2ca1fa5360cccb01c671ede Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 09:19:22 2017 -0700 [test/*/fixtures] rename es_archives to es_archiver commit d3667457c78e88e2d6974f3c38dd0fe61b846b91 Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 08:22:03 2017 -0700 [ftr/config] fix default directory value functions commit 9a6a2cc0b295e2281e83da04fcea40e9d6f00781 Author: spalger <spalger@users.noreply.github.com> Date: Wed May 17 07:30:52 2017 -0700 fix import paths commit fcb65a877d54b5b1d36b8c81f1264b36845e826e Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 21:39:57 2017 -0700 [grunt/ftr] use named exports for configs commit 7d7f38c7615cdbf8eb0119efc0f2a5188bca8792 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:50:04 2017 -0700 [test] remove unnecessary directory definitions commit 0c28984669768482f0a2ee7fc2800d5bcaf49025 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:46:29 2017 -0700 [ftr/config] make default directories relative to config path commit cd2f33612624cacffec138797f3fc0f4ecb46cca Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:32:12 2017 -0700 [test/common] put server config into common commit 7851ed811a236576c63bd20850b3ef2099be2a4e Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:18:20 2017 -0700 [grunt] "deprecate" test:api:runner task commit b2ac4c26593a1947c94f0168191fe8123ff74122 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 18:15:41 2017 -0700 [ftr] accept the project name as an unnamed arg commit 47e292894fc70c0a04883403c50c5d2ae0738d76 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:56:34 2017 -0700 [ftr/grunt] convert ftr task to multi-task with config commit 83375855f88e5e7b3fa8b6a1c5d24a9f54766ce5 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:54:54 2017 -0700 [test/functional] move fixtures into test/functional project commit 05994e9c92cf134c58f831c285b3b522a801acbc Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 17:02:51 2017 -0700 [src/test_utils] merge with test/utils directory commit c77ee5ed36b8b7eadf876cb6d9482a49dfc92b66 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:53:00 2017 -0700 [test/api_integration] migrate api tests to functional test runner commit ca328c34648dd7e07f70e1844e07cfc392e41103 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:50:12 2017 -0700 [esArchiver] refresh modified indices after load commit cde74a540850fd97578f441d6dccaefd1444e656 Author: spalger <spalger@users.noreply.github.com> Date: Tue May 16 16:46:48 2017 -0700 [test/functional] move shared services into test/common commit 0ea2646aea5817f6d1595e6ae0d356c426f138f0 Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 22:51:23 2017 -0700 [scripts/mocha] run _mocha script when debugging commit 1cc80600d90e318d4738920aa557d124075a4570 Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 22:48:12 2017 -0700 [ftr/config] allow child config files to have no testFiles config commit 2bb6c957443b18cebc419baa6f9db301c8f4dc4f Author: spalger <spalger@users.noreply.github.com> Date: Mon May 15 21:52:26 2017 -0700 [ftr] move screenshots into test/functional
2017-05-18 03:53:45 +02:00
* @param {string} appName As defined in the apps config
Getting Started page (#11805) * Getting Started page (#11673) * Initial code * Renaming files/folders * Notes and changes from HTML/CSS review * CSS changes * Fixing transform units * Fleshing out logo circle * Adding logos * Un-nesting styles * Adding kuiText class on <p> elements * Making shield icon 404 go away * Using trustAsHtml filter; using registry * Adding code for registry * Adding images * Hooking up the opt-out link * Fixing linter issues * Fix issue with refresh bringing back nav * Removing load_default module * Use GETTING_STARTED_ROUTE constant * Allow topMessage to be a directive * Adding kuiLink CSS class to anchor elements * Adding alt text to images * Replace getters with regular methods * Remove leftover comment * Removing unnecessary comment * Fixing typo in comment * Adding comments for message properties * Fixing typo in method name * Defining custom CSS class * Fixing method call * Creating custom CSS classes * Adding documentation links * Use a instead of button for demo link * Allow directives in manage and monitor messages * Refactoring shared code into single ui/public/getting_started folder * Adding README * Fixing whitespace in/around links * Trim messages before setting them * Decorate in-app links with opt-out attribute * Opt out of the Getting Started page if the user already has index patterns * Adding more commentary around expectations of setTopMessage use * Using ng-src and ng-href attributes where attr values are angular expressions * Importing the directive before using it * Using ui/registry for message registries * Renaming service => helpers to clarify intent * Adding explanatory comment * Adding "or" * Fixing div id * Breaks out the inject logic into another directive * Adding Getting Started page object for functional tests * Consolidate into one registry * Fixes incorrect classes * Changes how styles are applied to injected-items items * Modifying class name per CSS style guide * Adding getting started doc link * Removing unused import * Attempting to fix breaking build Apparently the Getting Started page is preventing access to Console (Dev Tools, really) so the functional tests for Console are failing. This commit opts the user out of the Getting Started page before attempting to navigate to Console. * Cleanup on aisle testbed! (#11765) * Navigate to getting started page so we can opt out of it
2017-05-15 23:04:16 +02:00
* @param {string} subUrl The route after the hash (#)
*/
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
navigateToUrl(appName, subUrl) {
const appConfig = Object.assign({}, config.get(['apps', appName]), {
// Overwrite the default hash with the URL we really want.
hash: `${appName}/${subUrl}`,
});
const appUrl = getUrl.noAuth(config.get('servers.kibana'), appConfig);
return remote.get(appUrl);
}
navigateToApp(appName) {
const self = this;
const appUrl = getUrl.noAuth(config.get('servers.kibana'), config.get(['apps', appName]));
log.debug('navigating to ' + appName + ' url: ' + appUrl);
function navigateTo(url) {
return retry.try(function () {
// since we're using hash URLs, always reload first to force re-render
return kibanaServer.uiSettings.getDefaultIndex()
.then(function (defaultIndex) {
if (appName === 'discover' || appName === 'visualize' || appName === 'dashboard') {
if (!defaultIndex) {
// https://github.com/elastic/kibana/issues/7496
// Even though most tests are using esClient to set the default index, sometimes Kibana clobbers
// that change. If we got here, fix it.
log.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex);
log.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""');
return kibanaServer.uiSettings.update({
'dateFormat:tz':'UTC',
'defaultIndex':'logstash-*'
});
}
}
})
.then(function () {
log.debug('navigate to: ' + url);
return remote.get(url);
})
.then(function () {
return self.sleep(700);
})
.then(function () {
log.debug('returned from get, calling refresh');
return remote.refresh();
})
.then(async function () {
const currentUrl = await remote.getCurrentUrl();
const loginPage = currentUrl.includes('/login');
const wantedLoginPage = appUrl.includes('/login') || appUrl.includes('/logout');
if (loginPage && !wantedLoginPage) {
log.debug(`Found loginPage username = ${config.get('servers.kibana.username')}`);
await PageObjects.shield.login(
config.get('servers.kibana.username'),
config.get('servers.kibana.password')
);
}
if (currentUrl.includes('app/kibana')) {
await testSubjects.find('kibanaChrome');
const gettingStartedPage = getPageObject('gettingStarted');
if (await gettingStartedPage.doesContainerExist()) {
await gettingStartedPage.optOut();
throw new Error('Retrying after receiving Getting Started page');
}
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
}
})
.then(async function () {
const currentUrl = (await remote.getCurrentUrl()).replace(/\/\/\w+:\w+@/, '//');
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
const maxAdditionalLengthOnNavUrl = 230;
// On several test failures at the end of the TileMap test we try to navigate back to
// Visualize so we can create the next Vertical Bar Chart, but we can see from the
// logging and the screenshot that it's still on the TileMap page. Why didn't the "get"
// with a new timestamped URL go? I thought that sleep(700) between the get and the
// refresh would solve the problem but didn't seem to always work.
// So this hack fails the navSuccessful check if the currentUrl doesn't match the
// appUrl plus up to 230 other chars.
// Navigating to Settings when there is a default index pattern has a URL length of 196
// (from debug output). Some other tabs may also be long. But a rather simple configured
// visualization is about 1000 chars long. So at least we catch that case.
// Browsers don't show the ':port' if it's 80 or 443 so we have to
// remove that part so we can get a match in the tests.
const navSuccessful = new RegExp(appUrl.replace(':80','').replace(':443','')
+ '.{0,' + maxAdditionalLengthOnNavUrl + '}$')
.test(currentUrl);
if (!navSuccessful) {
const msg = 'App failed to load: ' + appName +
' in ' + defaultFindTimeout + 'ms' +
' appUrl = ' + appUrl +
' currentUrl = ' + currentUrl;
log.debug(msg);
throw new Error(msg);
}
return currentUrl;
});
});
}
return retry.tryForTime(defaultTryTimeout * 3, () => {
return navigateTo(appUrl)
.then(function (currentUrl) {
let lastUrl = currentUrl;
return retry.try(function () {
// give the app time to update the URL
return self.sleep(501)
.then(function () {
return remote.getCurrentUrl();
})
.then(function (currentUrl) {
log.debug('in navigateTo url = ' + currentUrl);
if (lastUrl !== currentUrl) {
lastUrl = currentUrl;
throw new Error('URL changed, waiting for it to settle');
}
});
});
})
.then(async () => {
if (appName === 'status_page') return;
if (await testSubjects.exists('statusPageContainer')) {
throw new Error('Navigation ended up at the status page.');
}
});
});
}
runScript(fn, timeout = 10000) {
// wait for deps on window before running script
return remote
.setExecuteAsyncTimeout(timeout)
.executeAsync(function (done) {
const interval = setInterval(function () {
const ready = (document.readyState === 'complete');
const hasJQuery = !!window.$;
if (ready && hasJQuery) {
console.log('doc ready, jquery loaded');
clearInterval(interval);
done();
}
}, 10);
}).then(function () {
return remote.execute(fn);
});
}
async sleep(sleepMilliseconds) {
log.debug('... sleep(' + sleepMilliseconds + ') start');
await delay(sleepMilliseconds);
log.debug('... sleep(' + sleepMilliseconds + ') end');
}
createErrorHandler(testObj) {
const testName = (testObj.parent) ? [testObj.parent.name, testObj.name].join('_') : testObj.name;
return error => {
const now = Date.now();
const fileName = `failure_${now}_${testName}`;
return this.saveScreenshot(fileName, true)
.then(function () {
throw error;
});
};
}
async waitUntilUrlIncludes(path) {
await retry.try(async () => {
const url = await remote.getCurrentUrl();
if (!url.includes(path)) {
throw new Error('Url not found');
}
});
}
async getSharedItemTitleAndDescription() {
const element = await remote
.setFindTimeout(defaultFindTimeout)
.findByCssSelector('[data-shared-item]');
return {
title: await element.getAttribute('data-title'),
description: await element.getAttribute('data-description')
};
}
/**
* Makes sure the modal overlay is not showing, tries a few times in case it is in the process of hiding.
*/
async ensureModalOverlayHidden() {
return retry.try(async () => {
const shown = await testSubjects.exists('modalOverlay');
if (shown) {
throw new Error('Modal overlay is showing');
}
});
}
async clickConfirmOnModal() {
log.debug('Clicking modal confirm');
await testSubjects.click('confirmModalConfirmButton');
await this.ensureModalOverlayHidden();
}
async pressEnterKey() {
await remote.pressKeys('\uE007');
}
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
async clickCancelOnModal() {
log.debug('Clicking modal cancel');
await testSubjects.click('confirmModalCancelButton');
await this.ensureModalOverlayHidden();
}
async isConfirmModalOpen() {
const isOpen = await testSubjects
.find('confirmModalCancelButton', 2000)
.then(() => true, () => false);
await remote.setFindTimeout(defaultFindTimeout);
return isOpen;
}
async doesCssSelectorExist(selector) {
log.debug(`doesCssSelectorExist ${selector}`);
const exists = await remote
.setFindTimeout(1000)
.findByCssSelector(selector)
.then(() => true)
.catch(() => false);
remote.setFindTimeout(defaultFindTimeout);
log.debug(`exists? ${exists}`);
return exists;
}
async isChromeVisible() {
return await testSubjects.exists('kibanaChrome');
}
[functionalTestRunner] replace intern (#10910) * [functional_test_runner] replace functional testing tools with custom/pluggable solution * [functional_test_runner] Convert unit tests to commonjs format * [functional_test_runner] Fix dashboard test in wrong mode * [functional_test_runner] Add dashboardLandingPage test subject * [functional_test_runner] Get Visualize page object * [functional_test_runner] Fix outdated references * [functional_test_runner] Fix more outdated refs * [functional_test_runner] Remove duplicate tests * [functional_test_runner] Improve test readability * [functional_test_runner] :disappointed: So many duplicate methods * [functional_test_runner] Move mgmt `before` outside toplevel describe * [functional_test_runner] Settings page obj missing methods * [functional_test_runner] Add improvements from @gammon * [functional_test_runner] Fix return statements in async funcs * [functional_test_runner] Move before() to correct scope * [functional_test_runner] Add after() hooks to remove index patterns * [functional_test_runner] Attempt to fix vertical bar chart tests * [functional_test_runner] Clean up * [functional_test_runner] Reinstate unit tests * [functional_test_runner] Set default loglevel back to info * [functional_test_runner] Replace `context`s with `describe`s * [functional_test_runner] Better error handling * [functional_test_runner] Add in new Tile Map tests * Incorporate changes from master * [functional_test_runner] validate that every test file has a single top-level suite * Update contributing doc with link to full doc * [docs] Spelling and grammar fixes * docs: writing and running functional tests * [docs] Move plugin doc to plugin area * [docs] Housekeeping. Doc in wrong place * [docs] Remove dup doc file * [grunt] Only run mocha_setup when running tests, not every grunt task
2017-04-12 00:01:06 +02:00
}
return new CommonPage();
}