From 41fad6b649cf695f1a21b324ca3edccf40731c96 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 13 Feb 2020 16:44:41 -0800 Subject: [PATCH] Test coverage for the volume table on the task group page --- ui/tests/acceptance/task-group-detail-test.js | 24 +++++++++++++++++++ ui/tests/pages/jobs/job/task-group.js | 8 +++++++ 2 files changed, 32 insertions(+) diff --git a/ui/tests/acceptance/task-group-detail-test.js b/ui/tests/acceptance/task-group-detail-test.js index 4a42cfcd0..9aba20ba5 100644 --- a/ui/tests/acceptance/task-group-detail-test.js +++ b/ui/tests/acceptance/task-group-detail-test.js @@ -226,6 +226,30 @@ module('Acceptance | task group detail', function(hooks) { assert.notOk(normalRow.rescheduled, 'Normal row has no reschedule icon'); }); + test('when the task group depends on volumes, the volumes table is shown', async function(assert) { + assert.ok(TaskGroup.hasVolumes); + assert.equal(TaskGroup.volumes.length, Object.keys(taskGroup.volumes).length); + }); + + test('when the task group does not depend on volumes, the volumes table is not shown', async function(assert) { + job = server.create('job', { noHostVolumes: true, shallow: true }); + taskGroup = server.db.taskGroups.where({ jobId: job.id })[0]; + + await TaskGroup.visit({ id: job.id, name: taskGroup.name }); + + assert.notOk(TaskGroup.hasVolumes); + }); + + test('each row in the volumes table lists information about the volume', async function(assert) { + TaskGroup.volumes[0].as(volumeRow => { + const volume = taskGroup.volumes[volumeRow.name]; + assert.equal(volumeRow.name, volume.Name); + assert.equal(volumeRow.type, volume.Type); + assert.equal(volumeRow.source, volume.Source); + assert.equal(volumeRow.permissions, volume.ReadOnly ? 'Read' : 'Read/Write'); + }); + }); + test('when the job for the task group is not found, an error message is shown, but the URL persists', async function(assert) { await TaskGroup.visit({ id: 'not-a-real-job', name: 'not-a-real-task-group' }); diff --git a/ui/tests/pages/jobs/job/task-group.js b/ui/tests/pages/jobs/job/task-group.js index b3e5c9342..b593e08e4 100644 --- a/ui/tests/pages/jobs/job/task-group.js +++ b/ui/tests/pages/jobs/job/task-group.js @@ -38,6 +38,14 @@ export default create({ isEmpty: isPresent('[data-test-empty-allocations-list]'), + hasVolumes: isPresent('[data-test-volumes]'), + volumes: collection('[data-test-volumes] [data-test-volume]', { + name: text('[data-test-volume-name]'), + type: text('[data-test-volume-type]'), + source: text('[data-test-volume-source]'), + permissions: text('[data-test-volume-permissions]'), + }), + error: error(), emptyState: {