From 536be5d5e0b4f27d8258655d252b2401d2fc0af2 Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Sat, 6 May 2017 07:36:16 -0400 Subject: [PATCH] test support (#11477) * test support * Move custom find timeout logic into find service * Fix the error in tests by combining the calls. Seems to work locally like this. --- src/ui/public/kbn_top_nav/kbn_top_nav.html | 3 ++- src/ui/public/notify/notifier.js | 1 + src/ui/public/notify/partials/toaster.html | 1 + test/functional/page_objects/header_page.js | 9 +++++---- test/functional/services/find.js | 8 ++++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ui/public/kbn_top_nav/kbn_top_nav.html b/src/ui/public/kbn_top_nav/kbn_top_nav.html index e3b8a05350f1a..1c881f4d36d24 100644 --- a/src/ui/public/kbn_top_nav/kbn_top_nav.html +++ b/src/ui/public/kbn_top_nav/kbn_top_nav.html @@ -28,7 +28,8 @@ tooltip-popup-delay="400" tooltip-append-to-body="1" data-test-subj="{{menuItem.testId}}" - > + > + diff --git a/src/ui/public/notify/notifier.js b/src/ui/public/notify/notifier.js index aabad4db4af11..5395e44089111 100644 --- a/src/ui/public/notify/notifier.js +++ b/src/ui/public/notify/notifier.js @@ -121,6 +121,7 @@ function add(notif, cb) { notif.customActions = notif.customActions.map((action, index) => { return { key: action.text, + dataTestSubj: action.dataTestSubj, callback: closeNotif(notif, action.callback, action.text), getButtonClass() { const buttonTypeClass = typeToButtonClassMap[notif.type]; diff --git a/src/ui/public/notify/partials/toaster.html b/src/ui/public/notify/partials/toaster.html index 2d1206e613f47..8699f5936053f 100644 --- a/src/ui/public/notify/partials/toaster.html +++ b/src/ui/public/notify/partials/toaster.html @@ -67,6 +67,7 @@ ng-class="action.getButtonClass()" ng-click="action.callback()" ng-bind="action.key" + data-test-subj="{{action.dataTestSubj}}" > diff --git a/test/functional/page_objects/header_page.js b/test/functional/page_objects/header_page.js index 285c20a66c9a0..b39c420527ed4 100644 --- a/test/functional/page_objects/header_page.js +++ b/test/functional/page_objects/header_page.js @@ -3,6 +3,7 @@ export function HeaderPageProvider({ getService, getPageObjects }) { const remote = getService('remote'); const log = getService('log'); const retry = getService('retry'); + const find = getService('find'); const testSubjects = getService('testSubjects'); const PageObjects = getPageObjects(['common']); @@ -162,10 +163,10 @@ export function HeaderPageProvider({ getService, getPageObjects }) { .findByLinkText(quickTime).click(); } - async getToastMessage() { - remote.setFindTimeout(defaultFindTimeout); - return await remote.findDisplayedByCssSelector('kbn-truncated.toast-message.ng-isolate-scope') - .getVisibleText(); + async getToastMessage(findTimeout = defaultFindTimeout) { + const toastMessage = + await find.displayedByCssSelector('kbn-truncated.toast-message.ng-isolate-scope', findTimeout); + return toastMessage.getVisibleText(); } async waitForToastMessageGone() { diff --git a/test/functional/services/find.js b/test/functional/services/find.js index bb21929e09e7f..f7d5d3c000b15 100644 --- a/test/functional/services/find.js +++ b/test/functional/services/find.js @@ -22,6 +22,14 @@ export function FindProvider({ getService }) { log.debug(`Found ${elements.length} for selector ${selector}`); return elements; } + + async displayedByCssSelector(selector, timeout = defaultFindTimeout) { + log.debug('in displayedByCssSelector: ' + selector); + const remoteWithTimeout = remote.setFindTimeout(timeout); + const element = await remoteWithTimeout.findDisplayedByCssSelector(selector); + remoteWithTimeout.setFindTimeout(defaultFindTimeout); + return element; + } } return new Find();