Change test to filter the hosts list by type

This commit is contained in:
Carlos Alcaide Corvo committed 2021-12-14 09:22:33 -08:00
1 parent bc0af27afa
commit 6cec91b09b
1 file changed
+9 -2
@@ -173,7 +173,14 @@ module('Acceptance | projects | targets | hosts', function (hooks) {
test('visiting index', async function (assert) {
assert.expect(2);
const hostsCount = this.server.schema.hosts.all().models.length;
// Because we are generating host with different types but just showing on the list
// the type = static, we have to apply a filter here
const rawHostsList = this.server.schema.hosts.all();
const filteredHostsList = rawHostsList.filter((host) => {
if (host.type === 'static') {
return host;
}
}).length;
// This later/cancelTimers technique allows us to test a page with
// active polling. Normally an acceptance test waits for all runloop timers
// to stop before returning from an awaited test, but polling means that
@@ -183,7 +190,7 @@ module('Acceptance | projects | targets | hosts', function (hooks) {
run.cancelTimers();
// await a11yAudit();
assert.equal(currentURL(), urls.hosts);
assert.equal(findAll('tbody tr').length, hostsCount);
assert.equal(findAll('tbody tr').length, filteredHostsList);
}, 750);
await visit(urls.hosts);
});