-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test coverage for the jobs/:job/allocations page
- Loading branch information
1 parent
0c8ff8b
commit 495a5a7
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { test } from 'qunit'; | ||
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; | ||
import Allocations from 'nomad-ui/tests/pages/jobs/job/allocations'; | ||
|
||
let job; | ||
let allocations; | ||
|
||
moduleForAcceptance('Acceptance | job allocations', { | ||
beforeEach() { | ||
server.create('node'); | ||
|
||
job = server.create('job', { noFailedPlacements: true, createAllocations: false }); | ||
}, | ||
}); | ||
|
||
test('lists all allocations for the job', function(assert) { | ||
server.createList('allocation', Allocations.pageSize - 1); | ||
allocations = server.schema.allocations.where({ jobId: job.id }).models; | ||
|
||
Allocations.visit({ id: job.id }); | ||
|
||
andThen(() => { | ||
assert.equal( | ||
Allocations.allocations.length, | ||
Allocations.pageSize - 1, | ||
'Allocations are shown in a table' | ||
); | ||
|
||
const sortedAllocations = allocations.sortBy('modifyIndex').reverse(); | ||
|
||
Allocations.allocations.forEach((allocation, index) => { | ||
const shortId = sortedAllocations[index].id.split('-')[0]; | ||
assert.equal(allocation.shortId, shortId, `Allocation ${index} is ${shortId}`); | ||
}); | ||
}); | ||
}); | ||
|
||
test('allocations table is sortable', function(assert) { | ||
server.createList('allocation', Allocations.pageSize - 1); | ||
allocations = server.schema.allocations.where({ jobId: job.id }).models; | ||
|
||
Allocations.visit({ id: job.id }); | ||
|
||
andThen(() => { | ||
Allocations.sortBy('taskGroupName'); | ||
|
||
andThen(() => { | ||
assert.equal( | ||
currentURL(), | ||
`/jobs/${job.id}/allocations?sort=taskGroupName`, | ||
'the URL persists the sort parameter' | ||
); | ||
const sortedAllocations = allocations.sortBy('taskGroup').reverse(); | ||
Allocations.allocations.forEach((allocation, index) => { | ||
const shortId = sortedAllocations[index].id.split('-')[0]; | ||
assert.equal( | ||
allocation.shortId, | ||
shortId, | ||
`Allocation ${index} is ${shortId} with task group ${sortedAllocations[index].taskGroup}` | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test('allocations table is searchable', function(assert) { | ||
Array(10) | ||
.fill(null) | ||
.map((_, index) => { | ||
server.create('allocation', { | ||
id: index < 5 ? `ffffff-dddddd-${index}` : `111111-222222-${index}`, | ||
}); | ||
}); | ||
|
||
allocations = server.schema.allocations.where({ jobId: job.id }).models; | ||
Allocations.visit({ id: job.id }); | ||
|
||
andThen(() => { | ||
Allocations.search('ffffff'); | ||
}); | ||
|
||
andThen(() => { | ||
assert.equal(Allocations.allocations.length, 5, 'List is filtered by search term'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
attribute, | ||
clickable, | ||
create, | ||
collection, | ||
fillable, | ||
visitable, | ||
} from 'ember-cli-page-object'; | ||
|
||
import allocations from 'nomad-ui/tests/pages/components/allocations'; | ||
|
||
export default create({ | ||
visit: visitable('/jobs/:id/allocations'), | ||
|
||
pageSize: 25, | ||
|
||
search: fillable('[data-test-allocations-search] input'), | ||
|
||
...allocations(), | ||
|
||
sortOptions: collection('[data-test-sort-by]', { | ||
id: attribute('data-test-sort-by'), | ||
sort: clickable(), | ||
}), | ||
|
||
sortBy(id) { | ||
return this.sortOptions | ||
.toArray() | ||
.findBy('id', id) | ||
.sort(); | ||
}, | ||
}); |