Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
refactor: deprecations (#893)
Browse files Browse the repository at this point in the history
* fix: add the missing package to run the tests

* fix: errors that hided by (routing.transition-methods)

* fix: confirming zero issue in some deprecation workflow

* fix: checking the others deprecation, and testing

* fix: this-property-fallback in deprecated workflow

* fix: this-property-fallback in deprecated workflow
  • Loading branch information
MitanOmar authored Apr 4, 2023
1 parent b00f97b commit 0c3920c
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 57 deletions.
4 changes: 3 additions & 1 deletion app/index/activities/edit/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @public
*/
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import Changeset from "ember-changeset";
import lookupValidator from "ember-changeset-validations";
import RouteAutostartTourMixin from "timed/mixins/route-autostart-tour";
Expand All @@ -19,6 +20,7 @@ import ActivityValidator from "timed/validations/activity";
export default class IndexActivityEditController extends Route.extend(
RouteAutostartTourMixin
) {
@service router;
/**
* Model hook, fetch the activity to edit
*
Expand All @@ -34,7 +36,7 @@ export default class IndexActivityEditController extends Route.extend(

afterModel(model) {
if (model.get("transferred")) {
this.transitionTo("index");
this.router.transitionTo("index");
}
}

Expand Down
13 changes: 9 additions & 4 deletions app/users/edit/credits/absence-credits/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default Controller.extend({
userCreditsController: controller("users.edit.credits.index"),

notify: service("notify"),
router: service("router"),

absenceTypes: task(function* () {
return yield this.store.query("absence-type", {
Expand Down Expand Up @@ -49,9 +50,13 @@ export default Controller.extend({
const year =
allYears.find((y) => y === String(changeset.get("date").year())) || "";

yield this.transitionToRoute("users.edit.credits", this.get("user.id"), {
queryParams: { year },
});
yield this.router.transitionTo(
"users.edit.credits",
this.get("user.id"),
{
queryParams: { year },
}
);
} catch (e) {
/* istanbul ignore next */
this.notify.error("Error while saving the absence credit");
Expand All @@ -66,7 +71,7 @@ export default Controller.extend({

this.get("userController.data").perform(this.get("user.id"));

this.transitionToRoute("users.edit.credits");
this.router.transitionTo("users.edit.credits");
} catch (e) {
/* istanbul ignore next */
this.notify.error("Error while deleting the absence credit");
Expand Down
5 changes: 3 additions & 2 deletions app/users/edit/credits/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default Controller.extend(UsersEditCreditsQueryParams.Mixin, {
fetch: service("fetch"),

can: service("can"),
router: service("router"),

userController: controller("users.edit"),

Expand Down Expand Up @@ -109,7 +110,7 @@ export default Controller.extend(UsersEditCreditsQueryParams.Mixin, {

editAbsenceCredit: task(function* (id) {
if (this.can.can("edit absence-credit")) {
yield this.transitionToRoute(
yield this.router.transitionTo(
"users.edit.credits.absence-credits.edit",
id
);
Expand All @@ -118,7 +119,7 @@ export default Controller.extend(UsersEditCreditsQueryParams.Mixin, {

editOvertimeCredit: task(function* (id) {
if (this.can.can("edit overtime-credit")) {
yield this.transitionToRoute(
yield this.router.transitionTo(
"users.edit.credits.overtime-credits.edit",
id
);
Expand Down
13 changes: 9 additions & 4 deletions app/users/edit/credits/overtime-credits/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default Controller.extend({
userCreditsController: controller("users.edit.credits.index"),

notify: service("notify"),
router: service("router"),

credit: task(function* () {
const id = this.model;
Expand Down Expand Up @@ -41,9 +42,13 @@ export default Controller.extend({
const year =
allYears.find((y) => y === String(changeset.get("date").year())) || "";

yield this.transitionToRoute("users.edit.credits", this.get("user.id"), {
queryParams: { year },
});
yield this.router.transitionTo(
"users.edit.credits",
this.get("user.id"),
{
queryParams: { year },
}
);
} catch (e) {
/* istanbul ignore next */
this.notify.error("Error while saving the overtime credit");
Expand All @@ -58,7 +63,7 @@ export default Controller.extend({

this.get("userController.data").perform(this.get("user.id"));

this.transitionToRoute("users.edit.credits");
this.router.transitionTo("users.edit.credits");
} catch (e) {
/* istanbul ignore next */
this.notify.error("Error while deleting the overtime credit");
Expand Down
15 changes: 4 additions & 11 deletions config/deprecation-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@
window.deprecationWorkflow = window.deprecationWorkflow || {};
window.deprecationWorkflow.config = {
workflow: [
{ handler: "silence", matchId: "ember-global" },
{ handler: "silence", matchId: "ember.component.reopen" },
{ handler: "silence", matchId: "ember-metal.get-with-default" },
{ handler: "silence", matchId: "ember.component.reopen" }, // not finish yet
{ handler: "silence", matchId: "implicit-injections" },
{
handler: "silence",
matchId: "ember-views.curly-components.jquery-element",
},
{
// the issue exists in ember scrollable package
handler: "silence",
matchId: "deprecated-run-loop-and-computed-dot-access",
},
// This error is caused by ember-parachute and will persist
// until we have refactored all controllers and routes to not use ember-parachute
{ handler: "silence", matchId: "ember-utils.try-invoke" },
{ handler: "silence", matchId: "this-property-fallback" },
{ handler: "silence", matchId: "autotracking.mutation-after-consumption" },
{ handler: "silence", matchId: "manager-capabilities.modifiers-3-13" },
{ handler: "silence", matchId: "setting-on-hash" },
{ handler: "silence", matchId: "routing.transition-methods" },
],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@semantic-release/git": "^10.0.1",
"babel-eslint": "10.1.0",
"broccoli-asset-rev": "3.0.0",
"broccoli-funnel": "^3.0.8",
"downloadjs": "1.4.7",
"ember-auto-import": "2.6.0",
"ember-basic-dropdown": "7.0.0",
Expand Down
15 changes: 14 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions tests/acceptance/users-edit-credits-absence-credit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module("Acceptance | users edit credits absence credit", function (hooks) {
await fillIn("input[name=comment]", "Comment");
await click("[data-test-absence-credit-save]");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-absence-credits] tbody > tr").exists({ count: 1 });
});
Expand All @@ -49,7 +52,10 @@ module("Acceptance | users edit credits absence credit", function (hooks) {

await click(".btn-primary");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-absence-credits] tbody > tr").exists({ count: 1 });

Expand Down Expand Up @@ -79,7 +85,10 @@ module("Acceptance | users edit credits absence credit", function (hooks) {

await click(".btn-danger");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-absence-credits] tr").doesNotExist();
});
Expand Down
15 changes: 12 additions & 3 deletions tests/acceptance/users-edit-credits-overtime-credit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ module("Acceptance | users edit credits overtime credit", function (hooks) {

await click("[data-test-overtime-credit-save]");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-overtime-credits] tbody > tr").exists({ count: 1 });
});
Expand All @@ -48,7 +51,10 @@ module("Acceptance | users edit credits overtime credit", function (hooks) {

await click("[data-test-overtime-credit-save]");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-overtime-credits] tbody > tr").exists({ count: 1 });

Expand Down Expand Up @@ -78,7 +84,10 @@ module("Acceptance | users edit credits overtime credit", function (hooks) {

await click("[data-test-overtime-credit-delete]");

assert.strictEqual(currentURL(), `/users/${this.user.id}/credits`);
assert.strictEqual(
currentURL(),
`/users/${this.user.id}/credits?year=${moment().format("YYYY")}`
);

assert.dom("[data-test-overtime-credits] tr").doesNotExist();
});
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/components/async-list/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ module("Integration | Component | async list", function (hooks) {
this.set("data", { last: { value: ["a", "b"] } });

await render(hbs`
{{#async-list data as |section data|}}
<AsyncList @data={{this.data}} as |section data|>
{{#if (eq section 'body')}}
{{#each data as |d|}}
<div class="item">{{d}}</div>
{{/each}}
{{/if}}
{{/async-list}}
</AsyncList>
`);

assert.dom("div.item").exists({ count: 2 });
Expand All @@ -26,11 +26,11 @@ module("Integration | Component | async list", function (hooks) {
this.set("data", { last: { value: [] } });

await render(hbs`
{{#async-list data as |section data|}}
<AsyncList @data={{this.data}} as |section data|>
{{#if (eq section 'empty')}}
<div class="check-me"></div>
{{/if}}
{{/async-list}}
</AsyncList>
`);

assert.dom(".check-me").exists();
Expand All @@ -40,7 +40,7 @@ module("Integration | Component | async list", function (hooks) {
this.set("data", { isRunning: true });

await render(hbs`
{{#async-list data}}{{/async-list}}
<AsyncList @data={{this.data}} />
`);

assert.dom(".loading-icon").exists();
Expand All @@ -50,7 +50,7 @@ module("Integration | Component | async list", function (hooks) {
this.set("data", { last: { isError: true } });

await render(hbs`
{{#async-list data as |section data|}}{{/async-list}}
<AsyncList @data={{this.data}} as |section data|></AsyncList>
`);

assert.dom(".fa-bolt").exists();
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/components/balance-donut/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module("Integration | Component | balance donut", function (hooks) {
usedDays: 5,
});

await render(hbs`{{balance-donut balance}}`);
await render(hbs`<BalanceDonut @balance={{this.balance}} />`);

assert.dom(".donut-content").includesText("5 of 10");
assert.dom(".donut-content").includesText("50%");
Expand All @@ -30,7 +30,7 @@ module("Integration | Component | balance donut", function (hooks) {
usedDays: 3,
});

await render(hbs`{{balance-donut balance}}`);
await render(hbs`<BalanceDonut @balance={{this.balance}} />`);

assert.dom(".donut-content").includesText("3");
assert.dom(".donut-content").doesNotIncludeText("0");
Expand All @@ -47,7 +47,7 @@ module("Integration | Component | balance donut", function (hooks) {
usedDays: 20,
});

await render(hbs`{{balance-donut balance}}`);
await render(hbs`<BalanceDonut @balance={{this.balance}} />`);

assert.dom(".donut-content").includesText("20 of 10");
assert.dom(".donut-content").includesText("200%");
Expand All @@ -63,7 +63,7 @@ module("Integration | Component | balance donut", function (hooks) {
usedDuration: moment.duration({ h: 10 }),
});

await render(hbs`{{balance-donut balance}}`);
await render(hbs`<BalanceDonut @balance={{this.balance}} />`);

assert.dom(".donut-content").includesText("10:00");

Expand Down
6 changes: 5 additions & 1 deletion tests/integration/components/date-buttons/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module("Integration | Component | date buttons", function (hooks) {
this.set("toDate", null);

await render(
hbs`{{date-buttons onUpdateFromDate=(action (mut fromDate)) onUpdateToDate=(action (mut toDate))}}`
hbs`<DateButtons
@onUpdateFromDate={{(action (mut this.fromDate))}}
@onUpdateToDate={{(action (mut this.toDate))}}
/>
`
);

await click('[data-test-preset-date="0"]');
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/components/duration-since/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module("Integration | Component | duration since", function (hooks) {
})
);

await render(hbs`{{duration-since start}}`);
await render(hbs`<DurationSince @from={{this.start}} />`);

assert.ok(this.element);
assert.dom(this.element).hasText("00:05:05");
Expand All @@ -40,7 +40,9 @@ module("Integration | Component | duration since", function (hooks) {
})
);

await render(hbs`{{duration-since start elapsed=elapsed}}`);
await render(
hbs`<DurationSince @from={{this.start}} @elapsed={{this.elapsed}} />`
);

assert.ok(this.element);
assert.dom(this.element).hasText("01:06:06");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ module("Integration | Component | pagination limit", function (hooks) {
test("can change limit", async function (assert) {
this.set("limit", 10);

await render(hbs`{{pagination-limit pages=5 page_size=limit}}`);
await render(
hbs`<PaginationLimit @pages={{5}} @page_size={{this.limit}} />`
);

assert.dom("span").exists({ count: 4 });
assert.dom("a").exists({ count: 3 });
Expand Down
Loading

0 comments on commit 0c3920c

Please sign in to comment.