Skip to content

Commit

Permalink
Acceptance tests for topology search and filter
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Oct 17, 2022
1 parent a1f347e commit 56bd954
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/app/templates/topology.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@
<div class="toolbar-item">
{{#if this.model.nodes.length}}
<SearchBox
@inputClass="node-search"
@searchTerm={{mut this.searchTerm}}
{{!-- @onChange={{action this.buildTopology}} --}}
@placeholder="Search clients..."
/>
{{/if}}
Expand Down
26 changes: 25 additions & 1 deletion ui/tests/acceptance/topology-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable qunit/require-expect */
import { get } from '@ember/object';
import { currentURL } from '@ember/test-helpers';
import { currentURL, typeIn, click } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
Expand Down Expand Up @@ -311,4 +311,28 @@ module('Acceptance | topology', function (hooks) {
assert.ok(Topology.filteredNodesWarning.isPresent);
assert.ok(Topology.filteredNodesWarning.message.startsWith('1'));
});

test('Filtering and Querying reduces the number of nodes shown', async function (assert) {
server.createList('node', 10);
server.createList('node', 2, {
nodeClass: 'foo-bar-baz',
});
server.createList('allocation', 5);

await Topology.visit();
assert.dom('[data-test-topo-viz-node]').exists({ count: 12 });

await typeIn('input.node-search', server.schema.nodes.first().name);
assert.dom('[data-test-topo-viz-node]').exists({ count: 1 });
await typeIn('input.node-search', server.schema.nodes.first().name);
assert.dom('[data-test-topo-viz-node]').doesNotExist();
await click('[title="Clear search"]');
assert.dom('[data-test-topo-viz-node]').exists({ count: 12 });

await Topology.facets.class.toggle();
await Topology.facets.class.options
.findOneBy('label', 'foo-bar-baz')
.toggle();
assert.dom('[data-test-topo-viz-node]').exists({ count: 2 });
});
});
8 changes: 8 additions & 0 deletions ui/tests/pages/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
visitable,
} from 'ember-cli-page-object';

import { multiFacet } from 'nomad-ui/tests/pages/components/facet';
import TopoViz from 'nomad-ui/tests/pages/components/topo-viz';
import notification from 'nomad-ui/tests/pages/components/notification';

Expand All @@ -19,6 +20,13 @@ export default create({

viz: TopoViz('[data-test-topo-viz]'),

facets: {
datacenter: multiFacet('[data-test-datacenter-facet]'),
class: multiFacet('[data-test-class-facet]'),
state: multiFacet('[data-test-state-facet]'),
version: multiFacet('[data-test-version-facet]'),
},

clusterInfoPanel: {
scope: '[data-test-info-panel]',
nodeCount: text('[data-test-node-count]'),
Expand Down

0 comments on commit 56bd954

Please sign in to comment.