Commit ae10e4a8 authored by Michael Lange's avatar Michael Lange
Browse files

Use PageObject for job evaluations tests

parent 1c893792
Showing with 41 additions and 29 deletions
+41 -29
import { test } from 'qunit';
import { findAll, click } from 'ember-native-dom-helpers';
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
import Evaluations from 'nomad-ui/tests/pages/jobs/job/evaluations';
let job;
let evaluations;
......@@ -10,29 +10,23 @@ moduleForAcceptance('Acceptance | job evaluations', {
job = server.create('job', { noFailedPlacements: true, createAllocations: false });
evaluations = server.db.evaluations.where({ jobId: job.id });
visit(`/jobs/${job.id}/evaluations`);
Evaluations.visit({ id: job.id });
},
});
test('lists all evaluations for the job', function(assert) {
const evaluationRows = findAll('[data-test-evaluation]');
assert.equal(evaluationRows.length, evaluations.length, 'All evaluations are listed');
evaluations
.sortBy('modifyIndex')
.reverse()
.forEach((evaluation, index) => {
const shortId = evaluation.id.split('-')[0];
assert.equal(
evaluationRows[index].querySelector('[data-test-id]').textContent.trim(),
shortId,
`Evaluation ${index} is ${shortId}`
);
});
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}`);
});
});
test('evaluations table is sortable', function(assert) {
click('[data-test-sort-by="priority"]');
Evaluations.sortBy('priority');
andThen(() => {
assert.equal(
......@@ -40,17 +34,14 @@ test('evaluations table is sortable', function(assert) {
`/jobs/${job.id}/evaluations?sort=priority`,
'the URL persists the sort parameter'
);
const evaluationRows = findAll('[data-test-evaluation]');
evaluations
.sortBy('priority')
.reverse()
.forEach((evaluation, index) => {
const shortId = evaluation.id.split('-')[0];
assert.equal(
evaluationRows[index].querySelector('[data-test-id]').textContent.trim(),
shortId,
`Evaluation ${index} is ${shortId} with priority ${evaluation.priority}`
);
});
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}`
);
});
});
});
import { attribute, clickable, create, collection, text, visitable } from 'ember-cli-page-object';
export default create({
visit: visitable('/jobs/:id/evaluations'),
evaluations: collection('[data-test-evaluation]', {
id: text('[data-test-id]'),
}),
sortOptions: collection('[data-test-sort-by]', {
id: attribute('data-test-sort-by'),
sort: clickable(),
}),
sortBy(id) {
return this.sortOptions
.toArray()
.findBy('id', id)
.sort();
},
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment