@@ -10,6 +10,9 @@ module('Acceptance | crates page', function(hooks) {
10
10
setupApplicationTest ( hooks ) ;
11
11
setupMirage ( hooks ) ;
12
12
13
+ // should match the default set in the crates controller
14
+ const per_page = 50 ;
15
+
13
16
test ( 'is accessible' , async function ( assert ) {
14
17
assert . expect ( 0 ) ;
15
18
@@ -53,23 +56,29 @@ module('Acceptance | crates page', function(hooks) {
53
56
} ) ;
54
57
55
58
test ( 'listing crates' , async function ( assert ) {
56
- this . server . loadFixtures ( ) ;
59
+ for ( let i = 1 ; i <= per_page ; i ++ ) {
60
+ this . server . create ( 'crate' ) ;
61
+ }
57
62
58
63
await visit ( '/crates' ) ;
59
64
60
- assert . dom ( '[data-test-crates-nav] [data-test-current-rows]' ) . hasText ( '1-10' ) ;
61
- assert . dom ( '[data-test-crates-nav] [data-test-total-rows]' ) . hasText ( '19' ) ;
65
+ assert . dom ( '[data-test-crates-nav] [data-test-current-rows]' ) . hasText ( `1- ${ per_page } ` ) ;
66
+ assert . dom ( '[data-test-crates-nav] [data-test-total-rows]' ) . hasText ( ` ${ per_page } ` ) ;
62
67
} ) ;
63
68
64
69
test ( 'navigating to next page of crates' , async function ( assert ) {
65
- this . server . loadFixtures ( ) ;
70
+ for ( let i = 1 ; i <= per_page + 2 ; i ++ ) {
71
+ this . server . create ( 'crate' ) ;
72
+ }
73
+ const page_start = per_page + 1 ;
74
+ const total = per_page + 2 ;
66
75
67
76
await visit ( '/crates' ) ;
68
77
await click ( '[data-test-pagination-next]' ) ;
69
78
70
79
assert . equal ( currentURL ( ) , '/crates?page=2' ) ;
71
- assert . dom ( '[data-test-crates-nav] [data-test-current-rows]' ) . hasText ( '11-19' ) ;
72
- assert . dom ( '[data-test-crates-nav] [data-test-total-rows]' ) . hasText ( '19' ) ;
80
+ assert . dom ( '[data-test-crates-nav] [data-test-current-rows]' ) . hasText ( ` ${ page_start } - ${ total } ` ) ;
81
+ assert . dom ( '[data-test-crates-nav] [data-test-total-rows]' ) . hasText ( ` ${ total } ` ) ;
73
82
} ) ;
74
83
75
84
test ( 'crates default sort is alphabetical' , async function ( assert ) {
0 commit comments