07831ab455
This closes #10146. Because of cibernox/ember-power-select#1203, which documents the current impossibility of attaching test selectors to a PowerSelect invocation, this uses test selectors on parent containers instead, occasionally adding wrappers when needed. I chose to leave the existing test selectors in the hopes that we can return to using them eventually, but I could easily remove them if it seems like extra noise now. Presumably for the same reason, @class no longer works, so this adjusts the scoping of global search CSS to preserve the style of the search control. I also included an update to the latest version of ember-test-selectors, since we were far behind and I tried that before finding the aforelinked issue. Finally, this replaces ember-cli-uglify with ember-cli-terser to address production build failures as described at ember-cli/ember-cli#9290.
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
import { pluralize } from 'ember-inflector';
|
|
import { test } from 'qunit';
|
|
import { selectChoose } from 'ember-power-select/test-support';
|
|
|
|
export default function pageSizeSelect({ resourceName, pageObject, pageObjectList, setup }) {
|
|
test(`the number of ${pluralize(
|
|
resourceName
|
|
)} is equal to the localStorage user setting for page size`, async function(assert) {
|
|
const storedPageSize = 10;
|
|
window.localStorage.nomadPageSize = storedPageSize;
|
|
|
|
await setup.call(this);
|
|
|
|
assert.equal(pageObjectList.length, storedPageSize);
|
|
assert.equal(pageObject.pageSizeSelect.selectedOption, storedPageSize);
|
|
});
|
|
|
|
test('when the page size user setting is unset, the default page size is 25', async function(assert) {
|
|
await setup.call(this);
|
|
|
|
assert.equal(pageObjectList.length, pageObject.pageSize);
|
|
assert.equal(pageObject.pageSizeSelect.selectedOption, pageObject.pageSize);
|
|
});
|
|
|
|
test(`changing the page size updates the ${pluralize(
|
|
resourceName
|
|
)} list and also updates the user setting in localStorage`, async function(assert) {
|
|
const desiredPageSize = 10;
|
|
|
|
await setup.call(this);
|
|
|
|
assert.equal(window.localStorage.nomadPageSize, null);
|
|
assert.equal(pageObjectList.length, pageObject.pageSize);
|
|
assert.equal(pageObject.pageSizeSelect.selectedOption, pageObject.pageSize);
|
|
|
|
await selectChoose('[data-test-page-size-select-parent]', desiredPageSize);
|
|
|
|
assert.equal(window.localStorage.nomadPageSize, desiredPageSize);
|
|
assert.equal(pageObjectList.length, desiredPageSize);
|
|
assert.equal(pageObject.pageSizeSelect.selectedOption, desiredPageSize);
|
|
});
|
|
}
|