Skip to content

Commit

Permalink
Change non-slash-stealing test to use page objects
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Jun 18, 2020
1 parent 894de23 commit 5749ec1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ui/tests/acceptance/jobs-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -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');
});
Expand Down
11 changes: 4 additions & 7 deletions ui/tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
});
Expand Down
7 changes: 5 additions & 2 deletions ui/tests/pages/jobs/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import {
create,
collection,
clickable,
fillable,
isPresent,
property,
text,
triggerable,
visitable,
} from 'ember-cli-page-object';

Expand All @@ -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]',
Expand Down

0 comments on commit 5749ec1

Please sign in to comment.