Skip to content

Use "ember-native-dom-helpers" for simulated user actions #1140

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

Merged
merged 4 commits into from
Oct 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions app/templates/crate/version.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@
</ul>
</div>

<div class='section' id='crate-versions'>
<div class='section' id='crate-versions' data-test-versions>
<h3>Versions</h3>
<ul>
{{#each smallSortedVersions as |version|}}
<li>
{{#link-to 'crate.version' version.num}}
{{#link-to 'crate.version' version.num data-test-version-link=version.num}}
{{ version.num }}
{{/link-to}}
<span class='date'>{{moment-format version.created_at 'll'}}</span>
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"ember-maybe-import-regenerator": "^0.1.6",
"ember-metrics": "^0.10.0",
"ember-moment": "^7.3.1",
"ember-native-dom-helpers": "^0.5.4",
"ember-normalize": "^1.0.0",
"ember-page-title": "^3.2.1",
"ember-prism": "^0.1.0",
Expand Down
3 changes: 0 additions & 3 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
env: {
embertest: true
},
globals: {
'server': true,
'wait': true,
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/categories-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { visit } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | categories');
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/crate-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { click, visit, currentURL, currentRouteName } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | crate page');
Expand Down Expand Up @@ -123,6 +124,6 @@ test('crates license is supplied by version', async function(assert) {
await visit('/crates/nanomsg');
assert.dom('[data-test-license]').hasText('Apache-2.0');

await click('#crate-versions a:contains("0.5.0")');
await click('[data-test-version-link="0.5.0"]');
assert.dom('[data-test-license]').hasText('MIT/Apache-2.0');
});
1 change: 1 addition & 0 deletions tests/acceptance/crates-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { click, visit, currentURL } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | crates page');
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/front-page-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { visit, currentURL } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | front page');
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/keyword-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { visit } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | keywords');
Expand Down
35 changes: 11 additions & 24 deletions tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { fillIn, keyEvent, visit, triggerEvent, currentURL, blur } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | search');
Expand All @@ -8,10 +9,7 @@ test('searching for "rust"', async function(assert) {

await visit('/');
await fillIn('[data-test-search-input]', 'rust');

findWithAssert('[data-test-search-form]').submit();

await wait();
await triggerEvent('[data-test-search-form]', 'submit');

assert.equal(currentURL(), '/search?q=rust');
assert.equal(document.title, 'Search Results for \'rust\' - Cargo: packages for Rust');
Expand All @@ -31,38 +29,27 @@ test('searching for "rust"', async function(assert) {
test('pressing S key to focus the search bar', async function(assert) {
server.loadFixtures();

const KEYCODE_S = 83;
const KEYCODE_A = 65;

function assertSearchBarIsFocused() {
assert.dom('[data-test-search-input]').isFocused();
find('[data-test-search-input]').blur();
}

await visit('/');

findWithAssert('[data-test-search-input]').blur();

await keyEvent(document, 'keypress', KEYCODE_A);
await blur('[data-test-search-input]');
await keyEvent(document, 'keypress', 'a');
assert.dom('[data-test-search-input]').isNotFocused();
find('[data-test-search-input]').blur();

await keyEvent(document, 'keypress', KEYCODE_S);
assertSearchBarIsFocused();
await blur('[data-test-search-input]');
await keyEvent(document, 'keypress', 's');
assert.dom('[data-test-search-input]').isFocused();

await keyEvent(document, 'keydown', KEYCODE_S);
assertSearchBarIsFocused();
await blur('[data-test-search-input]');
await keyEvent(document, 'keydown', 's');
assert.dom('[data-test-search-input]').isFocused();
});

test('check search results are by default displayed by relevance', async function(assert) {
server.loadFixtures();

await visit('/');
await fillIn('[data-test-search-input]', 'rust');

findWithAssert('[data-test-search-form]').submit();

await wait();
await triggerEvent('[data-test-search-form]', 'submit');

assert.dom('[data-test-search-sort] [data-test-current-order]').hasText('Relevance');
});
1 change: 1 addition & 0 deletions tests/acceptance/team-page-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { visit } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | team page');
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/user-page-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from 'qunit';
import { visit } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';

moduleForAcceptance('Acceptance | user page');
Expand Down