Skip to content

Increase default results per page for crates page #1883

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 1 commit into from
Nov 2, 2019
Merged
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
2 changes: 1 addition & 1 deletion app/controllers/crates.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ export default Controller.extend(PaginationMixin, {
queryParams: ['letter', 'page', 'per_page', 'sort'],
letter: null,
page: '1',
per_page: 10,
per_page: 50,
sort: 'alpha',
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),

21 changes: 15 additions & 6 deletions tests/acceptance/crates-test.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@ module('Acceptance | crates page', function(hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);

// should match the default set in the crates controller
const per_page = 50;

test('is accessible', async function(assert) {
assert.expect(0);

@@ -53,23 +56,29 @@ module('Acceptance | crates page', function(hooks) {
});

test('listing crates', async function(assert) {
this.server.loadFixtures();
for (let i = 1; i <= per_page; i++) {
this.server.create('crate');
}

await visit('/crates');

assert.dom('[data-test-crates-nav] [data-test-current-rows]').hasText('1-10');
assert.dom('[data-test-crates-nav] [data-test-total-rows]').hasText('19');
assert.dom('[data-test-crates-nav] [data-test-current-rows]').hasText(`1-${per_page}`);
assert.dom('[data-test-crates-nav] [data-test-total-rows]').hasText(`${per_page}`);
});

test('navigating to next page of crates', async function(assert) {
this.server.loadFixtures();
for (let i = 1; i <= per_page + 2; i++) {
this.server.create('crate');
}
const page_start = per_page + 1;
const total = per_page + 2;

await visit('/crates');
await click('[data-test-pagination-next]');

assert.equal(currentURL(), '/crates?page=2');
assert.dom('[data-test-crates-nav] [data-test-current-rows]').hasText('11-19');
assert.dom('[data-test-crates-nav] [data-test-total-rows]').hasText('19');
assert.dom('[data-test-crates-nav] [data-test-current-rows]').hasText(`${page_start}-${total}`);
assert.dom('[data-test-crates-nav] [data-test-total-rows]').hasText(`${total}`);
});

test('crates default sort is alphabetical', async function(assert) {