Update tests for the ModifyIndex column and sort change

This commit is contained in:
Michael Lange 2017-10-17 19:19:02 -07:00
parent f07c222274
commit 3adc477736
2 changed files with 66 additions and 48 deletions

View file

@ -127,12 +127,20 @@ test('each allocation should have high-level details for the allocation', functi
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
);
assert.equal(
allocationRow
.find('td:eq(2)')
.text()
.trim(),
allocation.name,
'Allocation name'
);
assert.equal(
allocationRow
.find('td:eq(2)')
.find('td:eq(3)')
.text()
.trim(),
allocation.clientStatus,
@ -140,41 +148,41 @@ test('each allocation should have high-level details for the allocation', functi
);
assert.ok(
allocationRow
.find('td:eq(3)')
.find('td:eq(4)')
.text()
.includes(server.db.jobs.find(allocation.jobId).name),
'Job name'
);
assert.ok(
allocationRow
.find('td:eq(3) .is-faded')
.find('td:eq(4) .is-faded')
.text()
.includes(allocation.taskGroup),
'Task group name'
);
assert.equal(
allocationRow
.find('td:eq(4)')
.find('td:eq(5)')
.text()
.trim(),
allocStats.resourceUsage.CpuStats.Percent,
'CPU %'
);
assert.equal(
allocationRow.find('td:eq(4) .tooltip').attr('aria-label'),
allocationRow.find('td:eq(5) .tooltip').attr('aria-label'),
`${Math.floor(allocStats.resourceUsage.CpuStats.TotalTicks)} / ${cpuUsed} MHz`,
'Detailed CPU information is in a tooltip'
);
assert.equal(
allocationRow
.find('td:eq(5)')
.find('td:eq(6)')
.text()
.trim(),
allocStats.resourceUsage.MemoryStats.RSS / 1024 / 1024 / memoryUsed,
'Memory used'
);
assert.equal(
allocationRow.find('td:eq(5) .tooltip').attr('aria-label'),
allocationRow.find('td:eq(6) .tooltip').attr('aria-label'),
`${formatBytes([allocStats.resourceUsage.MemoryStats.RSS])} / ${memoryUsed} MiB`,
'Detailed memory information is in a tooltip'
);
@ -209,14 +217,14 @@ test('each allocation should show job information even if the job is incomplete
assert.ok(
allocationRow
.find('td:eq(3)')
.find('td:eq(4)')
.text()
.includes(server.db.jobs.find(allocation.jobId).name),
'Job name'
);
assert.ok(
allocationRow
.find('td:eq(3) .is-faded')
.find('td:eq(4) .is-faded')
.text()
.includes(allocation.taskGroup),
'Task group name'
@ -252,7 +260,7 @@ test('each allocation should link to the job the allocation belongs to', functio
const job = server.db.jobs.find(allocation.jobId);
andThen(() => {
click($('.allocations tbody tr:eq(0) td:eq(3) a').get(0));
click($('.allocations tbody tr:eq(0) td:eq(4) a').get(0));
});
andThen(() => {

View file

@ -140,43 +140,53 @@ test('/jobs/:id/:task-group should list one page of allocations for the task gro
});
test('each allocation should show basic information about the allocation', function(assert) {
const allocation = allocations.sortBy('name')[0];
const allocation = allocations.sortBy('modifyIndex').reverse()[0];
const allocationRow = $(findAll('.allocations tbody tr')[0]);
assert.equal(
allocationRow
.find('td:eq(0)')
.text()
.trim(),
allocation.id.split('-')[0],
'Allocation short id'
);
assert.equal(
allocationRow
.find('td:eq(1)')
.text()
.trim(),
allocation.name,
'Allocation name'
);
assert.equal(
allocationRow
.find('td:eq(2)')
.text()
.trim(),
allocation.clientStatus,
'Client status'
);
assert.equal(
allocationRow
.find('td:eq(3)')
.text()
.trim(),
server.db.nodes.find(allocation.nodeId).id.split('-')[0],
'Node ID'
);
andThen(() => {
assert.equal(
allocationRow
.find('td:eq(0)')
.text()
.trim(),
allocation.id.split('-')[0],
'Allocation short id'
);
assert.equal(
allocationRow
.find('td:eq(1)')
.text()
.trim(),
allocation.modifyIndex,
'Allocation modify index'
);
assert.equal(
allocationRow
.find('td:eq(2)')
.text()
.trim(),
allocation.name,
'Allocation name'
);
assert.equal(
allocationRow
.find('td:eq(3)')
.text()
.trim(),
allocation.clientStatus,
'Client status'
);
assert.equal(
allocationRow
.find('td:eq(4)')
.text()
.trim(),
server.db.nodes.find(allocation.nodeId).id.split('-')[0],
'Node ID'
);
});
click(allocationRow.find('td:eq(3) a').get(0));
click(allocationRow.find('td:eq(4) a').get(0));
andThen(() => {
assert.equal(currentURL(), `/nodes/${allocation.nodeId}`, 'Node links to node page');
@ -196,7 +206,7 @@ test('each allocation should show stats about the allocation, retrieved directly
assert.equal(
allocationRow
.find('td:eq(4)')
.find('td:eq(5)')
.text()
.trim(),
allocStats.resourceUsage.CpuStats.Percent,
@ -204,14 +214,14 @@ test('each allocation should show stats about the allocation, retrieved directly
);
assert.equal(
allocationRow.find('td:eq(4) .tooltip').attr('aria-label'),
allocationRow.find('td:eq(5) .tooltip').attr('aria-label'),
`${Math.floor(allocStats.resourceUsage.CpuStats.TotalTicks)} / ${cpuUsed} MHz`,
'Detailed CPU information is in a tooltip'
);
assert.equal(
allocationRow
.find('td:eq(5)')
.find('td:eq(6)')
.text()
.trim(),
allocStats.resourceUsage.MemoryStats.RSS / 1024 / 1024 / memoryUsed,
@ -219,7 +229,7 @@ test('each allocation should show stats about the allocation, retrieved directly
);
assert.equal(
allocationRow.find('td:eq(5) .tooltip').attr('aria-label'),
allocationRow.find('td:eq(6) .tooltip').attr('aria-label'),
`${formatBytes([allocStats.resourceUsage.MemoryStats.RSS])} / ${memoryUsed} MiB`,
'Detailed memory information is in a tooltip'
);