@@ -3,63 +3,60 @@ import moduleForAcceptance from 'cargo/tests/helpers/module-for-acceptance';
3
3
4
4
moduleForAcceptance ( 'Acceptance | search' ) ;
5
5
6
- test ( 'searching for "rust"' , function ( assert ) {
7
- visit ( '/' ) ;
8
- fillIn ( 'input.search' , 'rust' ) ;
9
- andThen ( function ( ) {
10
- findWithAssert ( 'form.search' ) . submit ( ) ;
11
- } ) ;
12
- wait ( ) ;
13
-
14
- andThen ( function ( ) {
15
- assert . equal ( currentURL ( ) , '/search?q=rust' ) ;
16
- assert . equal ( document . title , 'Search Results for \'rust\' - Cargo: packages for Rust' ) ;
17
-
18
- findWithAssert ( 'a[href="/search?page=2&q=rust"]' ) ;
19
- assert . notOk ( find ( 'a[href="/search?page=3&q=rust"]' ) [ 0 ] ) ;
20
-
21
- hasText ( assert , '#crates-heading' , 'Search Results for \'rust\'' ) ;
22
- hasText ( assert , '#results' , 'Displaying 1-10 of 18 total results Sort by Relevance Relevance Downloads' ) ;
23
-
24
- hasText ( assert , '#crates .row:first .desc .info' , 'rust_mixin' ) ;
25
- findWithAssert ( '#crates .row:first .desc .info .vers img[alt="0.0.1"]' ) ;
26
-
27
- findWithAssert ( '#crates .row:first .desc .info .badge:first a[href="https://ci.appveyor.com/project/huonw/external_mixin"]' ) ;
28
- findWithAssert ( '#crates .row:first .desc .info .badge:first a img[src="https://ci.appveyor.com/api/projects/status/github/huonw/external_mixin?svg=true&branch=master"]' ) ;
29
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(1) a[href="https://codecov.io/github/huonw/external_mixin?branch=master"]' ) ;
30
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(1) a img[src="https://codecov.io/github/huonw/external_mixin/coverage.svg?branch=master"]' ) ;
31
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(2) a[href="https://coveralls.io/github/huonw/external_mixin?branch=master"]' ) ;
32
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(2) a img[src="https://coveralls.io/repos/github/huonw/external_mixin/badge.svg?branch=master"]' ) ;
33
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(3) a[href="https://gitlab.com/huonw/external_mixin/pipelines"]' ) ;
34
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(3) a img[src="https://gitlab.com/huonw/external_mixin/badges/master/build.svg"]' ) ;
35
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(4) a[href="https://isitmaintained.com/project/huonw/external_mixin"]' ) ;
36
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(4) a img[src="https://isitmaintained.com/badge/resolution/huonw/external_mixin.svg"]' ) ;
37
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(5) a[href="https://isitmaintained.com/project/huonw/external_mixin"]' ) ;
38
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(5) a img[src="https://isitmaintained.com/badge/open/huonw/external_mixin.svg"]' ) ;
39
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(6) a[href="https://travis-ci.org/huonw/external_mixin"]' ) ;
40
- findWithAssert ( '#crates .row:first .desc .info .badge:eq(6) a img[src="https://travis-ci.org/huonw/external_mixin.svg?branch=master"]' ) ;
41
-
42
- hasText ( assert , '#crates .row:first .desc .summary' , 'Yo dawg, use Rust to generate Rust, right in your Rust. (See `external_mixin` to use scripting languages.)' ) ;
43
- hasText ( assert , '#crates .row:first .downloads' , '477' ) ;
44
- } ) ;
45
- click ( 'a[href="/search?page=2&q=rust"]' ) ;
46
-
47
- andThen ( function ( ) {
48
- assert . equal ( currentURL ( ) , '/search?page=2&q=rust' ) ;
49
- assert . equal ( document . title , 'Search Results for \'rust\' - Cargo: packages for Rust' ) ;
50
-
51
- findWithAssert ( 'a[href="/search?q=rust"]' ) ;
52
- assert . notOk ( find ( 'a[href="/search?page=3&q=rust"]' ) [ 0 ] ) ;
53
-
54
- hasText ( assert , '#crates-heading' , 'Search Results for \'rust\'' ) ;
55
- hasText ( assert , '#results' , 'Displaying 11-18 of 18 total results Sort by Relevance Relevance Downloads' ) ;
56
-
57
- hasText ( assert , '#crates .row:first .desc .info' , 'rusted_cypher' ) ;
58
- findWithAssert ( '#crates .row:first .desc .info .vers img[alt="0.7.1"]' ) ;
59
- } ) ;
6
+ test ( 'searching for "rust"' , async function ( assert ) {
7
+ await visit ( '/' ) ;
8
+ await fillIn ( 'input.search' , 'rust' ) ;
9
+
10
+ findWithAssert ( 'form.search' ) . submit ( ) ;
11
+
12
+ await wait ( ) ;
13
+
14
+ assert . equal ( currentURL ( ) , '/search?q=rust' ) ;
15
+ assert . equal ( document . title , 'Search Results for \'rust\' - Cargo: packages for Rust' ) ;
16
+
17
+ findWithAssert ( 'a[href="/search?page=2&q=rust"]' ) ;
18
+ assert . notOk ( find ( 'a[href="/search?page=3&q=rust"]' ) [ 0 ] ) ;
19
+
20
+ hasText ( assert , '#crates-heading' , 'Search Results for \'rust\'' ) ;
21
+ hasText ( assert , '#results' , 'Displaying 1-10 of 18 total results Sort by Relevance Relevance Downloads' ) ;
22
+
23
+ hasText ( assert , '#crates .row:first .desc .info' , 'rust_mixin' ) ;
24
+ findWithAssert ( '#crates .row:first .desc .info .vers img[alt="0.0.1"]' ) ;
25
+
26
+ findWithAssert ( '#crates .row:first .desc .info .badge:first a[href="https://ci.appveyor.com/project/huonw/external_mixin"]' ) ;
27
+ findWithAssert ( '#crates .row:first .desc .info .badge:first a img[src="https://ci.appveyor.com/api/projects/status/github/huonw/external_mixin?svg=true&branch=master"]' ) ;
28
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(1) a[href="https://codecov.io/github/huonw/external_mixin?branch=master"]' ) ;
29
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(1) a img[src="https://codecov.io/github/huonw/external_mixin/coverage.svg?branch=master"]' ) ;
30
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(2) a[href="https://coveralls.io/github/huonw/external_mixin?branch=master"]' ) ;
31
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(2) a img[src="https://coveralls.io/repos/github/huonw/external_mixin/badge.svg?branch=master"]' ) ;
32
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(3) a[href="https://gitlab.com/huonw/external_mixin/pipelines"]' ) ;
33
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(3) a img[src="https://gitlab.com/huonw/external_mixin/badges/master/build.svg"]' ) ;
34
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(4) a[href="https://isitmaintained.com/project/huonw/external_mixin"]' ) ;
35
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(4) a img[src="https://isitmaintained.com/badge/resolution/huonw/external_mixin.svg"]' ) ;
36
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(5) a[href="https://isitmaintained.com/project/huonw/external_mixin"]' ) ;
37
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(5) a img[src="https://isitmaintained.com/badge/open/huonw/external_mixin.svg"]' ) ;
38
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(6) a[href="https://travis-ci.org/huonw/external_mixin"]' ) ;
39
+ findWithAssert ( '#crates .row:first .desc .info .badge:eq(6) a img[src="https://travis-ci.org/huonw/external_mixin.svg?branch=master"]' ) ;
40
+
41
+ hasText ( assert , '#crates .row:first .desc .summary' , 'Yo dawg, use Rust to generate Rust, right in your Rust. (See `external_mixin` to use scripting languages.)' ) ;
42
+ hasText ( assert , '#crates .row:first .downloads' , '477' ) ;
43
+
44
+ await click ( 'a[href="/search?page=2&q=rust"]' ) ;
45
+
46
+ assert . equal ( currentURL ( ) , '/search?page=2&q=rust' ) ;
47
+ assert . equal ( document . title , 'Search Results for \'rust\' - Cargo: packages for Rust' ) ;
48
+
49
+ findWithAssert ( 'a[href="/search?q=rust"]' ) ;
50
+ assert . notOk ( find ( 'a[href="/search?page=3&q=rust"]' ) [ 0 ] ) ;
51
+
52
+ hasText ( assert , '#crates-heading' , 'Search Results for \'rust\'' ) ;
53
+ hasText ( assert , '#results' , 'Displaying 11-18 of 18 total results Sort by Relevance Relevance Downloads' ) ;
54
+
55
+ hasText ( assert , '#crates .row:first .desc .info' , 'rusted_cypher' ) ;
56
+ findWithAssert ( '#crates .row:first .desc .info .vers img[alt="0.7.1"]' ) ;
60
57
} ) ;
61
58
62
- test ( 'pressing S key to focus the search bar' , function ( assert ) {
59
+ test ( 'pressing S key to focus the search bar' , async function ( assert ) {
63
60
const KEYCODE_S = 83 ;
64
61
const KEYCODE_A = 65 ;
65
62
@@ -69,20 +66,19 @@ test('pressing S key to focus the search bar', function(assert) {
69
66
$searchBar . blur ( ) ;
70
67
}
71
68
72
- visit ( '/' ) ;
73
- andThen ( function ( ) {
74
- findWithAssert ( '#cargo-desktop-search' ) . blur ( ) ;
75
- } ) ;
69
+ await visit ( '/' ) ;
76
70
77
- keyEvent ( document , 'keypress' , KEYCODE_A ) ;
78
- andThen ( function assertSearchBarIsNotFocused ( ) {
79
- const $searchBar = find ( '#cargo-desktop-search' ) ;
80
- assert . notEqual ( $searchBar [ 0 ] , document . activeElement ) ;
81
- $searchBar . blur ( ) ;
82
- } ) ;
71
+ findWithAssert ( '#cargo-desktop-search' ) . blur ( ) ;
72
+
73
+ await keyEvent ( document , 'keypress' , KEYCODE_A ) ;
74
+
75
+ const $searchBar = find ( '#cargo-desktop-search' ) ;
76
+ assert . notEqual ( $searchBar [ 0 ] , document . activeElement ) ;
77
+ $searchBar . blur ( ) ;
78
+
79
+ await keyEvent ( document , 'keypress' , KEYCODE_S ) ;
80
+ assertSearchBarIsFocused ( ) ;
83
81
84
- keyEvent ( document , 'keypress' , KEYCODE_S ) ;
85
- andThen ( assertSearchBarIsFocused ) ;
86
- keyEvent ( document , 'keydown' , KEYCODE_S ) ;
87
- andThen ( assertSearchBarIsFocused ) ;
82
+ await keyEvent ( document , 'keydown' , KEYCODE_S ) ;
83
+ assertSearchBarIsFocused ( ) ;
88
84
} ) ;
0 commit comments