fix ESLint warnings for QUnit (#725)

This commit is contained in:
Jeldrik Hanschke 2023-11-04 17:32:09 +01:00 committed by GitHub
parent bf87f6f305
commit 0c4ef6fc5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 251 additions and 271 deletions

View file

@ -58,12 +58,7 @@ module.exports = {
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
rules: {
'qunit/no-assert-equal': 'warn',
'qunit/no-assert-logical-expression': 'warn',
'qunit/no-async-module-callbacks': 'warn',
'qunit/require-expect': 'warn',
},
rules: {},
},
],
};

View file

@ -47,7 +47,7 @@ module('Acceptance | create a poll', function (hooks) {
];
await pageCreateIndex.visit();
assert.equal(currentRouteName(), 'create.index');
assert.strictEqual(currentRouteName(), 'create.index');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -76,7 +76,7 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -91,7 +91,7 @@ module('Acceptance | create a poll', function (hooks) {
assert.ok(pageCreateMeta.titleHasFocus, 'title input has autofocus');
await pageCreateMeta.title('default poll').next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -106,7 +106,7 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateOptions.selectDates(dates);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -124,7 +124,7 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -148,7 +148,7 @@ module('Acceptance | create a poll', function (hooks) {
await assert.asyncThrows(async () => {
await pageCreateSettings.save();
}, 'Unexpected server-side error. Server responded with 503 (Service Unavailable)');
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
// simulate server is available again
// defer creation for testing loading spinner
@ -174,17 +174,17 @@ module('Acceptance | create a poll', function (hooks) {
resolveSubmission(resolveSubmissionWith);
await settled();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(
pagePollParticipation.urlIsValid(),
`poll url ${currentURL()} is valid`,
);
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'',
'poll description is correct',
@ -228,7 +228,7 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateIndex.pollType('MakeAPoll').next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -252,7 +252,7 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateMeta.title('default poll').next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -268,7 +268,7 @@ module('Acceptance | create a poll', function (hooks) {
pageCreateOptions.firstTextOption.inputHasFocus,
'first option input has autofocus',
);
assert.equal(
assert.strictEqual(
pageCreateOptions.textOptions.length,
2,
'there are two input fields as default',
@ -287,26 +287,41 @@ module('Acceptance | create a poll', function (hooks) {
'status bar shows correct item as current path (options.text)',
);
assert.ok(
pageCreateOptions.textOptions.objectAt(0).hasError &&
pageCreateOptions.textOptions.objectAt(1).hasError,
'validation errors are shown after submit',
pageCreateOptions.textOptions.objectAt(0).hasError,
'validation error is shown after submit for first text option',
);
assert.ok(
pageCreateOptions.textOptions.objectAt(1).hasError,
'validation error is shown after submit for second text option',
);
await pageCreateOptions.textOptions.objectAt(0).title('option a');
await pageCreateOptions.textOptions.objectAt(1).title('option c');
await pageCreateOptions.textOptions.objectAt(0).add();
assert.equal(pageCreateOptions.textOptions.length, 3, 'option was added');
assert.strictEqual(
pageCreateOptions.textOptions.length,
3,
'option was added',
);
await pageCreateOptions.textOptions.objectAt(1).title('option b');
await pageCreateOptions.textOptions.objectAt(2).add();
assert.equal(pageCreateOptions.textOptions.length, 4, 'option was added');
assert.strictEqual(
pageCreateOptions.textOptions.length,
4,
'option was added',
);
await pageCreateOptions.textOptions.objectAt(3).title('to be deleted');
await pageCreateOptions.textOptions.objectAt(3).delete();
assert.equal(pageCreateOptions.textOptions.length, 3, 'option got deleted');
assert.strictEqual(
pageCreateOptions.textOptions.length,
3,
'option got deleted',
);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
assert
.dom('[data-test-form-step].is-active')
.hasText(
@ -320,14 +335,14 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'',
'poll description is correct',
@ -349,17 +364,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta
.title('default poll')
.description('a sample description')
.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates(days);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert.deepEqual(
findAll('[data-test-day] label').map((el) => el.textContent.trim()),
days.map((day) =>
@ -373,17 +388,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateOptionsDatetime.times.objectAt(1).time('18:00');
await pageCreateOptionsDatetime.times.objectAt(2).time('12:00');
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'a sample description',
'poll description is correct',
@ -414,17 +429,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta
.title('default poll')
.description('a sample description')
.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates([day]);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert.deepEqual(
findAll('[data-test-day] label').map((el) => el.textContent.trim()),
[Intl.DateTimeFormat('en-US', { dateStyle: 'full' }).format(day)],
@ -486,17 +501,17 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'a sample description',
'poll description is correct',
@ -523,17 +538,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta
.title('default poll')
.description('a sample description')
.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates([day]);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert.deepEqual(
findAll('[data-test-day] label').map((el) => el.textContent.trim()),
[Intl.DateTimeFormat('en-US', { dateStyle: 'full' }).format(day)],
@ -541,17 +556,17 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'a sample description',
'poll description is correct',
@ -570,17 +585,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta
.title('default poll')
.description('a sample description')
.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates([day]);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert.deepEqual(
findAll('[data-test-day] label').map((el) => el.textContent.trim()),
[Intl.DateTimeFormat('en-US', { dateStyle: 'full' }).format(day)],
@ -589,17 +604,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateOptionsDatetime.times.objectAt(0).time('22:30');
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'a sample description',
'poll description is correct',
@ -626,18 +641,18 @@ module('Acceptance | create a poll', function (hooks) {
await visit('/create');
await click('button[type="submit"]');
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await fillIn(
'[data-test-form-element="title"] input[type="text"]',
'example poll for to test time adopting workflow',
);
await click('button[type="submit"]');
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates(days);
await click('button[type="submit"]');
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
for (let i = 1; i <= 3; i++) {
await click(
@ -729,10 +744,10 @@ module('Acceptance | create a poll', function (hooks) {
);
await click('button[type="submit"]');
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await click('button[type="submit"]');
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.deepEqual(
findAll(
`[data-test-form-element^="option"] label:not(.custom-control-label)`,
@ -761,11 +776,11 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.pollType('MakeAPoll').next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta.title('default poll').next();
assert.equal(currentRouteName(), 'create.options');
assert.equal(
assert.strictEqual(currentRouteName(), 'create.options');
assert.strictEqual(
pageCreateOptions.textOptions.length,
2,
'there are two input fields as default',
@ -773,20 +788,24 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateOptions.textOptions.objectAt(0).title('option a');
await pageCreateOptions.textOptions.objectAt(1).delete();
assert.equal(pageCreateOptions.textOptions.length, 1, 'option was deleted');
assert.strictEqual(
pageCreateOptions.textOptions.length,
1,
'option was deleted',
);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'',
'poll description is correct',
@ -807,17 +826,17 @@ module('Acceptance | create a poll', function (hooks) {
await pageCreateIndex.visit();
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta
.title('default poll')
.description('a sample description')
.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates(days);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert.deepEqual(
findAll('[data-test-day] label').map((el) => el.textContent.trim()),
days.map((day) =>
@ -832,7 +851,7 @@ module('Acceptance | create a poll', function (hooks) {
.hasValue('10:00', 'time input has the value entered by the user');
await backButton();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
assert.deepEqual(
findAll('.ember-power-calendar-day--selected').map(
(el) => el.dataset.date,
@ -842,7 +861,7 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
assert
.dom('[data-test-day="2016-01-02"] input[type="time"]')
.hasValue('', 'time input the user has not touched is still empty');
@ -854,17 +873,17 @@ module('Acceptance | create a poll', function (hooks) {
);
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.save();
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.true(pagePollParticipation.urlIsValid(), 'poll url is valid');
assert.equal(
assert.strictEqual(
pagePollParticipation.title,
'default poll',
'poll title is correct',
);
assert.equal(
assert.strictEqual(
pagePollParticipation.description,
'a sample description',
'poll description is correct',
@ -886,60 +905,60 @@ module('Acceptance | create a poll', function (hooks) {
test('Start at first step is enforced', async function (assert) {
await pageCreateSettings.visit();
assert.equal(currentRouteName(), 'create.index');
assert.strictEqual(currentRouteName(), 'create.index');
});
test('back button', async function (assert) {
await pageCreateIndex.visit();
assert.equal(currentRouteName(), 'create.index');
assert.strictEqual(currentRouteName(), 'create.index');
await pageCreateIndex.next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta.title('foo').next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.selectDates([new Date()]);
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
await pageCreateOptionsDatetime.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.back();
assert.equal(currentRouteName(), 'create.options-datetime');
assert.strictEqual(currentRouteName(), 'create.options-datetime');
await pageCreateOptionsDatetime.back();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.back();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta.back();
assert.equal(currentRouteName(), 'create.index');
assert.strictEqual(currentRouteName(), 'create.index');
await pageCreateIndex.pollType('MakeAPoll').next();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta.next();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.textOptions.objectAt(0).title('foo');
await pageCreateOptions.textOptions.objectAt(1).title('bar');
await pageCreateOptions.next();
assert.equal(currentRouteName(), 'create.settings');
assert.strictEqual(currentRouteName(), 'create.settings');
await pageCreateSettings.back();
assert.equal(currentRouteName(), 'create.options');
assert.strictEqual(currentRouteName(), 'create.options');
await pageCreateOptions.back();
assert.equal(currentRouteName(), 'create.meta');
assert.strictEqual(currentRouteName(), 'create.meta');
await pageCreateMeta.back();
assert.equal(currentRouteName(), 'create.index');
assert.strictEqual(currentRouteName(), 'create.index');
});
module('validation', async function () {
module('validation', function () {
test('validates user input when creating a poll with dates and times', async function (assert) {
const day = DateTime.now();

View file

@ -1,4 +1,4 @@
import { fillIn, find, visit } from '@ember/test-helpers';
import { fillIn, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
@ -11,15 +11,13 @@ module('Acceptance | i18n', function (hooks) {
test('locale is saved in localStorage', async function (assert) {
await visit('/');
assert.equal(
find('.language-select').value,
'de',
'picks up locale in locale storage',
);
assert
.dom('.language-select')
.hasValue('de', 'picks up locale in locale storage');
await fillIn('.language-select', 'en');
assert.equal(find('.language-select').value, 'en');
assert.equal(
assert.dom('.language-select').hasValue('en', 'shows changed locale');
assert.strictEqual(
window.localStorage.getItem('locale'),
'en',
'persisted in localeStorage',

View file

@ -1,6 +1,5 @@
import {
click,
find,
findAll,
currentURL,
currentRouteName,
@ -38,20 +37,20 @@ module('Acceptance | participate in a poll', function (hooks) {
});
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll.participation',
'poll is redirected to poll.participation',
);
await pollParticipate('Max Meiner', ['yes', 'no']);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
currentURL().split('?')[1],
`encryptionKey=${encryptionKey}`,
'encryption key is part of query params',
);
assert.equal(
assert.strictEqual(
PollEvaluationPage.participants.length,
1,
'user is added to participants table',
@ -68,16 +67,16 @@ module('Acceptance | participate in a poll', function (hooks) {
);
await click('.nav [data-test-link="participation"]');
assert.equal(currentRouteName(), 'poll.participation');
assert.equal(find('.name input').value, '', 'input for name is cleared');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert.dom('.name input').hasNoValue('input for name is cleared');
assert.notOk(
findAll('input[type="radio"]').some((el) => el.checked),
'radios are cleared',
);
await pollParticipate('Peter Müller', ['yes', 'yes']);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
PollEvaluationPage.participants.length,
2,
'user is added to participants table',
@ -103,11 +102,11 @@ module('Acceptance | participate in a poll', function (hooks) {
});
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
await pollParticipate('Max Manus', ['answer 1', 'answer 2']);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
PollEvaluationPage.participants.length,
1,
'user is added to participants table',
@ -135,11 +134,11 @@ module('Acceptance | participate in a poll', function (hooks) {
await visit(
`/poll/${poll.id}/participation?encryptionKey=${encryptionKey}`,
);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
await pollParticipate('Karl Käfer', ['yes', null]);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
PollEvaluationPage.participants.length,
1,
'user is added to participants table',
@ -167,11 +166,11 @@ module('Acceptance | participate in a poll', function (hooks) {
await visit(
`/poll/${poll.id}/participation?encryptionKey=${encryptionKey}`,
);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
await pollParticipate(null, ['yes', 'no']);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
PollEvaluationPage.participants.length,
1,
'user is added to participants table',
@ -197,7 +196,7 @@ module('Acceptance | participate in a poll', function (hooks) {
await visit(
`/poll/${poll.id}/participation?encryptionKey=${encryptionKey}`,
);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
assert
.dom('[data-test-modal="saving-failed"] .modal-content')
.isNotVisible(
@ -217,8 +216,8 @@ module('Acceptance | participate in a poll', function (hooks) {
.isNotVisible(
'Notification is hidden after another save attempt was successful',
);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert.strictEqual(
PollEvaluationPage.participants.length,
1,
'user is added to participants table',
@ -301,7 +300,7 @@ module('Acceptance | participate in a poll', function (hooks) {
assert.dom('[data-test-form-element="name"] input').isFocused();
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll.participation',
'invalid form prevents a transition',
@ -337,7 +336,7 @@ module('Acceptance | participate in a poll', function (hooks) {
assert
.dom('[data-test-form-element="option-2017-12-24"] input[id$="yes"]')
.isFocused();
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll.participation',
'invalid form prevents a transition',
@ -374,7 +373,7 @@ module('Acceptance | participate in a poll', function (hooks) {
assert.dom('[data-test-form-element="name"] input').isFocused();
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll.participation',
'invalid form prevents a transition',

View file

@ -1,10 +1,4 @@
import {
findAll,
click,
currentRouteName,
find,
visit,
} from '@ember/test-helpers';
import { findAll, click, currentRouteName, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
@ -28,14 +22,12 @@ module('Acceptance | view evaluation', function (hooks) {
});
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
await click('.nav [data-test-link="evaluation"]');
assert.equal(
findAll('.tab-content .tab-pane .evaluation-summary').length,
0,
'evaluation summary is not present',
);
assert
.dom('.tab-content .tab-pane .evaluation-summary')
.doesNotExist('evaluation summary is not present');
});
test('evaluation is correct for FindADate (date-only)', async function (assert) {
@ -102,24 +94,23 @@ module('Acceptance | view evaluation', function (hooks) {
});
await visit(`/poll/${poll.id}/evaluation?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
findAll('.tab-content .tab-pane .evaluation-summary').length,
1,
'evaluation summary is present',
);
assert.equal(
find('.participants').textContent.trim(),
t('poll.evaluation.participants', { count: 2 }).toString(),
'shows number of participants',
);
assert.equal(
find('.best-options strong').textContent.trim(),
'Friday, January 1, 2016',
'shows option most participants replied with yes to as best option',
);
assert.equal(
find('.last-participation').textContent.trim(),
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert
.dom('.tab-content .tab-pane .evaluation-summary')
.exists({ count: 1 }, 'evaluation summary is present');
assert
.dom('.participants')
.hasText(
t('poll.evaluation.participants', { count: 2 }).toString(),
'shows number of participants',
);
assert
.dom('.best-options strong')
.hasText(
'Friday, January 1, 2016',
'shows option most participants replied with yes to as best option',
);
assert.dom('.last-participation').hasText(
t('poll.evaluation.lastParticipation', {
ago: '3 months ago',
}).toString(),
@ -260,24 +251,23 @@ module('Acceptance | view evaluation', function (hooks) {
});
await visit(`/poll/${poll.id}/evaluation?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
findAll('.tab-content .tab-pane .evaluation-summary').length,
1,
'evaluation summary is present',
);
assert.equal(
find('.participants').textContent.trim(),
t('poll.evaluation.participants', { count: 2 }).toString(),
'shows number of participants',
);
assert.equal(
find('.best-options strong').textContent.trim(),
'Saturday, December 12, 2015 at 12:12 PM',
'shows option most participants replied with yes to as best option',
);
assert.equal(
find('.last-participation').textContent.trim(),
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert
.dom('.tab-content .tab-pane .evaluation-summary')
.exists({ count: 1 }, 'evaluation summary is present');
assert
.dom('.participants')
.hasText(
t('poll.evaluation.participants', { count: 2 }).toString(),
'shows number of participants',
);
assert
.dom('.best-options strong')
.hasText(
'Saturday, December 12, 2015 at 12:12 PM',
'shows option most participants replied with yes to as best option',
);
assert.dom('.last-participation').hasText(
t('poll.evaluation.lastParticipation', {
ago: '3 months ago',
}).toString(),
@ -450,22 +440,19 @@ module('Acceptance | view evaluation', function (hooks) {
});
await visit(`/poll/${poll.id}/evaluation?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
findAll('.tab-content .tab-pane .evaluation-summary').length,
1,
'evaluation summary is present',
);
assert.equal(
find('.participants').textContent.trim(),
t('poll.evaluation.participants', { count: 2 }).toString(),
'participants are counted correctly',
);
assert.equal(
find('.best-options strong').textContent.trim(),
'second option',
'options are evaluated correctly',
);
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert
.dom('.tab-content .tab-pane .evaluation-summary')
.exists({ count: 1 }, 'evaluation summary is present');
assert
.dom('.participants')
.hasText(
t('poll.evaluation.participants', { count: 2 }).toString(),
'participants are counted correctly',
);
assert
.dom('.best-options strong')
.hasText('second option', 'options are evaluated correctly');
assert.deepEqual(
PollEvaluationPage.options.map((_) => _.label),
@ -489,8 +476,7 @@ module('Acceptance | view evaluation', function (hooks) {
);
});
assert.equal(
find('.last-participation').textContent.trim(),
assert.dom('.last-participation').hasText(
t('poll.evaluation.lastParticipation', {
ago: '3 days ago',
}).toString(),
@ -560,14 +546,12 @@ module('Acceptance | view evaluation', function (hooks) {
});
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.participation');
assert.strictEqual(currentRouteName(), 'poll.participation');
await click('.nav [data-test-link="evaluation"]');
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
find('.tab-pane h2').textContent.trim(),
t('poll.evaluation.label').toString(),
'headline is there',
);
assert.strictEqual(currentRouteName(), 'poll.evaluation');
assert
.dom('.tab-pane h2')
.hasText(t('poll.evaluation.label').toString(), 'headline is there');
});
});

View file

@ -24,7 +24,7 @@ module('Acceptance | view poll', function (hooks) {
let pollUrl = `/poll/${poll.id}?encryptionKey=${encryptionKey}`;
await visit(pollUrl);
assert.equal(
assert.strictEqual(
pageParticipation.url,
window.location.href,
'share link is shown',
@ -259,12 +259,12 @@ module('Acceptance | view poll', function (hooks) {
let encryptionKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
await visit(`/poll/${pollId}?encryptionKey=${encryptionKey}`);
assert.equal(
assert.strictEqual(
currentURL(),
`/poll/${pollId}?encryptionKey=${encryptionKey}`,
'shows URL entered by user',
);
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll_error',
'shows error substate of poll route',
@ -279,12 +279,12 @@ module('Acceptance | view poll', function (hooks) {
let poll = this.server.create('poll', { encryptionKey: 'anotherkey' });
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(
assert.strictEqual(
currentURL(),
`/poll/${poll.id}?encryptionKey=${encryptionKey}`,
'shows URL entered by user',
);
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll_error',
'shows error substate of poll route',
@ -302,12 +302,12 @@ module('Acceptance | view poll', function (hooks) {
this.server.get('polls/:id', () => {}, 500);
await visit(`/poll/${pollId}?encryptionKey=${encryptionKey}`);
assert.equal(
assert.strictEqual(
currentURL(),
`/poll/${pollId}?encryptionKey=${encryptionKey}`,
'shows URL entered by user',
);
assert.equal(
assert.strictEqual(
currentRouteName(),
'poll_error',
'shows error substate of poll route',

View file

@ -1,6 +1,6 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click, find, findAll } from '@ember/test-helpers';
import { render, click, findAll } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { setupIntl } from 'ember-intl/test-support';
@ -26,16 +26,12 @@ module('Integration | Component | create options datetime', function (hooks) {
hbs`<CreateOptionsDatetime @dates={{this.dates}} @times={{this.times}} />`,
);
assert.equal(
findAll('.days .form-group input').length,
1,
'there is one input field',
);
assert.equal(
find('.days .form-group input').value,
'',
'value is an empty string',
);
assert
.dom('.days .form-group input')
.exists({ count: 1 }, 'there is one input field');
assert
.dom('.days .form-group input')
.hasNoValue('value is an empty string');
});
test('it generates input field for options iso 8601 datetime string (with time)', async function (assert) {
@ -45,16 +41,12 @@ module('Integration | Component | create options datetime', function (hooks) {
hbs`<CreateOptionsDatetime @dates={{this.dates}} @times={{this.times}} />`,
);
assert.equal(
findAll('.days .form-group input').length,
1,
'there is one input field',
);
assert.equal(
find('.days .form-group input').value,
'11:11',
'it has time in option as value',
);
assert
.dom('.days .form-group input')
.exists({ count: 1 }, 'there is one input field');
assert
.dom('.days .form-group input')
.hasValue('11:11', 'it has time in option as value');
});
test('it hides repeated labels', async function (assert) {
@ -64,16 +56,15 @@ module('Integration | Component | create options datetime', function (hooks) {
hbs`<CreateOptionsDatetime @dates={{this.dates}} @times={{this.times}} />`,
);
assert.equal(
findAll('.days label').length,
3,
'every form-group has a label',
);
assert.equal(
findAll('.days label:not(.sr-only)').length,
2,
'there are two not hidden labels for two different dates',
);
assert
.dom('.days label')
.exists({ count: 3 }, 'every form-group has a label');
assert
.dom('.days label:not(.sr-only)')
.exists(
{ count: 2 },
'there are two not hidden labels for two different dates',
);
assert.notOk(
findAll('.days .form-group')[0]
.querySelector('label')
@ -101,19 +92,15 @@ module('Integration | Component | create options datetime', function (hooks) {
hbs`<CreateOptionsDatetime @dates={{this.dates}} @times={{this.times}} />`,
);
assert.equal(
findAll('.days .form-group input').length,
2,
'there are two input fields before',
);
assert
.dom('.days .form-group input')
.exists({ count: 2 }, 'there are two input fields before');
await click(findAll('.days .form-group')[0].querySelector('.add'));
assert.equal(
findAll('.days .form-group input').length,
3,
'another input field is added',
);
assert.equal(
assert
.dom('.days .form-group input')
.exists({ count: 3 }, 'another input field is added');
assert.strictEqual(
findAll('.days .form-group')[1].querySelector('label').textContent,
findAll('.days .form-group')[0].querySelector('label').textContent,
'new input has correct label',
@ -133,26 +120,20 @@ module('Integration | Component | create options datetime', function (hooks) {
hbs`<CreateOptionsDatetime @dates={{this.dates}} @times={{this.times}} />`,
);
assert.equal(
findAll('.days input').length,
2,
'there are two input fields before',
);
assert
.dom('.days input')
.exists({ count: 2 }, 'there are two input fields before');
assert.ok(
findAll('.delete').every((el) => el.disabled === false),
'options are deleteable',
);
await click(findAll('.days .form-group')[0].querySelector('.delete'));
assert.equal(
findAll('.days .form-group input').length,
1,
'one input field is removed after deletion',
);
assert.equal(
find('.days .form-group input').value,
'22:22',
'correct input field is deleted',
);
assert
.dom('.days .form-group input')
.exists({ count: 1 }, 'one input field is removed after deletion');
assert
.dom('.days .form-group input')
.hasValue('22:22', 'correct input field is deleted');
});
});

View file

@ -14,8 +14,6 @@ module('Integration | Component | create options', function (hooks) {
});
test('shows validation errors if options are not unique (makeAPoll)', async function (assert) {
assert.expect(5);
this.set('options', new TrackedSet());
await render(hbs`
@ -66,7 +64,7 @@ module('Integration | Component | create options', function (hooks) {
/>
`);
assert.equal(findAll('.form-group.has-error').length, 0);
assert.dom('.form-group.has-error').doesNotExist();
await focus(findAll('input')[0]);
await blur(findAll('input')[0]);

View file

@ -14,8 +14,11 @@ module('Integration | Mirage api mocking', function (hooks) {
encryptionKey,
title: 'foo',
});
assert.equal(JSON.parse(sjcl.decrypt(encryptionKey, poll.title)), 'foo');
assert.equal(
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, poll.title)),
'foo',
);
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, poll.description)),
'bar',
);
@ -27,6 +30,9 @@ module('Integration | Mirage api mocking', function (hooks) {
encryptionKey,
name: 'foo',
});
assert.equal(JSON.parse(sjcl.decrypt(encryptionKey, user.name)), 'foo');
assert.strictEqual(
JSON.parse(sjcl.decrypt(encryptionKey, user.name)),
'foo',
);
});
});