diff --git a/docs-app/package.json b/docs-app/package.json index 76bc0fbe..7e4ab0ae 100644 --- a/docs-app/package.json +++ b/docs-app/package.json @@ -49,7 +49,7 @@ "@embroider/broccoli-side-watch": "0.0.2-unstable.ba9fd29", "@embroider/compat": "^3.4.8", "@embroider/core": "^3.4.8", - "@embroider/macros": "^1.16.0", + "@embroider/macros": "^1.16.1", "@embroider/router": "^2.1.6", "@embroider/webpack": "^4.0.0", "@glimmer/component": "^1.1.2", diff --git a/docs-app/tests/helpers/index.ts b/docs-app/tests/helpers/index.ts index 761cc7cf..a410f4db 100644 --- a/docs-app/tests/helpers/index.ts +++ b/docs-app/tests/helpers/index.ts @@ -5,8 +5,6 @@ import { type SetupTestOptions, } from 'ember-qunit'; -import { resetViewport } from './reset-viewport'; - // This file exists to provide wrappers around ember-qunit's // test setup functions. This way, you can easily extend the setup that is // needed per test type. @@ -16,7 +14,6 @@ function setupApplicationTest( options?: SetupTestOptions, ): void { upstreamSetupApplicationTest(hooks, options); - resetViewport(hooks); // Additional setup for application tests can be done here. // @@ -52,5 +49,4 @@ function setupTest(hooks: NestedHooks, options?: SetupTestOptions): void { export { setupApplicationTest, setupRenderingTest, setupTest }; export * from './percy'; -export * from './reset-viewport'; export * from './resize-container'; diff --git a/docs-app/tests/helpers/reset-viewport.ts b/docs-app/tests/helpers/reset-viewport.ts deleted file mode 100644 index 1fbe9f99..00000000 --- a/docs-app/tests/helpers/reset-viewport.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - Do not allow ember-qunit to resize the viewport! Resizing the viewport causes - issues with tests and Percy snapshots for this addon. - - https://github.com/emberjs/ember-qunit/blob/master/vendor/ember-qunit/test-container-styles.css -*/ -export function resetViewport(hooks: NestedHooks): void { - hooks.beforeEach(function () { - const testingContainer = document.getElementById( - 'ember-testing-container', - )!; - - testingContainer.classList.add('full-screen'); - }); -} diff --git a/ember-container-query/package.json b/ember-container-query/package.json index 8584dee8..e91aee27 100644 --- a/ember-container-query/package.json +++ b/ember-container-query/package.json @@ -66,6 +66,7 @@ }, "dependencies": { "@embroider/addon-shim": "^1.8.7", + "@embroider/macros": "^1.16.1", "decorator-transforms": "^1.2.1", "ember-element-helper": "^0.8.6", "ember-modifier": "^3.2.7 || ^4.1.0", diff --git a/ember-container-query/src/modifiers/container-query.ts b/ember-container-query/src/modifiers/container-query.ts index 1c8c8aa5..4f20b001 100644 --- a/ember-container-query/src/modifiers/container-query.ts +++ b/ember-container-query/src/modifiers/container-query.ts @@ -3,6 +3,7 @@ import { action } from '@ember/object'; import type Owner from '@ember/owner'; import { debounce as _debounce } from '@ember/runloop'; import { inject as service } from '@ember/service'; +import { isTesting, macroCondition } from '@embroider/macros'; import type { ArgsFor, NamedArgs, PositionalArgs } from 'ember-modifier'; import Modifier from 'ember-modifier'; @@ -120,13 +121,14 @@ export default class ContainerQueryModifier< } private measureDimensions(element: Element): void { - const height = element.clientHeight; - const width = element.clientWidth; + const scale = macroCondition(isTesting()) ? 2 : 1; + + const { height, width } = element.getBoundingClientRect(); this.dimensions = { aspectRatio: width / height, - height, - width, + height: scale * height, + width: scale * width, }; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50f97704..6140cf96 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -242,8 +242,8 @@ importers: specifier: ^3.4.8 version: 3.4.8(@glint/template@1.4.0) '@embroider/macros': - specifier: ^1.16.0 - version: 1.16.0(@glint/template@1.4.0) + specifier: ^1.16.1 + version: 1.16.1(@glint/template@1.4.0) '@embroider/router': specifier: ^2.1.6 version: 2.1.6(@embroider/core@3.4.8) @@ -433,6 +433,9 @@ importers: '@embroider/addon-shim': specifier: ^1.8.7 version: 1.8.7 + '@embroider/macros': + specifier: ^1.16.1 + version: 1.16.1(@glint/template@1.4.0) decorator-transforms: specifier: ^1.2.1 version: 1.2.1(@babel/core@7.24.4) @@ -2001,7 +2004,7 @@ packages: ember-source: ^4.0.0 || ^5.0.0 dependencies: '@ember/test-waiters': 3.1.0 - '@embroider/macros': 1.16.0(@glint/template@1.4.0) + '@embroider/macros': 1.16.1(@glint/template@1.4.0) '@simple-dom/interface': 1.4.0 broccoli-debug: 0.6.5 broccoli-funnel: 3.0.8 @@ -2210,6 +2213,28 @@ packages: semver: 7.6.0 transitivePeerDependencies: - supports-color + dev: true + + /@embroider/macros@1.16.1(@glint/template@1.4.0): + resolution: {integrity: sha512-yBavtQBbiCjIW4tTNdoS+5/eu3mckZImrcVFkloRvZ5ZWvs2zqnLJVtfNsPMxhWu6dknFlmLqfuT30+kqnsQbg==} + engines: {node: 12.* || 14.* || >= 16} + peerDependencies: + '@glint/template': ^1.0.0 + peerDependenciesMeta: + '@glint/template': + optional: true + dependencies: + '@embroider/shared-internals': 2.6.0(supports-color@8.1.1) + '@glint/template': 1.4.0 + assert-never: 1.2.1 + babel-import-util: 2.0.3 + ember-cli-babel: 7.26.11 + find-up: 5.0.0 + lodash: 4.17.21 + resolve: 1.22.8 + semver: 7.6.0 + transitivePeerDependencies: + - supports-color /@embroider/router@2.1.6(@embroider/core@3.4.8): resolution: {integrity: sha512-geEJF0iKpGQ4YcP2oc30BGPgxer7Umeeg/C07m6xe2OYltQxIzSNWm//A7F/ZrwhVwSSai1W7YyFw8r5wS3OsA==} @@ -2276,7 +2301,7 @@ packages: optional: true dependencies: '@babel/core': 7.24.4(supports-color@8.1.1) - '@embroider/macros': 1.16.0(@glint/template@1.4.0) + '@embroider/macros': 1.16.1(@glint/template@1.4.0) '@glint/environment-ember-loose': 1.4.0(@glimmer/component@1.1.2)(@glint/template@1.4.0)(@types/ember__component@4.0.22)(@types/ember__object@4.0.12)(ember-modifier@4.1.0) '@glint/template': 1.4.0 broccoli-funnel: 3.0.8 @@ -6643,7 +6668,7 @@ packages: '@babel/plugin-proposal-private-methods': 7.18.6(@babel/core@7.24.4) '@babel/plugin-transform-class-static-block': 7.24.4(@babel/core@7.24.4) '@babel/preset-env': 7.24.4(@babel/core@7.24.4)(supports-color@8.1.1) - '@embroider/macros': 1.16.0(@glint/template@1.4.0) + '@embroider/macros': 1.16.1(@glint/template@1.4.0) '@embroider/shared-internals': 2.6.0(supports-color@8.1.1) babel-loader: 8.3.0(@babel/core@7.24.4)(webpack@5.91.0) babel-plugin-ember-modules-api-polyfill: 3.5.0 @@ -7287,7 +7312,7 @@ packages: dependencies: '@ember/test-helpers': 3.3.0(@glint/template@1.4.0)(ember-source@5.8.0)(webpack@5.91.0) '@embroider/addon-shim': 1.8.7 - '@embroider/macros': 1.16.0(@glint/template@1.4.0) + '@embroider/macros': 1.16.1(@glint/template@1.4.0) ember-cli-test-loader: 3.1.0 ember-source: 5.8.0(@babel/core@7.24.4)(@glimmer/component@1.1.2)(@glint/template@1.4.0)(rsvp@4.8.5)(webpack@5.91.0) qunit: 2.20.1 @@ -7408,7 +7433,7 @@ packages: resolution: {integrity: sha512-d/8rdE2nDUt6xVMpTqbohE4kHAaoY+P/7jWCWow3UQGtaGhvURXfKgo8TG/UVK+TfTgJInN6JcU76XLg+MWEtw==} engines: {node: 12.* || 14.* || >= 16} dependencies: - '@embroider/macros': 1.16.0(@glint/template@1.4.0) + '@embroider/macros': 1.16.1(@glint/template@1.4.0) broccoli-caching-writer: 3.0.3 broccoli-concat: 4.2.5 broccoli-funnel: 3.0.8