2018-07-07 00:07:53 +00:00
|
|
|
import { test } from 'qunit';
|
|
|
|
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
2018-07-11 16:37:58 +00:00
|
|
|
import Evaluations from 'nomad-ui/tests/pages/jobs/job/evaluations';
|
2018-07-07 00:07:53 +00:00
|
|
|
|
|
|
|
let job;
|
|
|
|
let evaluations;
|
|
|
|
|
|
|
|
moduleForAcceptance('Acceptance | job evaluations', {
|
|
|
|
beforeEach() {
|
|
|
|
job = server.create('job', { noFailedPlacements: true, createAllocations: false });
|
|
|
|
evaluations = server.db.evaluations.where({ jobId: job.id });
|
|
|
|
|
2018-07-11 16:37:58 +00:00
|
|
|
Evaluations.visit({ id: job.id });
|
2018-07-07 00:07:53 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
test('lists all evaluations for the job', function(assert) {
|
2018-07-11 16:37:58 +00:00
|
|
|
assert.equal(Evaluations.evaluations.length, evaluations.length, 'All evaluations are listed');
|
|
|
|
|
|
|
|
const sortedEvaluations = evaluations.sortBy('modifyIndex').reverse();
|
|
|
|
|
|
|
|
Evaluations.evaluations.forEach((evaluation, index) => {
|
|
|
|
const shortId = sortedEvaluations[index].id.split('-')[0];
|
|
|
|
assert.equal(evaluation.id, shortId, `Evaluation ${index} is ${shortId}`);
|
|
|
|
});
|
2018-07-07 00:07:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('evaluations table is sortable', function(assert) {
|
2018-07-11 16:37:58 +00:00
|
|
|
Evaluations.sortBy('priority');
|
2018-07-07 00:07:53 +00:00
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
currentURL(),
|
|
|
|
`/jobs/${job.id}/evaluations?sort=priority`,
|
|
|
|
'the URL persists the sort parameter'
|
|
|
|
);
|
2018-07-11 16:37:58 +00:00
|
|
|
const sortedEvaluations = evaluations.sortBy('priority').reverse();
|
|
|
|
Evaluations.evaluations.forEach((evaluation, index) => {
|
|
|
|
const shortId = sortedEvaluations[index].id.split('-')[0];
|
|
|
|
assert.equal(
|
|
|
|
evaluation.id,
|
|
|
|
shortId,
|
|
|
|
`Evaluation ${index} is ${shortId} with priority ${sortedEvaluations[index].priority}`
|
|
|
|
);
|
|
|
|
});
|
2018-07-07 00:07:53 +00:00
|
|
|
});
|
|
|
|
});
|