open-nomad/ui/tests/acceptance/clients-list-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

534 lines
16 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
/* eslint-disable qunit/require-expect */
import { currentURL, settled } from '@ember/test-helpers';
2019-03-13 00:04:16 +00:00
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
2019-09-26 18:47:07 +00:00
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import pageSizeSelect from './behaviors/page-size-select';
2018-07-10 08:11:27 +00:00
import ClientsList from 'nomad-ui/tests/pages/clients/list';
import percySnapshot from '@percy/ember';
import faker from 'nomad-ui/mirage/faker';
2017-09-19 14:47:10 +00:00
2021-12-28 14:45:20 +00:00
module('Acceptance | clients list', function (hooks) {
2019-03-13 00:04:16 +00:00
setupApplicationTest(hooks);
2019-03-13 01:09:19 +00:00
setupMirage(hooks);
2017-09-19 14:47:10 +00:00
2021-12-28 14:45:20 +00:00
hooks.beforeEach(function () {
window.localStorage.clear();
server.createList('node-pool', 3);
});
2021-12-28 14:45:20 +00:00
test('it passes an accessibility audit', async function (assert) {
const nodesCount = ClientsList.pageSize + 1;
server.createList('node', nodesCount);
server.createList('agent', 1);
await ClientsList.visit();
await a11yAudit(assert);
});
2021-12-28 14:45:20 +00:00
test('/clients should list one page of clients', async function (assert) {
faker.seed(1);
2019-03-13 00:04:16 +00:00
// Make sure to make more nodes than 1 page to assert that pagination is working
const nodesCount = ClientsList.pageSize + 1;
2019-03-13 00:04:16 +00:00
server.createList('node', nodesCount);
server.createList('agent', 1);
2017-09-19 14:47:10 +00:00
await ClientsList.visit();
2017-09-19 14:47:10 +00:00
await percySnapshot(assert);
assert.equal(ClientsList.nodes.length, ClientsList.pageSize);
2018-07-10 08:11:27 +00:00
assert.ok(ClientsList.hasPagination, 'Pagination found on the page');
2017-09-19 14:47:10 +00:00
const sortedNodes = server.db.nodes.sortBy('modifyIndex').reverse();
2018-07-10 08:11:27 +00:00
ClientsList.nodes.forEach((node, index) => {
2021-12-28 16:08:12 +00:00
assert.equal(
node.id,
sortedNodes[index].id.split('-')[0],
'Clients are ordered'
);
2018-07-10 08:11:27 +00:00
});
assert.ok(document.title.includes('Clients'));
2017-09-19 14:47:10 +00:00
});
2021-12-28 14:45:20 +00:00
test('each client record should show high-level info of the client', async function (assert) {
const node = server.create('node', 'draining', {
status: 'ready',
});
server.createList('agent', 1);
2017-09-19 14:47:10 +00:00
await ClientsList.visit();
2017-09-19 14:47:10 +00:00
2018-07-10 08:11:27 +00:00
const nodeRow = ClientsList.nodes.objectAt(0);
2017-09-19 14:47:10 +00:00
const allocations = server.db.allocations.where({ nodeId: node.id });
2018-07-10 08:11:27 +00:00
assert.equal(nodeRow.id, node.id.split('-')[0], 'ID');
assert.equal(nodeRow.name, node.name, 'Name');
assert.equal(nodeRow.nodePool, node.nodePool, 'Node Pool');
assert.equal(
nodeRow.compositeStatus.text,
'draining',
'Combined status, draining, and eligbility'
);
2018-07-10 08:11:27 +00:00
assert.equal(nodeRow.address, node.httpAddr);
assert.equal(nodeRow.datacenter, node.datacenter, 'Datacenter');
assert.equal(nodeRow.version, node.version, 'Version');
2018-07-10 08:11:27 +00:00
assert.equal(nodeRow.allocations, allocations.length, '# Allocations');
2017-09-19 14:47:10 +00:00
});
2021-12-28 14:45:20 +00:00
test('each client record should show running allocations', async function (assert) {
server.createList('agent', 1);
const node = server.create('node', {
modifyIndex: 4,
status: 'ready',
schedulingEligibility: 'eligible',
drain: false,
});
server.create('job', { createAllocations: false });
2021-12-28 16:08:12 +00:00
const running = server.createList('allocation', 2, {
clientStatus: 'running',
});
server.createList('allocation', 3, { clientStatus: 'pending' });
server.createList('allocation', 10, { clientStatus: 'complete' });
await ClientsList.visit();
const nodeRow = ClientsList.nodes.objectAt(0);
assert.equal(nodeRow.id, node.id.split('-')[0], 'ID');
assert.equal(
nodeRow.compositeStatus.text,
'ready',
'Combined status, draining, and eligbility'
);
assert.equal(nodeRow.allocations, running.length, '# Allocations');
});
2021-12-28 14:45:20 +00:00
test('client status, draining, and eligibility are collapsed into one column that stays sorted', async function (assert) {
server.createList('agent', 1);
server.create('node', {
modifyIndex: 5,
status: 'ready',
schedulingEligibility: 'eligible',
drain: false,
});
server.create('node', {
modifyIndex: 4,
status: 'initializing',
schedulingEligibility: 'eligible',
drain: false,
});
server.create('node', {
modifyIndex: 3,
status: 'down',
schedulingEligibility: 'eligible',
drain: false,
});
server.create('node', {
modifyIndex: 2,
status: 'down',
schedulingEligibility: 'ineligible',
drain: false,
});
server.create('node', {
modifyIndex: 1,
status: 'ready',
schedulingEligibility: 'ineligible',
drain: false,
});
server.create('node', 'draining', {
modifyIndex: 0,
status: 'ready',
});
await ClientsList.visit();
2021-12-28 14:45:20 +00:00
ClientsList.nodes[0].compositeStatus.as((readyClient) => {
assert.equal(readyClient.text, 'ready');
assert.ok(readyClient.isUnformatted, 'expected no status class');
assert.equal(readyClient.tooltip, 'ready / not draining / eligible');
});
assert.equal(ClientsList.nodes[1].compositeStatus.text, 'initializing');
assert.equal(ClientsList.nodes[2].compositeStatus.text, 'down');
assert.equal(
ClientsList.nodes[2].compositeStatus.text,
'down',
'down takes priority over ineligible'
);
assert.equal(ClientsList.nodes[4].compositeStatus.text, 'ineligible');
2021-12-28 16:08:12 +00:00
assert.ok(
ClientsList.nodes[4].compositeStatus.isWarning,
'expected warning class'
);
assert.equal(ClientsList.nodes[5].compositeStatus.text, 'draining');
2021-12-28 16:08:12 +00:00
assert.ok(
ClientsList.nodes[5].compositeStatus.isInfo,
'expected info class'
);
await ClientsList.sortBy('compositeStatus');
Upgrade Ember and friends 3.28 (#12215) * chore: upgrade forward compatible packages * chore: v3.20.2...v3.24.0 * chore: silence string prototype extension deprecation * refact: don't test clicking disabled button job-list Recent test-helper upgrades will guard against clicking disabled buttons as this is not something that real users can do. We need to change our tests accordingly. * fix: await async test helper `expectError` We have to await this async test function otherwise the test's rendering context will be torn down before we run assertions against it. * fix: don't try to click disabled two-step-button Recent test-helper updates prohibit clicking disabled buttons. We need to adapt the tests accordingly. * fix: recommendation-accordion Use up-to-date semantics for handling list-accordion closing in recommendation-accordion. * fixes toggling recommendation-accordion toggle. * fix: simple-unless linting error application.hbs There's no reason to use unless here - we can use if instead. * fix: no-quoteless-attributes recommendation accordion * fix: no-quoteless-attributes recommendation-chart * fix: allow `unless` - global-header.hbs This is a valid use of unless in our opinion. * fix: allow unless in job-diff This is not a great use for unless but we don't want to change this behavior atm. * fix: no-attrs-in-components list-pager There is no need to use this.attrs in classic components. When we will convert to glimmer we will use `@`-instead. * fix: simple-unless job/definition We can convert to a simple if here. * fix: allow inline-styles stats-box component To make linter happy. * fix: disable no-action and no-invalid-interactive Will be adressed in follow-up PRs. * chore: update ember-classic-decorator to latest * chore: upgrade ember-can to latest * chore: upgrade ember-composable-helpers to latest * chore: upgrade ember-concurrency * fix: recomputation deprecation `Trigger` schedule `do` on actions queue to work around recomputation deprecation when triggering Trigger on `did-insert`. * chore: upgrade ember-cli-string-helpers * chore: upgrade ember-copy * chore: upgrade ember-data-model-fragments * chore: upgrade ember-deprecation-workflow * chore: upgrade ember-inline-svg * chore: upgrade ember-modifier * chore: upgrade ember-truth-helpers * chore: upgrade ember-moment & ember-cli-moment-shim * chore: upgrade ember-power-select * chore: upgrade ember-responsive * chore: upgrade ember-sinon * chore: upgrade ember-cli-mirage For now we will stay on 2.2 - upgrades > 2.3 break the build. * chore: upgrade 3.24.0 to 3.28.5 * fix: add missing classic decorators on adapters * fix: missing classic decorators to serializers * fix: don't reopen Ember.Object anymore * fix: remove unused useNativeEvents ember-cli-page-objects doesn't provide this method anymore * fix: add missing attributeBindings for test-selectors ember-test-selectors doesn't provides automatic bindings for data-test-* attributes anymore. * fix: classic decorator for application serializer test * fix: remove `removeContext` from tests. It is unneeded and ember-cli-page-objects doesn't provides this method anymore. * fix: remove deprecations `run.*`-invocations * fix: `collapseWhitespace` in optimize test * fix: make sure to load async relationship before access * fix: dependent keys for relationship computeds We need to add `*.isFulfilled` as dependent keys for computeds that access async relationships. * fix: `computed.read`-invocations use `read` instead * chore: prettify templates * fix: use map instead of mapBy ember-cli-page-object Doesn't work with updated ember-cli-page-object anymore. * fix: remove remaining deprecated `run.*`-calls * chore: add more deprecations deprecation-workflow * fix: `implicit-injection`-deprecation All routes that add watchers will need to inject the store-service as the store service is internally used in watchers. * fix: more implicit injection deprecations * chore: silence implicit-injection deprecation We can tackle the deprecation when we find the time. * fix: new linting errors after upgrade * fix: remove merge conflicts prettierignore * chore: upgrade to run node 12.22 when building binaries
2022-03-08 17:28:36 +00:00
assert.deepEqual(
ClientsList.nodes.map((n) => n.compositeStatus.text),
['ready', 'initializing', 'ineligible', 'draining', 'down', 'down']
);
// Simulate a client state change arriving through polling
2021-12-28 16:08:12 +00:00
let readyClient = this.owner
.lookup('service:store')
.peekAll('node')
.findBy('modifyIndex', 5);
readyClient.set('schedulingEligibility', 'ineligible');
await settled();
Upgrade Ember and friends 3.28 (#12215) * chore: upgrade forward compatible packages * chore: v3.20.2...v3.24.0 * chore: silence string prototype extension deprecation * refact: don't test clicking disabled button job-list Recent test-helper upgrades will guard against clicking disabled buttons as this is not something that real users can do. We need to change our tests accordingly. * fix: await async test helper `expectError` We have to await this async test function otherwise the test's rendering context will be torn down before we run assertions against it. * fix: don't try to click disabled two-step-button Recent test-helper updates prohibit clicking disabled buttons. We need to adapt the tests accordingly. * fix: recommendation-accordion Use up-to-date semantics for handling list-accordion closing in recommendation-accordion. * fixes toggling recommendation-accordion toggle. * fix: simple-unless linting error application.hbs There's no reason to use unless here - we can use if instead. * fix: no-quoteless-attributes recommendation accordion * fix: no-quoteless-attributes recommendation-chart * fix: allow `unless` - global-header.hbs This is a valid use of unless in our opinion. * fix: allow unless in job-diff This is not a great use for unless but we don't want to change this behavior atm. * fix: no-attrs-in-components list-pager There is no need to use this.attrs in classic components. When we will convert to glimmer we will use `@`-instead. * fix: simple-unless job/definition We can convert to a simple if here. * fix: allow inline-styles stats-box component To make linter happy. * fix: disable no-action and no-invalid-interactive Will be adressed in follow-up PRs. * chore: update ember-classic-decorator to latest * chore: upgrade ember-can to latest * chore: upgrade ember-composable-helpers to latest * chore: upgrade ember-concurrency * fix: recomputation deprecation `Trigger` schedule `do` on actions queue to work around recomputation deprecation when triggering Trigger on `did-insert`. * chore: upgrade ember-cli-string-helpers * chore: upgrade ember-copy * chore: upgrade ember-data-model-fragments * chore: upgrade ember-deprecation-workflow * chore: upgrade ember-inline-svg * chore: upgrade ember-modifier * chore: upgrade ember-truth-helpers * chore: upgrade ember-moment & ember-cli-moment-shim * chore: upgrade ember-power-select * chore: upgrade ember-responsive * chore: upgrade ember-sinon * chore: upgrade ember-cli-mirage For now we will stay on 2.2 - upgrades > 2.3 break the build. * chore: upgrade 3.24.0 to 3.28.5 * fix: add missing classic decorators on adapters * fix: missing classic decorators to serializers * fix: don't reopen Ember.Object anymore * fix: remove unused useNativeEvents ember-cli-page-objects doesn't provide this method anymore * fix: add missing attributeBindings for test-selectors ember-test-selectors doesn't provides automatic bindings for data-test-* attributes anymore. * fix: classic decorator for application serializer test * fix: remove `removeContext` from tests. It is unneeded and ember-cli-page-objects doesn't provides this method anymore. * fix: remove deprecations `run.*`-invocations * fix: `collapseWhitespace` in optimize test * fix: make sure to load async relationship before access * fix: dependent keys for relationship computeds We need to add `*.isFulfilled` as dependent keys for computeds that access async relationships. * fix: `computed.read`-invocations use `read` instead * chore: prettify templates * fix: use map instead of mapBy ember-cli-page-object Doesn't work with updated ember-cli-page-object anymore. * fix: remove remaining deprecated `run.*`-calls * chore: add more deprecations deprecation-workflow * fix: `implicit-injection`-deprecation All routes that add watchers will need to inject the store-service as the store service is internally used in watchers. * fix: more implicit injection deprecations * chore: silence implicit-injection deprecation We can tackle the deprecation when we find the time. * fix: new linting errors after upgrade * fix: remove merge conflicts prettierignore * chore: upgrade to run node 12.22 when building binaries
2022-03-08 17:28:36 +00:00
assert.deepEqual(
ClientsList.nodes.map((n) => n.compositeStatus.text),
['initializing', 'ineligible', 'ineligible', 'draining', 'down', 'down']
);
});
2021-12-28 14:45:20 +00:00
test('each client should link to the client detail page', async function (assert) {
server.createList('node', 1);
server.createList('agent', 1);
2019-03-13 00:04:16 +00:00
const node = server.db.nodes[0];
2017-09-19 14:47:10 +00:00
await ClientsList.visit();
await ClientsList.nodes.objectAt(0).clickRow();
2017-09-19 14:47:10 +00:00
2017-10-28 01:23:41 +00:00
assert.equal(currentURL(), `/clients/${node.id}`);
2017-09-19 14:47:10 +00:00
});
2021-12-28 14:45:20 +00:00
test('when there are no clients, there is an empty message', async function (assert) {
faker.seed(1);
2019-03-13 00:04:16 +00:00
server.createList('agent', 1);
2017-09-30 01:33:57 +00:00
await ClientsList.visit();
2017-09-30 01:33:57 +00:00
await percySnapshot(assert);
2018-07-10 08:11:27 +00:00
assert.ok(ClientsList.isEmpty);
assert.equal(ClientsList.empty.headline, 'No Clients');
2017-09-30 01:33:57 +00:00
});
2021-12-28 14:45:20 +00:00
test('when there are clients, but no matches for a search term, there is an empty message', async function (assert) {
2019-03-13 00:04:16 +00:00
server.createList('agent', 1);
server.create('node', { name: 'node' });
2017-09-30 01:33:57 +00:00
await ClientsList.visit();
2017-09-30 01:33:57 +00:00
await ClientsList.search('client');
2018-07-10 08:11:27 +00:00
assert.ok(ClientsList.isEmpty);
assert.equal(ClientsList.empty.headline, 'No Matches');
2017-09-30 01:33:57 +00:00
});
2021-12-28 14:45:20 +00:00
test('when accessing clients is forbidden, show a message with a link to the tokens page', async function (assert) {
2019-03-13 00:04:16 +00:00
server.create('agent');
server.create('node', { name: 'node' });
server.pretender.get('/v1/nodes', () => [403, {}, null]);
await ClientsList.visit();
2018-07-10 08:11:27 +00:00
assert.equal(ClientsList.error.title, 'Not Authorized');
await ClientsList.error.seekHelp();
assert.equal(currentURL(), '/settings/tokens');
});
pageSizeSelect({
resourceName: 'client',
pageObject: ClientsList,
pageObjectList: ClientsList.nodes,
async setup() {
server.createList('node', ClientsList.pageSize);
server.createList('agent', 1);
await ClientsList.visit();
},
});
2019-03-13 00:04:16 +00:00
testFacet('Class', {
facet: ClientsList.facets.class,
paramName: 'class',
expectedOptions(nodes) {
return Array.from(new Set(nodes.mapBy('nodeClass'))).sort();
},
async beforeEach() {
2019-03-13 00:04:16 +00:00
server.create('agent');
server.createList('node', 2, { nodeClass: 'nc-one' });
server.createList('node', 2, { nodeClass: 'nc-two' });
server.createList('node', 2, { nodeClass: 'nc-three' });
await ClientsList.visit();
2019-03-13 00:04:16 +00:00
},
filter: (node, selection) => selection.includes(node.nodeClass),
});
testFacet('State', {
facet: ClientsList.facets.state,
paramName: 'state',
2021-12-28 16:08:12 +00:00
expectedOptions: [
'Initializing',
'Ready',
'Down',
'Ineligible',
'Draining',
'Disconnected',
2021-12-28 16:08:12 +00:00
],
async beforeEach() {
2019-03-13 00:04:16 +00:00
server.create('agent');
2019-03-13 00:04:16 +00:00
server.createList('node', 2, { status: 'initializing' });
server.createList('node', 2, { status: 'ready' });
server.createList('node', 2, { status: 'down' });
2021-12-28 16:08:12 +00:00
server.createList('node', 2, {
schedulingEligibility: 'eligible',
drain: false,
});
server.createList('node', 2, {
schedulingEligibility: 'ineligible',
drain: false,
});
server.createList('node', 2, {
schedulingEligibility: 'ineligible',
drain: true,
});
await ClientsList.visit();
2019-03-13 00:04:16 +00:00
},
filter: (node, selection) => {
if (selection.includes('draining') && !node.drain) return false;
2021-12-28 16:08:12 +00:00
if (
selection.includes('ineligible') &&
node.schedulingEligibility === 'eligible'
)
return false;
return selection.includes(node.status);
},
2019-03-13 00:04:16 +00:00
});
testFacet('Node Pools', {
facet: ClientsList.facets.nodePools,
paramName: 'nodePool',
expectedOptions() {
return server.db.nodePools
.filter((p) => p.name !== 'all') // The node pool 'all' should not be a filter.
.map((p) => p.name);
},
async beforeEach() {
server.create('agent');
server.create('node-pool', { name: 'all' });
server.create('node-pool', { name: 'default' });
server.createList('node-pool', 10);
// Make sure each node pool has at least one node.
server.db.nodePools.forEach((p) => {
server.createList('node', 2, { nodePool: p.name });
});
await ClientsList.visit();
},
filter: (node, selection) => selection.includes(node.nodePool),
});
2019-03-13 00:04:16 +00:00
testFacet('Datacenters', {
facet: ClientsList.facets.datacenter,
paramName: 'dc',
expectedOptions(nodes) {
return Array.from(new Set(nodes.mapBy('datacenter'))).sort();
},
async beforeEach() {
2019-03-13 00:04:16 +00:00
server.create('agent');
server.createList('node', 2, { datacenter: 'pdx-1' });
server.createList('node', 2, { datacenter: 'nyc-1' });
server.createList('node', 2, { datacenter: 'ams-1' });
await ClientsList.visit();
2019-03-13 00:04:16 +00:00
},
filter: (node, selection) => selection.includes(node.datacenter),
});
testFacet('Versions', {
facet: ClientsList.facets.version,
paramName: 'version',
expectedOptions(nodes) {
return Array.from(new Set(nodes.mapBy('version'))).sort();
},
async beforeEach() {
server.create('agent');
server.createList('node', 2, { version: '0.12.0' });
server.createList('node', 2, { version: '1.1.0-beta1' });
server.createList('node', 2, { version: '1.2.0+ent' });
await ClientsList.visit();
},
filter: (node, selection) => selection.includes(node.version),
});
2020-03-13 18:31:06 +00:00
testFacet('Volumes', {
facet: ClientsList.facets.volume,
paramName: 'volume',
expectedOptions(nodes) {
const flatten = (acc, val) => acc.concat(Object.keys(val));
2021-12-28 16:08:12 +00:00
return Array.from(
new Set(nodes.mapBy('hostVolumes').reduce(flatten, []))
);
2020-03-13 18:31:06 +00:00
},
async beforeEach() {
server.create('agent');
server.createList('node', 2, { hostVolumes: { One: { Name: 'One' } } });
2021-12-28 16:08:12 +00:00
server.createList('node', 2, {
hostVolumes: { One: { Name: 'One' }, Two: { Name: 'Two' } },
});
2020-03-13 18:31:06 +00:00
server.createList('node', 2, { hostVolumes: { Two: { Name: 'Two' } } });
await ClientsList.visit();
},
filter: (node, selection) =>
2021-12-28 16:08:12 +00:00
Object.keys(node.hostVolumes).find((volume) =>
selection.includes(volume)
),
2020-03-13 18:31:06 +00:00
});
2021-12-28 14:45:20 +00:00
test('when the facet selections result in no matches, the empty state states why', async function (assert) {
2019-03-13 00:04:16 +00:00
server.create('agent');
server.createList('node', 2, { status: 'ready' });
await ClientsList.visit();
await ClientsList.facets.state.toggle();
await ClientsList.facets.state.options.objectAt(0).toggle();
assert.ok(ClientsList.isEmpty, 'There is an empty message');
2021-12-28 16:08:12 +00:00
assert.equal(
ClientsList.empty.headline,
'No Matches',
'The message is appropriate'
);
});
2021-12-28 14:45:20 +00:00
test('the clients list is immediately filtered based on query params', async function (assert) {
2019-03-13 00:04:16 +00:00
server.create('agent');
server.create('node', { nodeClass: 'omg-large' });
server.create('node', { nodeClass: 'wtf-tiny' });
await ClientsList.visit({ class: JSON.stringify(['wtf-tiny']) });
2021-12-28 16:08:12 +00:00
assert.equal(
ClientsList.nodes.length,
1,
'Only one client shown due to query param'
);
});
2021-12-28 16:08:12 +00:00
function testFacet(
label,
{ facet, paramName, beforeEach, filter, expectedOptions }
) {
2021-12-28 14:45:20 +00:00
test(`the ${label} facet has the correct options`, async function (assert) {
await beforeEach();
await facet.toggle();
let expectation;
if (typeof expectedOptions === 'function') {
expectation = expectedOptions(server.db.nodes);
} else {
expectation = expectedOptions;
}
assert.deepEqual(
2021-12-28 14:45:20 +00:00
facet.options.map((option) => option.label.trim()),
expectation,
'Options for facet are as expected'
);
});
2021-12-28 14:45:20 +00:00
test(`the ${label} facet filters the nodes list by ${label}`, async function (assert) {
2019-03-13 00:04:16 +00:00
let option;
await beforeEach();
await facet.toggle();
option = facet.options.objectAt(0);
await option.toggle();
const selection = [option.key];
const expectedNodes = server.db.nodes
2021-12-28 14:45:20 +00:00
.filter((node) => filter(node, selection))
.sortBy('modifyIndex')
.reverse();
ClientsList.nodes.forEach((node, index) => {
assert.equal(
node.id,
expectedNodes[index].id.split('-')[0],
`Node at ${index} is ${expectedNodes[index].id}`
);
});
});
2021-12-28 14:45:20 +00:00
test(`selecting multiple options in the ${label} facet results in a broader search`, async function (assert) {
2019-03-13 00:04:16 +00:00
const selection = [];
await beforeEach();
await facet.toggle();
const option1 = facet.options.objectAt(0);
const option2 = facet.options.objectAt(1);
await option1.toggle();
selection.push(option1.key);
await option2.toggle();
selection.push(option2.key);
const expectedNodes = server.db.nodes
2021-12-28 14:45:20 +00:00
.filter((node) => filter(node, selection))
.sortBy('modifyIndex')
.reverse();
ClientsList.nodes.forEach((node, index) => {
assert.equal(
node.id,
expectedNodes[index].id.split('-')[0],
`Node at ${index} is ${expectedNodes[index].id}`
);
});
});
2021-12-28 14:45:20 +00:00
test(`selecting options in the ${label} facet updates the ${paramName} query param`, async function (assert) {
2019-03-13 00:04:16 +00:00
const selection = [];
await beforeEach();
await facet.toggle();
const option1 = facet.options.objectAt(0);
const option2 = facet.options.objectAt(1);
await option1.toggle();
selection.push(option1.key);
await option2.toggle();
selection.push(option2.key);
assert.equal(
currentURL(),
2021-12-28 16:08:12 +00:00
`/clients?${paramName}=${encodeURIComponent(
JSON.stringify(selection)
)}`,
'URL has the correct query param key and value'
);
});
2019-03-13 00:04:16 +00:00
}
});