Skip to content

Commit

Permalink
ui: apply new qunit linting rules to tests
Browse files Browse the repository at this point in the history
Async tests should use  in integrations tests.
Acceptance tests are using Mirage and can't use
since we can't know the number of assertions.
  • Loading branch information
ChaiWithJai committed Dec 28, 2021
1 parent 5fa392d commit 05017e7
Show file tree
Hide file tree
Showing 92 changed files with 372 additions and 22 deletions.
6 changes: 5 additions & 1 deletion ui/tests/acceptance/allocation-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* Mirage fixtures are random so we can't expect a set number of assertions */
import { run } from '@ember/runloop';
import { currentURL } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
Expand Down Expand Up @@ -49,6 +51,8 @@ module('Acceptance | allocation detail', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await a11yAudit(assert);
});

Expand Down Expand Up @@ -204,6 +208,7 @@ module('Acceptance | allocation detail', function (hooks) {

await Allocation.tasks.objectAt(0).clickLink();

// Make sure the allocation is pending in order to ensure there are no tasks
assert.equal(
currentURL(),
`/allocations/${allocation.id}/${task.name}`,
Expand Down Expand Up @@ -251,7 +256,6 @@ module('Acceptance | allocation detail', function (hooks) {
});

test('when there are no tasks, an empty state is shown', async function (assert) {
// Make sure the allocation is pending in order to ensure there are no tasks
allocation = server.create('allocation', 'withTaskWithPorts', {
clientStatus: 'pending',
});
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/application-errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module('Acceptance | application errors ', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

server.pretender.get('/v1/nodes', () => [500, {}, null]);
await ClientsList.visit();
await a11yAudit(assert);
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/behaviors/fs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { test } from 'qunit';
import { currentURL, visit } from '@ember/test-helpers';

Expand Down
3 changes: 3 additions & 0 deletions ui/tests/acceptance/client-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
/* Mirage fixtures are random so we can't expect a set number of assertions */
import { currentURL, waitUntil, settled } from '@ember/test-helpers';
import { assign } from '@ember/polyfills';
import { module, test } from 'qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/client-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module('Acceptance | client monitor', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await ClientMonitor.visit({ id: node.id });
await a11yAudit(assert);
});
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/clients-list-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/exec-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { module, skip, test } from 'qunit';
import { currentURL, settled } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/job-allocations-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
3 changes: 3 additions & 0 deletions ui/tests/acceptance/job-clients-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down Expand Up @@ -75,11 +76,13 @@ module('Acceptance | job clients', function (hooks) {

['createTime', 'modifyTime'].forEach((col) => {
if (jobStatus === 'not scheduled') {
/* eslint-disable-next-line qunit/no-conditional-assertions */
assert.equal(
clientRow[col].text,
'-',
`row ${index} doesn't have ${col} tooltip`
);
/* eslint-disable-next-line qunit/no-early-return */
return;
}

Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/job-definition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module('Acceptance | job definition', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await a11yAudit(assert, 'scrollable-region-focusable');
});

Expand Down
4 changes: 3 additions & 1 deletion ui/tests/acceptance/job-deployments-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ module('Acceptance | job deployments', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await Deployments.visit({ id: job.id });
await a11yAudit(assert);
});

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

assert.ok(
assert.equal(
Deployments.deployments.length,
deployments.length,
'Each deployment gets a row in the timeline'
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/job-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable ember/no-test-module-for */
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/job-dispatch-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable ember/no-test-module-for */
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/job-evaluations-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/job-run-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ module('Acceptance | job run', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await JobRun.visit();
await a11yAudit(assert);
});
Expand Down
4 changes: 3 additions & 1 deletion ui/tests/acceptance/job-versions-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down Expand Up @@ -36,7 +38,7 @@ module('Acceptance | job versions', function (hooks) {
});

test('/jobs/:id/versions should list all job versions', async function (assert) {
assert.ok(
assert.equal(
Versions.versions.length,
versions.length,
'Each version gets a row in the timeline'
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/jobs-list-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/optimize-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { currentURL, visit } from '@ember/test-helpers';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/plugin-allocations-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/plugin-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/plugins-list-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/regions-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
5 changes: 3 additions & 2 deletions ui/tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable ember-a11y-testing/a11y-audit-called */ // TODO
/* eslint-disable ember-a11y-testing/a11y-audit-called */
/* eslint-disable qunit/require-expect */
import { module, test } from 'qunit';
import { currentURL, triggerEvent, visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
Expand Down Expand Up @@ -114,7 +115,7 @@ module('Acceptance | search', function (hooks) {
request.requestBody.includes('feature-detection-query')
);

assert.ok(
assert.equal(
featureDetectionQueries.length,
1,
'expect the feature detection query to only run once'
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/server-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/server-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module('Acceptance | server monitor', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await ServerMonitor.visit({ name: agent.name });
await a11yAudit(assert);
});
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/servers-list-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/task-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/task-group-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { currentURL, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/task-logs-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL } from '@ember/test-helpers';
import { run } from '@ember/runloop';
import { module, test } from 'qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/token-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module('Acceptance | tokens', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

await Tokens.visit();
await a11yAudit(assert);
});
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/acceptance/topology-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module('Acceptance | topology', function (hooks) {
});

test('it passes an accessibility audit', async function (assert) {
assert.expect(1);

server.createList('node', 3);
server.createList('allocation', 5);

Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/volume-detail-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { module, test } from 'qunit';
import { currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
1 change: 1 addition & 0 deletions ui/tests/acceptance/volumes-list-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable qunit/require-expect */
import { currentURL, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
32 changes: 19 additions & 13 deletions ui/tests/helpers/glimmer-factory.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
// Used in glimmer component unit tests. Glimmer components should typically
// be tested with integration tests, but occasionally individual methods or
// properties have logic that isn't coupled to rendering or the DOM and can
// be better tested in a unit fashion.
//
// Use like
//
// setupGlimmerComponentFactory(hooks, 'my-component')
//
// test('testing my component', function(assert) {
// const component = this.createComponent({ hello: 'world' });
// assert.equal(component.args.hello, 'world');
// });
/* eslint-disable qunit/no-commented-tests */
// We comment test to show an example of how to use the factory function

/*
Used in glimmer component unit tests. Glimmer components should typically
be tested with integration tests, but occasionally individual methods or
properties have logic that isn't coupled to rendering or the DOM and can
be better tested in a unit fashion.
Use like
setupGlimmerComponentFactory(hooks, 'my-component')
test('testing my component', function(assert) {
const component = this.createComponent({ hello: 'world' });
assert.equal(component.args.hello, 'world');
});
*/

export default function setupGlimmerComponentFactory(hooks, componentKey) {
hooks.beforeEach(function () {
this.createComponent = glimmerComponentInstantiator(
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/helpers/module-for-job.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable qunit/require-expect */
/* eslint-disable qunit/no-conditional-assertions */
import { currentURL } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/integration/components/agent-monitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ module('Integration | Component | agent-monitor', function (hooks) {
`;

test('basic appearance', async function (assert) {
assert.expect(5);

this.setProperties({
level: 'info',
client: { id: 'client1' },
Expand Down
6 changes: 6 additions & 0 deletions ui/tests/integration/components/allocation-row-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ module('Integration | Component | allocation row', function (hooks) {
});

test('Allocation row shows warning when it requires drivers that are unhealthy on the node it is running on', async function (assert) {
assert.expect(2);

const node = this.server.schema.nodes.first();
const drivers = node.drivers;
Object.values(drivers).forEach((driver) => {
Expand Down Expand Up @@ -113,6 +115,8 @@ module('Integration | Component | allocation row', function (hooks) {
});

test('Allocation row shows an icon indicator when it was preempted', async function (assert) {
assert.expect(2);

const allocId = this.server.create('allocation', 'preempted').id;
const allocation = await this.store.findRecord('allocation', allocId);

Expand All @@ -128,6 +132,8 @@ module('Integration | Component | allocation row', function (hooks) {
});

test('when an allocation is not running, the utilization graphs are omitted', async function (assert) {
assert.expect(8);

this.setProperties({
context: 'job',
enablePolling: false,
Expand Down
4 changes: 4 additions & 0 deletions ui/tests/integration/components/app-breadcrumbs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ module('Integration | Component | app breadcrumbs', function (hooks) {
});

test('every breadcrumb is rendered correctly', async function (assert) {
assert.expect(2);

this.breadcrumbs.set('breadcrumbs', commonCrumbs);

await render(template);
Expand All @@ -60,6 +62,8 @@ module('Integration | Component | app breadcrumbs', function (hooks) {
});

test('when breadcrumbs are pending promises, an ellipsis is rendered', async function (assert) {
assert.expect(3);

let resolvePromise;
const promise = new RSVP.Promise((resolve) => {
resolvePromise = resolve;
Expand Down
2 changes: 2 additions & 0 deletions ui/tests/integration/components/attributes-table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module('Integration | Component | attributes table', function (hooks) {
};

test('should render a row for each key/value pair in a deep object', async function (assert) {
assert.expect(2);

this.set('attributes', commonAttributes);
await render(hbs`<AttributesTable @attributePairs={{attributes}} />`);

Expand Down
Loading

0 comments on commit 05017e7

Please sign in to comment.