Skip to content

Commit

Permalink
Add accessibility audits to acceptance tests
Browse files Browse the repository at this point in the history
I’m torn about whether this approach of making separate tests
for the audit is preferable to embedding the audit in the
existing tests, perhaps similarly to how assertions on the
page title are embedded. 🤔
  • Loading branch information
backspace committed Jul 21, 2020
1 parent a860994 commit d06919b
Show file tree
Hide file tree
Showing 29 changed files with 215 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ui/tests/acceptance/allocation-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { assign } from '@ember/polyfills';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Allocation from 'nomad-ui/tests/pages/allocations/detail';
import moment from 'moment';

Expand Down Expand Up @@ -46,6 +47,11 @@ module('Acceptance | allocation detail', function(hooks) {
await Allocation.visit({ id: allocation.id });
});

test('it passes an accessibility audit', async function(assert) {
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/allocation/:id should name the allocation and link to the corresponding job and node', async function(assert) {
assert.ok(Allocation.title.includes(allocation.name), 'Allocation name is in the heading');
assert.equal(Allocation.details.job, job.name, 'Job name is in the subheading');
Expand Down
9 changes: 9 additions & 0 deletions ui/tests/acceptance/application-errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import ClientsList from 'nomad-ui/tests/pages/clients/list';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import Job from 'nomad-ui/tests/pages/jobs/detail';
Expand All @@ -16,6 +17,14 @@ module('Acceptance | application errors ', function(hooks) {
server.create('job');
});

test('it passes an accessibility audit', async function(assert) {
server.pretender.get('/v1/nodes', () => [500, {}, null]);
await ClientsList.visit();
await a11yAudit();

assert.ok(true, 'a11y audit passes');
});

test('transitioning away from an error page resets the global error', async function(assert) {
server.pretender.get('/v1/nodes', () => [500, {}, null]);

Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/behaviors/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { currentURL, visit } from '@ember/test-helpers';

import { filesForPath } from 'nomad-ui/mirage/config';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';

import Response from 'ember-cli-mirage/response';
import moment from 'moment';
Expand All @@ -24,6 +25,12 @@ const fileSort = (prop, files) => {
};

export default function browseFilesystem({ pageObjectVisitPathFunctionName, pageObjectVisitFunctionName, visitSegments, getExpectedPathBase, getTitleComponent, getBreadcrumbComponent, getFilesystemRoot }) {
test('it passes an accessibility audit', async function(assert) {
await FS[pageObjectVisitFunctionName](visitSegments({allocation: this.allocation, task: this.task }));
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('visiting filesystem root', async function(assert) {
await FS[pageObjectVisitFunctionName](visitSegments({allocation: this.allocation, task: this.task }));

Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/client-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { assign } from '@ember/polyfills';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import moment from 'moment';
import ClientDetail from 'nomad-ui/tests/pages/clients/detail';
Expand Down Expand Up @@ -41,6 +42,12 @@ module('Acceptance | client detail', function(hooks) {
});
});

test('it passes an accessibility audit', async function(assert) {
await ClientDetail.visit({ id: node.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/clients/:id should have a breadcrumb trail linking back to clients', async function(assert) {
await ClientDetail.visit({ id: node.id });

Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/client-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { run } from '@ember/runloop';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import ClientMonitor from 'nomad-ui/tests/pages/clients/monitor';

let node;
Expand All @@ -25,6 +26,12 @@ module('Acceptance | client monitor', function(hooks) {
run.later(run, run.cancelTimers, 500);
});

test('it passes an accessibility audit', async function(assert) {
await ClientMonitor.visit({ id: node.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/clients/:id/monitor should have a breadcrumb trail linking back to clients', async function(assert) {
await ClientMonitor.visit({ id: node.id });

Expand Down
12 changes: 12 additions & 0 deletions ui/tests/acceptance/clients-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import pageSizeSelect from './behaviors/page-size-select';
import ClientsList from 'nomad-ui/tests/pages/clients/list';

Expand All @@ -13,6 +14,17 @@ module('Acceptance | clients list', function(hooks) {
window.localStorage.clear();
});

test('it passes an accessibility audit', async function(assert) {
const nodesCount = ClientsList.pageSize + 1;

server.createList('node', nodesCount);
server.createList('agent', 1);

await ClientsList.visit();
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/clients should list one page of clients', async function(assert) {
// Make sure to make more nodes than 1 page to assert that pagination is working
const nodesCount = ClientsList.pageSize + 1;
Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/exec-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { module, skip, test } from 'qunit';
import { currentURL, settled } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Service from '@ember/service';
import Exec from 'nomad-ui/tests/pages/exec';
import KEYS from 'nomad-ui/utils/keys';
Expand Down Expand Up @@ -33,6 +34,12 @@ module('Acceptance | exec', function(hooks) {
});
});

test('it passes an accessibility audit', async function(assert) {
await Exec.visitJob({ job: this.job.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/exec/:job should show the region, namespace, and job name', async function(assert) {
server.create('namespace');
let namespace = server.create('namespace');
Expand Down
10 changes: 10 additions & 0 deletions ui/tests/acceptance/job-allocations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Allocations from 'nomad-ui/tests/pages/jobs/job/allocations';

let job;
Expand All @@ -28,6 +29,15 @@ module('Acceptance | job allocations', function(hooks) {
job = server.create('job', { noFailedPlacements: true, createAllocations: false });
});

test('it passes an accessibility audit', async function(assert) {
server.createList('allocation', Allocations.pageSize - 1, { shallow: true });
allocations = server.schema.allocations.where({ jobId: job.id }).models;

await Allocations.visit({ id: job.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('lists all allocations for the job', async function(assert) {
server.createList('allocation', Allocations.pageSize - 1, { shallow: true });
allocations = server.schema.allocations.where({ jobId: job.id }).models;
Expand Down
6 changes: 6 additions & 0 deletions ui/tests/acceptance/job-definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import setupCodeMirror from 'nomad-ui/tests/helpers/codemirror';
import Definition from 'nomad-ui/tests/pages/jobs/job/definition';

Expand All @@ -19,6 +20,11 @@ module('Acceptance | job definition', function(hooks) {
await Definition.visit({ id: job.id });
});

test('it passes an accessibility audit', async function(assert) {
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('visiting /jobs/:job_id/definition', async function(assert) {
assert.equal(currentURL(), `/jobs/${job.id}/definition`);
assert.equal(document.title, `Job ${job.name} definition - Nomad`);
Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/job-deployments-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { get } from '@ember/object';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import moment from 'moment';
import Deployments from 'nomad-ui/tests/pages/jobs/job/deployments';

Expand Down Expand Up @@ -33,6 +34,12 @@ module('Acceptance | job deployments', function(hooks) {
});
});

test('it passes an accessibility audit', async function(assert) {
await Deployments.visit({ id: job.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/jobs/:id/deployments should list all job deployments', async function(assert) {
await Deployments.visit({ id: job.id });

Expand Down
8 changes: 8 additions & 0 deletions ui/tests/acceptance/job-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { selectChoose } from 'ember-power-select/test-support';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import moduleForJob from 'nomad-ui/tests/helpers/module-for-job';
import JobDetail from 'nomad-ui/tests/pages/jobs/detail';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
Expand Down Expand Up @@ -76,6 +77,13 @@ module('Acceptance | job detail (with namespaces)', function(hooks) {
clientToken = server.create('token');
});

test('it passes an accessibility audit', async function(assert) {
const namespace = server.db.namespaces.find(job.namespaceId);
await JobDetail.visit({ id: job.id, namespace: namespace.name });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('when there are namespaces, the job detail page states the namespace for the job', async function(assert) {
const namespace = server.db.namespaces.find(job.namespaceId);
await JobDetail.visit({ id: job.id, namespace: namespace.name });
Expand Down
6 changes: 6 additions & 0 deletions ui/tests/acceptance/job-evaluations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Evaluations from 'nomad-ui/tests/pages/jobs/job/evaluations';

let job;
Expand All @@ -18,6 +19,11 @@ module('Acceptance | job evaluations', function(hooks) {
await Evaluations.visit({ id: job.id });
});

test('it passes an accessibility audit', async function(assert) {
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('lists all evaluations for the job', async function(assert) {
assert.equal(Evaluations.evaluations.length, evaluations.length, 'All evaluations are listed');

Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/job-run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { assign } from '@ember/polyfills';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import setupCodeMirror from 'nomad-ui/tests/helpers/codemirror';
import JobRun from 'nomad-ui/tests/pages/jobs/run';

Expand Down Expand Up @@ -54,6 +55,12 @@ module('Acceptance | job run', function(hooks) {
window.localStorage.nomadTokenSecret = managementToken.secretId;
});

test('it passes an accessibility audit', async function(assert) {
await JobRun.visit();
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('visiting /jobs/run', async function(assert) {
await JobRun.visit();

Expand Down
6 changes: 6 additions & 0 deletions ui/tests/acceptance/job-versions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import Versions from 'nomad-ui/tests/pages/jobs/job/versions';
import moment from 'moment';

Expand All @@ -19,6 +20,11 @@ module('Acceptance | job versions', function(hooks) {
await Versions.visit({ id: job.id });
});

test('it passes an accessibility audit', async function(assert) {
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/jobs/:id/versions should list all job versions', async function(assert) {
assert.ok(Versions.versions.length, versions.length, 'Each version gets a row in the timeline');
assert.equal(document.title, `Job ${job.name} versions - Nomad`);
Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/jobs-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import pageSizeSelect from './behaviors/page-size-select';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import Layout from 'nomad-ui/tests/pages/layout';
Expand All @@ -23,6 +24,12 @@ module('Acceptance | jobs list', function(hooks) {
window.localStorage.nomadTokenSecret = managementToken.secretId;
});

test('it passes an accessibility audit', async function(assert) {
await JobsList.visit();
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('visiting /jobs', async function(assert) {
await JobsList.visit();

Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/namespaces-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import { selectChoose } from 'ember-power-select/test-support';
import JobsList from 'nomad-ui/tests/pages/jobs/list';
import ClientsList from 'nomad-ui/tests/pages/clients/list';
Expand Down Expand Up @@ -47,6 +48,12 @@ module('Acceptance | namespaces (enabled)', function(hooks) {
window.localStorage.clear();
});

test('it passes an accessibility audit', async function(assert) {
await JobsList.visit();
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('the namespace switcher lists all namespaces', async function(assert) {
const namespaces = server.db.namespaces;

Expand Down
14 changes: 14 additions & 0 deletions ui/tests/acceptance/plugin-allocations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import pageSizeSelect from './behaviors/page-size-select';
import PluginAllocations from 'nomad-ui/tests/pages/storage/plugins/plugin/allocations';

Expand All @@ -16,6 +17,19 @@ module('Acceptance | plugin allocations', function(hooks) {
window.localStorage.clear();
});

test('it passes an accessibility audit', async function(assert) {
plugin = server.create('csi-plugin', {
shallow: true,
controllerRequired: true,
controllersExpected: 3,
nodesExpected: 3,
});

await PluginAllocations.visit({ id: plugin.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/csi/plugins/:id/allocations shows all allocations in a single table', async function(assert) {
plugin = server.create('csi-plugin', {
shallow: true,
Expand Down
7 changes: 7 additions & 0 deletions ui/tests/acceptance/plugin-detail-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
import moment from 'moment';
import { formatBytes } from 'nomad-ui/helpers/format-bytes';
import PluginDetail from 'nomad-ui/tests/pages/storage/plugins/detail';
Expand All @@ -17,6 +18,12 @@ module('Acceptance | plugin detail', function(hooks) {
plugin = server.create('csi-plugin', { controllerRequired: true });
});

test('it passes an accessibility audit', async function(assert) {
await PluginDetail.visit({ id: plugin.id });
await a11yAudit();
assert.ok(true, 'a11y audit passes');
});

test('/csi/plugins/:id should have a breadcrumb trail linking back to Plugins and Storage', async function(assert) {
await PluginDetail.visit({ id: plugin.id });

Expand Down
Loading

0 comments on commit d06919b

Please sign in to comment.