2018-02-02 01:22:09 +00:00
|
|
|
import { test } from 'qunit';
|
|
|
|
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
2018-07-11 02:20:02 +00:00
|
|
|
import JobDetail from 'nomad-ui/tests/pages/jobs/detail';
|
2018-02-02 01:22:09 +00:00
|
|
|
|
2018-11-08 05:04:27 +00:00
|
|
|
export default function moduleForJob(title, context, jobFactory, additionalTests) {
|
2018-02-02 01:22:09 +00:00
|
|
|
let job;
|
|
|
|
|
|
|
|
moduleForAcceptance(title, {
|
2018-11-08 05:04:27 +00:00
|
|
|
before() {
|
|
|
|
if (context !== 'allocations' && context !== 'children') {
|
|
|
|
throw new Error(
|
|
|
|
`Invalid context provided to moduleForJob, expected either "allocations" or "children", got ${context}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2018-02-02 01:22:09 +00:00
|
|
|
beforeEach() {
|
|
|
|
server.create('node');
|
|
|
|
job = jobFactory();
|
2018-07-11 02:20:02 +00:00
|
|
|
JobDetail.visit({ id: job.id });
|
2018-02-02 01:22:09 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
test('visiting /jobs/:job_id', function(assert) {
|
|
|
|
assert.equal(currentURL(), `/jobs/${job.id}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('the subnav links to overview', function(assert) {
|
2018-07-11 02:20:02 +00:00
|
|
|
JobDetail.tabFor('overview').visit();
|
2018-02-02 01:22:09 +00:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), `/jobs/${job.id}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('the subnav links to definition', function(assert) {
|
2018-07-11 02:20:02 +00:00
|
|
|
JobDetail.tabFor('definition').visit();
|
2018-02-02 01:22:09 +00:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), `/jobs/${job.id}/definition`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('the subnav links to versions', function(assert) {
|
2018-07-11 02:20:02 +00:00
|
|
|
JobDetail.tabFor('versions').visit();
|
2018-02-02 01:22:09 +00:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), `/jobs/${job.id}/versions`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-07-11 02:28:54 +00:00
|
|
|
test('the subnav links to evaluations', function(assert) {
|
|
|
|
JobDetail.tabFor('evaluations').visit();
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(currentURL(), `/jobs/${job.id}/evaluations`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-11-08 05:04:27 +00:00
|
|
|
if (context === 'allocations') {
|
|
|
|
test('allocations for the job are shown in the overview', function(assert) {
|
|
|
|
assert.ok(JobDetail.allocationsSummary, 'Allocations are shown in the summary section');
|
|
|
|
assert.notOk(JobDetail.childrenSummary, 'Children are not shown in the summary section');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context === 'children') {
|
|
|
|
test('children for the job are shown in the overview', function(assert) {
|
|
|
|
assert.ok(JobDetail.childrenSummary, 'Children are shown in the summary section');
|
|
|
|
assert.notOk(
|
|
|
|
JobDetail.allocationsSummary,
|
|
|
|
'Allocations are not shown in the summary section'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-02-02 01:22:09 +00:00
|
|
|
for (var testName in additionalTests) {
|
|
|
|
test(testName, function(assert) {
|
|
|
|
additionalTests[testName](job, assert);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|