2019-03-13 00:08:16 +00:00
|
|
|
import { currentURL } from '@ember/test-helpers';
|
2019-03-13 00:04:16 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2019-09-26 18:47:07 +00:00
|
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
2020-07-28 17:59:14 +00:00
|
|
|
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
|
2018-07-11 16:45:30 +00:00
|
|
|
import Versions from 'nomad-ui/tests/pages/jobs/job/versions';
|
2017-09-19 14:47:10 +00:00
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
let job;
|
|
|
|
let versions;
|
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
module('Acceptance | job versions', function(hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
2019-03-13 01:09:19 +00:00
|
|
|
setupMirage(hooks);
|
2019-03-13 00:04:16 +00:00
|
|
|
|
2019-03-14 06:44:53 +00:00
|
|
|
hooks.beforeEach(async function() {
|
2017-09-19 14:47:10 +00:00
|
|
|
job = server.create('job', { createAllocations: false });
|
|
|
|
versions = server.db.jobVersions.where({ jobId: job.id });
|
|
|
|
|
2019-03-14 06:44:53 +00:00
|
|
|
await Versions.visit({ id: job.id });
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-07-28 17:59:14 +00:00
|
|
|
test('it passes an accessibility audit', async function(assert) {
|
|
|
|
await a11yAudit();
|
|
|
|
assert.ok(true, 'a11y audit passes');
|
|
|
|
});
|
|
|
|
|
2019-03-14 06:44:53 +00:00
|
|
|
test('/jobs/:id/versions should list all job versions', async function(assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
assert.ok(Versions.versions.length, versions.length, 'Each version gets a row in the timeline');
|
2019-07-17 20:02:58 +00:00
|
|
|
assert.equal(document.title, `Job ${job.name} versions - Nomad`);
|
2019-03-13 00:04:16 +00:00
|
|
|
});
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-03-14 06:44:53 +00:00
|
|
|
test('each version mentions the version number, the stability, and the submitted time', async function(assert) {
|
2019-03-13 00:04:16 +00:00
|
|
|
const version = versions.sortBy('submitTime').reverse()[0];
|
|
|
|
const formattedSubmitTime = moment(version.submitTime / 1000000).format(
|
|
|
|
"MMM DD, 'YY HH:mm:ss ZZ"
|
|
|
|
);
|
|
|
|
const versionRow = Versions.versions.objectAt(0);
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-03-13 00:04:16 +00:00
|
|
|
assert.ok(versionRow.text.includes(`Version #${version.version}`), 'Version #');
|
|
|
|
assert.equal(versionRow.stability, version.stable.toString(), 'Stability');
|
|
|
|
assert.equal(versionRow.submitTime, formattedSubmitTime, 'Submit time');
|
|
|
|
});
|
2018-11-05 23:42:04 +00:00
|
|
|
|
2019-03-14 06:44:53 +00:00
|
|
|
test('when the job for the versions is not found, an error message is shown, but the URL persists', async function(assert) {
|
|
|
|
await Versions.visit({ id: 'not-a-real-job' });
|
2018-11-05 23:42:04 +00:00
|
|
|
|
|
|
|
assert.equal(
|
2020-01-20 20:57:01 +00:00
|
|
|
server.pretender.handledRequests
|
|
|
|
.filter(request => !request.url.includes('policy'))
|
|
|
|
.findBy('status', 404).url,
|
2018-11-05 23:42:04 +00:00
|
|
|
'/v1/job/not-a-real-job',
|
|
|
|
'A request to the nonexistent job is made'
|
|
|
|
);
|
|
|
|
assert.equal(currentURL(), '/jobs/not-a-real-job/versions', 'The URL persists');
|
|
|
|
assert.ok(Versions.error.isPresent, 'Error message is shown');
|
|
|
|
assert.equal(Versions.error.title, 'Not Found', 'Error message is for 404');
|
|
|
|
});
|
|
|
|
});
|