Fix remaining deprecations (#711)

* fix: Use of assign has been deprecated. Please use Object.assign or the spread operator instead.

* fix @tagName argument of <LinkTo> is deprecated

* clean-up deprecation workflow
This commit is contained in:
Jeldrik Hanschke 2023-10-28 19:21:45 +02:00 committed by GitHub
parent 2d5914ff63
commit 5146bbdf36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 58 deletions

View file

@ -91,33 +91,26 @@
<div class="box">
<ul class="nav nav-tabs" role="tablist">
{{! template-lint-disable no-link-to-tagname no-unknown-arguments-for-builtin-components }}
{{!
TODO: Refactor to current Bootstrap markup, which uses a regular
`<a></a>` element within a `<li class="nav-item"></li>`.
}}
<LinkTo
@route="poll.participation"
@model={{poll}}
@tagName="li"
@activeClass="active"
class="participation nav-item"
>
<LinkTo @route="poll.participation" @model={{poll}} class="nav-link">
<li class="nav-item">
<LinkTo
@route="poll.participation"
@model={{poll.id}}
class="nav-link"
data-test-link="participation"
>
{{t "poll.tab-title.participation"}}
</LinkTo>
</LinkTo>
<LinkTo
@route="poll.evaluation"
@model={{poll}}
@tagName="li"
@activeClass="active"
class="evaluation nav-item"
>
<LinkTo @route="poll.evaluation" @model={{poll}} class="nav-link">
</li>
<li class="nav-item">
<LinkTo
@route="poll.evaluation"
@model={{poll.id}}
class="nav-link"
data-test-link="evaluation"
>
{{t "poll.tab-title.evaluation"}}
</LinkTo>
</LinkTo>
</li>
</ul>
<div class="tab-content">

View file

@ -3,19 +3,12 @@
self.deprecationWorkflow = self.deprecationWorkflow || {};
self.deprecationWorkflow.config = {
workflow: [
// @ember/string deprecation is thrown even if all deprecated behavior is
// fixed due to a bug in Ember itself. Details can be found in:
// https://github.com/emberjs/ember.js/issues/20377
{
handler: 'silence',
matchId: 'deprecated-run-loop-and-computed-dot-access',
matchId: 'ember-string.add-package',
},
{
handler: 'silence',
matchId: 'ember-cli-mirage-config-routes-only-export',
},
{ handler: 'silence', matchId: 'ember-modifier.function-based-options' },
{ handler: 'silence', matchId: 'ember-cli-mirage.miragejs.import' },
{ handler: 'silence', matchId: 'ember.link-to.tag-name' },
{ handler: 'throw', matchId: 'ember-cli-page-object.multiple' },
{ handler: 'silence', matchId: 'autotracking.mutation-after-consumption' },
{ handler: 'silence', matchId: 'ember-runtime.deprecate-copy-copyable' },
],
};

View file

@ -67,7 +67,7 @@ module('Acceptance | participate in a poll', function (hooks) {
'participants table shows correct answers for new participant',
);
await click('.nav .participation');
await click('.nav [data-test-link="participation"]');
assert.equal(currentRouteName(), 'poll.participation');
assert.equal(find('.name input').value, '', 'input for name is cleared');
assert.notOk(

View file

@ -1,11 +1,15 @@
import { findAll, currentRouteName, find, visit } from '@ember/test-helpers';
import {
findAll,
click,
currentRouteName,
find,
visit,
} from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { setupIntl, t } from 'ember-intl/test-support';
import switchTab from 'croodle/tests/helpers/switch-tab';
import PollEvaluationPage from 'croodle/tests/pages/poll/evaluation';
import { assign } from '@ember/polyfills';
import { DateTime } from 'luxon';
module('Acceptance | view evaluation', function (hooks) {
@ -26,7 +30,7 @@ module('Acceptance | view evaluation', function (hooks) {
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.participation');
await switchTab('evaluation');
await click('.nav [data-test-link="evaluation"]');
assert.equal(
findAll('.tab-content .tab-pane .evaluation-summary').length,
0,
@ -440,12 +444,10 @@ module('Acceptance | view evaluation', function (hooks) {
options: [{ title: 'first option' }, { title: 'second option' }],
pollType: 'MakeAPoll',
};
let poll = this.server.create(
'poll',
assign(pollData, {
users: usersData.map((_) => this.server.create('user', _)),
}),
);
let poll = this.server.create('poll', {
...pollData,
users: usersData.map((_) => this.server.create('user', _)),
});
await visit(`/poll/${poll.id}/evaluation?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.evaluation');
@ -560,7 +562,7 @@ module('Acceptance | view evaluation', function (hooks) {
await visit(`/poll/${poll.id}?encryptionKey=${encryptionKey}`);
assert.equal(currentRouteName(), 'poll.participation');
await switchTab('evaluation');
await click('.nav [data-test-link="evaluation"]');
assert.equal(currentRouteName(), 'poll.evaluation');
assert.equal(
find('.tab-pane h2').textContent.trim(),

View file

@ -8,7 +8,6 @@ import {
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { setupMirage } from 'ember-cli-mirage/test-support';
import switchTab from 'croodle/tests/helpers/switch-tab';
import pageParticipation from 'croodle/tests/pages/poll/participation';
import { DateTime } from 'luxon';
import { triggerCopySuccess } from 'ember-cli-clipboard/test-support';
@ -169,7 +168,7 @@ module('Acceptance | view poll', function (hooks) {
.dom('[data-test-modal="choose-timezone"]')
.doesNotExist('modal is closed');
await switchTab('evaluation');
await click('.nav [data-test-link="evaluation"]');
assert.deepEqual(
findAll('[data-test-best-option]').map((el) => el.textContent.trim()),
[
@ -244,7 +243,7 @@ module('Acceptance | view poll', function (hooks) {
.dom('[data-test-modal="choose-timezone"]')
.doesNotExist('modal is closed');
await switchTab('evaluation');
await click('.nav [data-test-link="evaluation"]');
assert.deepEqual(
findAll('[data-test-best-option]').map((el) => el.textContent.trim()),
[

View file

@ -1,5 +0,0 @@
import { click } from '@ember/test-helpers';
export default function (tab) {
return click(`.nav-tabs .${tab} a`);
}

View file

@ -10,7 +10,6 @@ import {
import { defaultsForCreate } from 'croodle/tests/pages/defaults';
import { hasFocus } from 'croodle/tests/pages/helpers';
import { calendarSelect } from 'ember-power-calendar/test-support';
import { assign } from '@ember/polyfills';
import { isArray } from '@ember/array';
import { assert } from '@ember/debug';
import { DateTime } from 'luxon';
@ -41,7 +40,7 @@ function selectDates(selector) {
}
export default create(
assign({}, defaultsForCreate, {
Object.assign({}, defaultsForCreate, {
selectDates: selectDates('[data-test-form-element-for="days"]'),
dateHasError: isVisible('.days.has-error'),
dateError: text('.days .help-block'),

View file

@ -1,10 +1,9 @@
import { attribute, collection, create, text } from 'ember-cli-page-object';
import { definition as Poll } from 'croodle/tests/pages/poll';
import { defaultsForApplication } from 'croodle/tests/pages/defaults';
import { assign } from '@ember/polyfills';
export default create(
assign({}, defaultsForApplication, Poll, {
Object.assign({}, defaultsForApplication, Poll, {
options: collection(
'[data-test-table-of="participants"] thead tr:last-child th:not(:first-child)',
{