mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Test coverage for preemption on the client detail page
This commit is contained in:
@@ -97,11 +97,11 @@
|
||||
<div class="boxed-section-head">
|
||||
<div>
|
||||
Allocations
|
||||
<button role="button" class="badge is-white" onclick={{action "setPreemptionFilter" false}}>
|
||||
<button role="button" class="badge is-white" onclick={{action "setPreemptionFilter" false}} data-test-filter-all>
|
||||
{{model.allocations.length}}
|
||||
</button>
|
||||
{{#if preemptions.length}}
|
||||
<button role="button" class="badge is-warning" onclick={{action "setPreemptionFilter" true}}>
|
||||
<button role="button" class="badge is-warning" onclick={{action "setPreemptionFilter" true}} data-test-filter-preemptions>
|
||||
{{preemptions.length}} {{pluralize "preemption" preemptions.length}}
|
||||
</button>
|
||||
{{/if}}
|
||||
|
||||
@@ -12,6 +12,8 @@ import Jobs from 'nomad-ui/tests/pages/jobs/list';
|
||||
|
||||
let node;
|
||||
|
||||
const wasPreemptedFilter = allocation => !!allocation.preemptedByAllocation;
|
||||
|
||||
module('Acceptance | client detail', function(hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
@@ -24,6 +26,7 @@ module('Acceptance | client detail', function(hooks) {
|
||||
server.create('agent');
|
||||
server.create('job', { createAllocations: false });
|
||||
server.createList('allocation', 3, { nodeId: node.id, clientStatus: 'running' });
|
||||
server.create('allocation', 'preempted', { nodeId: node.id, clientStatus: 'running' });
|
||||
});
|
||||
|
||||
test('/clients/:id should have a breadcrumb trail linking back to clients', async function(assert) {
|
||||
@@ -219,6 +222,65 @@ module('Acceptance | client detail', function(hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
test('the allocation section should show the count of preempted allocations on the client', async function(assert) {
|
||||
const allocations = server.db.allocations.where({ nodeId: node.id });
|
||||
|
||||
await ClientDetail.visit({ id: node.id });
|
||||
|
||||
assert.equal(
|
||||
ClientDetail.allocationFilter.allCount,
|
||||
allocations.length,
|
||||
'All filter/badge shows all allocations count'
|
||||
);
|
||||
assert.ok(
|
||||
ClientDetail.allocationFilter.preemptionsCount.startsWith(
|
||||
allocations.filter(wasPreemptedFilter).length
|
||||
),
|
||||
'Preemptions filter/badge shows preempted allocations count'
|
||||
);
|
||||
});
|
||||
|
||||
test('clicking the preemption badge filters the allocations table and sets a query param', async function(assert) {
|
||||
const allocations = server.db.allocations.where({ nodeId: node.id });
|
||||
|
||||
await ClientDetail.visit({ id: node.id });
|
||||
await ClientDetail.allocationFilter.preemptions();
|
||||
|
||||
assert.equal(
|
||||
ClientDetail.allocations.length,
|
||||
allocations.filter(wasPreemptedFilter).length,
|
||||
'Only preempted allocations are shown'
|
||||
);
|
||||
assert.equal(
|
||||
currentURL(),
|
||||
`/clients/${node.id}?preemptions=true`,
|
||||
'Filter is persisted in the URL'
|
||||
);
|
||||
});
|
||||
|
||||
test('clicking the total allocations badge resets the filter and removes the query param', async function(assert) {
|
||||
const allocations = server.db.allocations.where({ nodeId: node.id });
|
||||
|
||||
await ClientDetail.visit({ id: node.id });
|
||||
await ClientDetail.allocationFilter.preemptions();
|
||||
await ClientDetail.allocationFilter.all();
|
||||
|
||||
assert.equal(ClientDetail.allocations.length, allocations.length, 'All allocations are shown');
|
||||
assert.equal(currentURL(), `/clients/${node.id}`, 'Filter is persisted in the URL');
|
||||
});
|
||||
|
||||
test('navigating directly to the client detail page with the preemption query param set will filter the allocations table', async function(assert) {
|
||||
const allocations = server.db.allocations.where({ nodeId: node.id });
|
||||
|
||||
await ClientDetail.visit({ id: node.id, preemptions: true });
|
||||
|
||||
assert.equal(
|
||||
ClientDetail.allocations.length,
|
||||
allocations.filter(wasPreemptedFilter).length,
|
||||
'Only preempted allocations are shown'
|
||||
);
|
||||
});
|
||||
|
||||
test('/clients/:id should list all attributes for the node', async function(assert) {
|
||||
await ClientDetail.visit({ id: node.id });
|
||||
|
||||
|
||||
@@ -45,6 +45,13 @@ export default create({
|
||||
|
||||
...allocations(),
|
||||
|
||||
allocationFilter: {
|
||||
preemptions: clickable('[data-test-filter-preemptions]'),
|
||||
all: clickable('[data-test-filter-all]'),
|
||||
preemptionsCount: text('[data-test-filter-preemptions]'),
|
||||
allCount: text('[data-test-filter-all]'),
|
||||
},
|
||||
|
||||
attributesTable: isPresent('[data-test-attributes]'),
|
||||
metaTable: isPresent('[data-test-meta]'),
|
||||
emptyMetaMessage: isPresent('[data-test-empty-meta-message]'),
|
||||
|
||||
Reference in New Issue
Block a user