Skip to content

Commit

Permalink
Refactor allocations page as a component
Browse files Browse the repository at this point in the history
  • Loading branch information
DingoEatingFuzz committed Jul 30, 2018
1 parent 1b89375 commit 740b6b9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 42 deletions.
2 changes: 1 addition & 1 deletion ui/tests/acceptance/client-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test('each allocation should have high-level details for the allocation', functi
andThen(() => {
const allocationRow = ClientDetail.allocations.objectAt(0);

assert.equal(allocationRow.id, allocation.id.split('-')[0], 'Allocation short ID');
assert.equal(allocationRow.shortId, allocation.id.split('-')[0], 'Allocation short ID');
assert.equal(
allocationRow.createTime,
moment(allocation.createTime / 1000000).format('MM/DD HH:mm:ss'),
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/acceptance/job-deployments-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ test('when open, a deployment shows a list of all allocations for the deployment
const allocation = allocations[0];
const allocationRow = deploymentRow.allocations.objectAt(0);

assert.equal(allocationRow.id, allocation.id.split('-')[0], 'Allocation is as expected');
assert.equal(allocationRow.shortId, allocation.id.split('-')[0], 'Allocation is as expected');
});
});
});
Expand Down
19 changes: 3 additions & 16 deletions ui/tests/pages/clients/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
visitable,
} from 'ember-cli-page-object';

import allocations from 'nomad-ui/tests/pages/components/allocations';

export default create({
visit: visitable('/clients/:id'),

Expand Down Expand Up @@ -36,22 +38,7 @@ export default create({
eligibilityDefinition: text('[data-test-eligibility]'),
datacenterDefinition: text('[data-test-datacenter-definition]'),

allocations: collection('[data-test-allocation]', {
id: text('[data-test-short-id]'),
createTime: text('[data-test-create-time]'),
modifyTime: text('[data-test-modify-time]'),
status: text('[data-test-client-status]'),
job: text('[data-test-job]'),
taskGroup: text('[data-test-task-group]'),
jobVersion: text('[data-test-job-version]'),
cpu: text('[data-test-cpu]'),
cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'),
mem: text('[data-test-mem]'),
memTooltip: attribute('aria-label', '[data-test-mem] .tooltip'),

visit: clickable('[data-test-short-id] a'),
visitJob: clickable('[data-test-job]'),
}),
...allocations(),

attributesTable: isPresent('[data-test-attributes]'),
metaTable: isPresent('[data-test-meta]'),
Expand Down
30 changes: 30 additions & 0 deletions ui/tests/pages/components/allocations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { attribute, collection, clickable, isPresent, text } from 'ember-cli-page-object';

export default function(selector = '[data-test-allocation]') {
return {
allocations: collection(selector, {
id: attribute('data-test-allocation'),
shortId: text('[data-test-short-id]'),
createTime: text('[data-test-create-time]'),
modifyTime: text('[data-test-modify-time]'),
status: text('[data-test-client-status]'),
job: text('[data-test-job]'),
taskGroup: text('[data-test-task-group]'),
client: text('[data-test-client]'),
jobVersion: text('[data-test-job-version]'),
cpu: text('[data-test-cpu]'),
cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'),
mem: text('[data-test-mem]'),
memTooltip: attribute('aria-label', '[data-test-mem] .tooltip'),
rescheduled: isPresent('[data-test-indicators] [data-test-icon="reschedule"]'),

visit: clickable('[data-test-short-id] a'),
visitJob: clickable('[data-test-job]'),
visitClient: clickable('[data-test-client] a'),
}),

allocationFor(id) {
return this.allocations.toArray().find(allocation => allocation.id === id);
},
};
}
6 changes: 3 additions & 3 deletions ui/tests/pages/jobs/job/deployments.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
visitable,
} from 'ember-cli-page-object';

import allocations from 'nomad-ui/tests/pages/components/allocations';

export default create({
visit: visitable('/jobs/:id/deployments'),

Expand Down Expand Up @@ -46,9 +48,7 @@ export default create({
progress: text('[data-test-deployment-task-group-progress-deadline]'),
}),

...allocations('[data-test-deployment-allocation]'),
hasAllocations: isPresent('[data-test-deployment-allocations]'),
allocations: collection('[data-test-deployment-allocation]', {
id: text('[data-test-short-id]'),
}),
}),
});
24 changes: 3 additions & 21 deletions ui/tests/pages/jobs/job/task-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
visitable,
} from 'ember-cli-page-object';

import allocations from 'nomad-ui/tests/pages/components/allocations';

export default create({
pageSize: 10,

Expand All @@ -31,27 +33,7 @@ export default create({
return this.breadcrumbs.toArray().find(crumb => crumb.id === id);
},

allocations: collection('[data-test-allocation]', {
id: attribute('data-test-allocation'),
shortId: text('[data-test-short-id]'),
createTime: text('[data-test-create-time]'),
modifyTime: text('[data-test-modify-time]'),
status: text('[data-test-client-status]'),
jobVersion: text('[data-test-job-version]'),
client: text('[data-test-client]'),
cpu: text('[data-test-cpu]'),
cpuTooltip: attribute('aria-label', '[data-test-cpu] .tooltip'),
mem: text('[data-test-mem]'),
memTooltip: attribute('aria-label', '[data-test-mem] .tooltip'),
rescheduled: isPresent('[data-test-indicators] [data-test-icon="reschedule"]'),

visit: clickable('[data-test-short-id] a'),
visitClient: clickable('[data-test-client] a'),
}),

allocationFor(id) {
return this.allocations.toArray().find(allocation => allocation.id === id);
},
...allocations(),

isEmpty: isPresent('[data-test-empty-allocations-list]'),

Expand Down

0 comments on commit 740b6b9

Please sign in to comment.