From 5749ec1cc8cfe73df23aa978138b1873c70db280 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Thu, 18 Jun 2020 14:47:05 -0500 Subject: [PATCH] Change non-slash-stealing test to use page objects --- ui/tests/acceptance/jobs-list-test.js | 4 ++-- ui/tests/acceptance/search-test.js | 11 ++++------- ui/tests/pages/jobs/list.js | 7 +++++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ui/tests/acceptance/jobs-list-test.js b/ui/tests/acceptance/jobs-list-test.js index 1a23555abcb..bf0d7b1a55a 100644 --- a/ui/tests/acceptance/jobs-list-test.js +++ b/ui/tests/acceptance/jobs-list-test.js @@ -155,7 +155,7 @@ module('Acceptance | jobs list', function(hooks) { await JobsList.visit(); - await JobsList.search('dog'); + await JobsList.search.fillIn('dog'); assert.ok(JobsList.isEmpty, 'The empty message is shown'); assert.equal(JobsList.emptyState.headline, 'No Matches', 'The message is appropriate'); }); @@ -168,7 +168,7 @@ module('Acceptance | jobs list', function(hooks) { assert.equal(currentURL(), '/jobs?page=2', 'Page query param captures page=2'); - await JobsList.search('foobar'); + await JobsList.search.fillIn('foobar'); assert.equal(currentURL(), '/jobs?search=foobar', 'No page query param'); }); diff --git a/ui/tests/acceptance/search-test.js b/ui/tests/acceptance/search-test.js index c488476944c..3a8240223b7 100644 --- a/ui/tests/acceptance/search-test.js +++ b/ui/tests/acceptance/search-test.js @@ -1,8 +1,9 @@ import { module, test } from 'qunit'; -import { click, currentURL, triggerEvent, visit } from '@ember/test-helpers'; +import { currentURL, triggerEvent, visit } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; import PageLayout from 'nomad-ui/tests/pages/layout'; +import JobsList from 'nomad-ui/tests/pages/jobs/list'; import { selectSearch } from 'ember-power-select/test-support'; import sinon from 'sinon'; @@ -131,12 +132,8 @@ module('Acceptance | search', function(hooks) { assert.notOk(PageLayout.navbar.search.field.isPresent); - // FIXME use page objects for this and below? 🤔 - await click('.search-box input'); - - await triggerEvent('.search-box input', 'keydown', { - keyCode: 191, // slash - }); + await JobsList.search.click(); + await JobsList.search.keydown({ keyCode: 191 }); assert.notOk(PageLayout.navbar.search.field.isPresent); }); diff --git a/ui/tests/pages/jobs/list.js b/ui/tests/pages/jobs/list.js index 2cad7087e0f..425ede744b8 100644 --- a/ui/tests/pages/jobs/list.js +++ b/ui/tests/pages/jobs/list.js @@ -3,10 +3,10 @@ import { create, collection, clickable, - fillable, isPresent, property, text, + triggerable, visitable, } from 'ember-cli-page-object'; @@ -18,7 +18,10 @@ export default create({ visit: visitable('/jobs'), - search: fillable('[data-test-jobs-search] input'), + search: { + scope: '[data-test-jobs-search] input', + keydown: triggerable('keydown'), + }, runJobButton: { scope: '[data-test-run-job]',