Skip to content

Commit

Permalink
fix: fix issue & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romgere committed May 31, 2024
1 parent d4c965e commit 944b1bb
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/routes/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default class AppRoute extends Route {
}

async model({ locale }: { locale: string }) {
this.intl.locale = locale === 'en-us' ? locale : [locale, 'en-us'];
if (this.intl.locale[0] !== locale) {
this.intl.locale = locale === 'en-us' ? locale : [locale, 'en-us'];
}
// No await here, let's the loading happen & await for it in generator route
this.harfbuzz.loadWASM();
this.fontManager.loadFont();
Expand Down
4 changes: 3 additions & 1 deletion app/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import RouterService from '@ember/routing/router-service';
import IntlService from 'ember-intl/services/intl';

export default class IndexRoute extends Route {
@service declare intl: IntlService;
@service declare router: RouterService;

async model() {
this.transitionTo('app.index', this.intl.locale[0]);
this.router.transitionTo('app.index', this.intl.locale[0]);
}
}
2 changes: 2 additions & 0 deletions tests/integration/components/lang-switcher-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ const {
APP: { availableLanguages },
} = config;
import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready';
import { setupIntl } from 'ember-intl/test-support';

import type IntlService from 'ember-intl/services/intl';

module('Integration | Component | lang-switcher', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

hooks.afterEach(function () {
(this.owner.lookup('service:intl') as IntlService).locale = 'en-us';
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/settings-form-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setComponentTemplate } from '@ember/component';
import { ModelType } from 'text2stl/services/text-maker';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | settings-form', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
class SettingsFormFont extends Component {}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/settings-form/font-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import { setComponentTemplate } from '@ember/component';
import { tracked } from '@glimmer/tracking';
import templateOnly from '@ember/component/template-only';
import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | settings-form/font', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
// mock the FontPicker
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/settings-form/handle-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import TextMakerSettings from 'text2stl/models/text-maker-settings';
import { ModelType } from 'text2stl/services/text-maker';
import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input';
import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | advanced-settings-form/handle', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
const model = new TextMakerSettings({
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/settings-form/support-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const {
import TextMakerSettings from 'text2stl/models/text-maker-settings';
import { ModelType } from 'text2stl/services/text-maker';
import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | advanced-settings-form/support', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
const model = new TextMakerSettings({
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/components/settings-form/text-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const {
} = config;
import TextMakerSettings from 'text2stl/models/text-maker-settings';
import { ModelType } from 'text2stl/services/text-maker';

import fillCalciteInput from 'text2stl/tests/helpers/fill-calcite-input';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | settings-form/text', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
const model = new TextMakerSettings({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const {
import TextMakerSettings from 'text2stl/models/text-maker-settings';
import { ModelType } from 'text2stl/services/text-maker';
import wait from 'text2stl/tests/helpers/wait';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | settings-form/select-type', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
const model = new TextMakerSettings({
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/three-preview-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setComponentTemplate } from '@ember/component';
import Component from '@glimmer/component';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | three-preview', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders', async function (assert) {
class ThreePreviewRenderer extends Component {}
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/components/three-preview/size-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { Mesh, BoxGeometry } from 'three';
import { setupIntl } from 'ember-intl/test-support';

module('Integration | Component | tree-preview/size', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);

test('it renders nothing when no mesh is specified', async function (assert) {
await render(hbs`<ThreePreview::Size data-test />`);
Expand Down

0 comments on commit 944b1bb

Please sign in to comment.