Skip to content

Commit

Permalink
fix(ember): fix bugs from ember-intl v7 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz committed Nov 15, 2024
1 parent e8f854f commit 0f7d83a
Show file tree
Hide file tree
Showing 30 changed files with 61 additions and 88 deletions.
2 changes: 1 addition & 1 deletion ember/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM danlynn/ember-cli:4.12.1-node_18.16 as build
FROM danlynn/ember-cli:5.8.1-node_20.12 as build

ARG OIDC_HOST

Expand Down
2 changes: 1 addition & 1 deletion ember/app/models/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class AddressModel extends LocalizedModel {
}

get countryName() {
const countries = new Intl.DisplayNames(this.intl.locale, {
const countries = new Intl.DisplayNames(this.intl.primaryLocale, {
type: "region",
});
return countries.of(this.country);
Expand Down
9 changes: 5 additions & 4 deletions ember/app/ui/components/case-transfer/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
</div>
<div class="uk-margin">
<label class="uk-form-label">
<Input
@type="checkbox"
@checked={{this.removeAccess}}
disabled={{not @toRemove}}
<input
type="checkbox"
checked={{this.removeAccess}}
disabled={{not @toRemove.length}}
class="uk-checkbox"
{{on "click" (fn (mut this.removeAccess) (not this.removeAccess))}}
/>
{{t "documents.bulkEdit.transfer.removeAssignees"}}
</label>
Expand Down
2 changes: 1 addition & 1 deletion ember/app/ui/components/date-picker/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class CfFieldInputDateComponent extends Component {
@tracked flatpickrRef = null;

get locale() {
return this.intl.primaryLocale.split("-")[0];
return this.intl.primaryLocale;
}

@action
Expand Down
4 changes: 2 additions & 2 deletions ember/app/ui/components/identity-addresses/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@
</div>
{{else}}
<Form.input
@label={{t "components.identity-addresses.form.label.description" lang=(uppercase (get this.intl.locale "0"))}}
@name="_description.{{get this.intl.locale "0"}}"
@label={{t "components.identity-addresses.form.label.description" lang=(uppercase this.intl.primaryLocale)}}
@name="_description.{{this.intl.primaryLocale}}"
@required={{false}}
/>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions ember/app/ui/components/identity-emails/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
</div>
{{else}}
<Form.input
@label={{t "components.identity-emails.form.label.description" lang=(uppercase (get this.intl.locale "0"))}}
@name="_description.{{get this.intl.locale "0"}}"
@label={{t "components.identity-emails.form.label.description" lang=(uppercase this.intl.primaryLocale)}}
@name="_description.{{this.intl.primaryLocale}}"
@required={{false}}
/>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion ember/app/ui/components/identity-members/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class IdentityMembersComponent extends Component {
}

get locale() {
return this.intl.locale[0];
return this.intl.primaryLocale;
}

membersResource = trackedFunction(this, async () => {
Expand Down
4 changes: 2 additions & 2 deletions ember/app/ui/components/identity-phone-numbers/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
</div>
{{else}}
<Form.input
@label={{t "components.identity-phone-numbers.form.label.description" lang=(uppercase (get this.intl.locale "0"))}}
@name="_description.{{get this.intl.locale "0"}}"
@label={{t "components.identity-phone-numbers.form.label.description" lang=(uppercase this.intl.primaryLocale)}}
@name="_description.{{this.intl.primaryLocale}}"
@required={{false}}
/>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions ember/app/ui/components/nav-bar/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
{{/if}}
<li class="language-select">
<a class="uk-link-reset" href="#">
{{this.intl.locale}}
{{this.intl.primaryLocale}}
<UkIcon @icon="chevron-down" />
</a>
<ul
Expand Down Expand Up @@ -271,7 +271,7 @@
href="#"
data-test-locale
>
{{this.intl.locale}}
{{this.intl.primaryLocale}}
<UkIcon @icon="chevron-down" />
</a>
<ul
Expand Down
2 changes: 1 addition & 1 deletion ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"ember-engines": "^0.11.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.1.2",
"ember-flatpickr": "^8.0.0",
"ember-flatpickr": "^8.0.1",
"ember-in-viewport": "^4.1.0",
"ember-intl": "^7.0.7",
"ember-load-initializers": "^2.1.2",
Expand Down
7 changes: 2 additions & 5 deletions ember/tests/acceptance/identities-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { visit, click, currentURL } from "@ember/test-helpers";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { setupApplicationTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupApplicationTest } from "mysagw/tests/helpers";

module("Acceptance | identities", function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(async function () {
this.identity = this.server.create("identity", {
Expand Down
7 changes: 2 additions & 5 deletions ember/tests/acceptance/interest-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { visit, fillIn, click, waitFor, currentURL } from "@ember/test-helpers";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { setupApplicationTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupApplicationTest } from "mysagw/tests/helpers";

module("Acceptance | interest", function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(async function () {
this.category = this.server.create("interest-category");
Expand Down
7 changes: 2 additions & 5 deletions ember/tests/acceptance/snippets-test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { visit, fillIn, click } from "@ember/test-helpers";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { setupApplicationTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupApplicationTest } from "mysagw/tests/helpers";

module("Acceptance | snippets", function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(async function () {
this.server.create("snippet", { body: { de: "Lorem ipsum" } });
Expand Down
12 changes: 6 additions & 6 deletions ember/tests/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import {
setupApplicationTest as upstreamSetupApplicationTest,
setupRenderingTest as upstreamSetupRenderingTest,
Expand All @@ -23,20 +25,18 @@ function setupApplicationTest(hooks, options) {
// This is also a good place to call test setup functions coming
// from other addons:
//
// setupIntl(hooks); // ember-intl
// setupMirage(hooks); // ember-cli-mirage
setupIntl(hooks, "de");
setupMirage(hooks);
}

function setupRenderingTest(hooks, options) {
upstreamSetupRenderingTest(hooks, options);

// Additional setup for rendering tests can be done here.
setupIntl(hooks, "de");
}

function setupTest(hooks, options) {
upstreamSetupTest(hooks, options);

// Additional setup for unit tests can be done here.
setupIntl(hooks, "de");
}

export { setupApplicationTest, setupRenderingTest, setupTest };
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { module, test } from "qunit";

import calumaScenario from "mysagw/mirage/scenarios/caluma";
Expand All @@ -10,7 +9,6 @@ import { setupRenderingTest } from "mysagw/tests/helpers";
module("Integration | Component | case-filters", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

test("it renders", async function (assert) {
const filters = {
Expand All @@ -35,8 +33,6 @@ module("Integration | Component | case-filters", function (hooks) {
`);

await click("[data-test-filter-modal-open]");
assert
.dom(".uk-modal-title")
.hasText("t:components.filters.modal.title:()");
assert.dom(".uk-modal-title").hasText("Filters");
});
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupIntl } from "ember-intl/test-support";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | dynamic-table/header", function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders without ordering", async function (assert) {
this.config = { classList: ["a", "b"], label: "test" };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupIntl } from "ember-intl/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | filter-modal", function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders", async function (assert) {
await render(hbs`
Expand All @@ -16,7 +14,7 @@ module("Integration | Component | filter-modal", function (hooks) {
</FilterModal>
`);

assert.dom(this.element).includesText("t:global.continue");
assert.dom(this.element).includesText("Weiter");
assert.dom("button").includesText("3");
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { render, click, fillIn } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupRenderingTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | identity-addresses", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { render, click, fillIn } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupRenderingTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | identity-emails", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { render, fillIn, click } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { setupRenderingTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | identity-form", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(async function () {
await authenticateSession({ userinfo: { mysagw_groups: ["sagw"] } });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { render, click, waitFor } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
import { selectChoose } from "ember-power-select/test-support";
import { setupRenderingTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | identity-memberships", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
setupIntl(hooks);

hooks.beforeEach(async function () {
await authenticateSession({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { render, click, fillIn } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupRenderingTest } from "ember-qunit";
import { authenticateSession } from "ember-simple-auth/test-support";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | identity-phone-numbers", function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | interest-category-form", function (hooks) {
setupRenderingTest(hooks);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | membership-role-form", function (hooks) {
setupRenderingTest(hooks);

Expand Down
11 changes: 7 additions & 4 deletions ember/tests/integration/ui/components/nav-bar/component-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { click, render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupIntl } from "ember-intl/test-support";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | nav-bar", function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test("it renders", async function (assert) {
await render(hbs`<NavBar @text="foo"/>`);
Expand All @@ -15,10 +14,14 @@ module("Integration | Component | nav-bar", function (hooks) {
});

test("it switches the locale", async function (assert) {
const intl = this.owner.lookup("service:intl");

await render(hbs`<NavBar />`);

assert.dom("[data-test-locale]").hasText("en-us");
assert.dom("[data-test-locale]").hasText("de");
assert.strictEqual(intl.primaryLocale, "de");
await click("[data-test-locale-select='fr']");
assert.strictEqual(intl.primaryLocale, "fr");
assert.dom("[data-test-locale]").hasText("fr");
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import { setupRenderingTest } from "ember-qunit";
import { module, test } from "qunit";

import { setupRenderingTest } from "mysagw/tests/helpers";

module("Integration | Component | snippet-form", function (hooks) {
setupRenderingTest(hooks);

Expand Down
Loading

0 comments on commit 0f7d83a

Please sign in to comment.