diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e8c86fc46d..db44af8cc8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,9 +92,9 @@ jobs: - ember-lts-5.4 - ember-lts-5.8 - ember-lts-5.12 - # - ember-release - # - ember-beta - # - ember-canary + - ember-release + - ember-beta + - ember-canary - ember-default-no-prototype-extensions steps: diff --git a/ember_debug/utils/ember.js b/ember_debug/utils/ember.js index 710daee88d..0d05c889ad 100644 --- a/ember_debug/utils/ember.js +++ b/ember_debug/utils/ember.js @@ -3,7 +3,13 @@ import { emberSafeRequire } from 'ember-debug/utils/ember/loader'; let Ember; try { - Ember = requireModule('ember').default; + Ember = requireModule('ember/barrel').default; +} catch { + // pass through +} + +try { + Ember = Ember || requireModule('ember').default; } catch { Ember = window.Ember; } diff --git a/ember_debug/vendor/startup-wrapper.js b/ember_debug/vendor/startup-wrapper.js index 75c6ebbc7f..9cf134115d 100644 --- a/ember_debug/vendor/startup-wrapper.js +++ b/ember_debug/vendor/startup-wrapper.js @@ -112,7 +112,10 @@ var EMBER_VERSIONS_SUPPORTED = {{EMBER_VERSIONS_SUPPORTED}}; if (!Ember) { try { - Ember = requireModule('ember')['default']; + Ember = requireModule('ember/barrel')['default']; + } catch {} + try { + Ember = Ember || requireModule('ember')['default']; } catch { Ember = window.Ember; } diff --git a/tests/ember_debug/profile-manager-test.js b/tests/ember_debug/profile-manager-test.js index 8b53c27ea4..b2fa239430 100644 --- a/tests/ember_debug/profile-manager-test.js +++ b/tests/ember_debug/profile-manager-test.js @@ -12,6 +12,7 @@ import setupEmberDebugTest from '../helpers/setup-ember-debug-test'; import { run } from '@ember/runloop'; import Ember from 'ember-debug/utils/ember'; import { compareVersion } from 'ember-debug/utils/version'; +import { setComponentTemplate } from '@ember/component'; const { VERSION } = Ember; @@ -28,119 +29,123 @@ const getRounded = (value) => { } return Math.floor(data); }; -class OneRootGlimmer extends GlimmerComponent { - classNames = 'simple-component'; -} -const mockedComponents = { - text: { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs('text only', { - moduleName: 'my-app/templates/components/text.hbs', - }), - }, - 'text-glimmer': { - component: GlimmerComponent, - template: hbs('text only', { - moduleName: 'my-app/templates/components/text-glimmer.hbs', - }), - }, - comment: { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs('', { - moduleName: 'my-app/templates/components/comment.hbs', - }), - }, - 'comment-glimmer': { - component: GlimmerComponent, - template: hbs('', { - moduleName: 'my-app/templates/components/comment-glimmer.hbs', - }), - }, - 'one-root': { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs('
one root
', { - moduleName: 'my-app/templates/components/one-root.hbs', - }), - }, - 'one-root-glimmer': { - component: OneRootGlimmer, - template: hbs('
one root
', { - moduleName: 'my-app/templates/components/one-root-glimmer.hbs', - }), - }, - 'two-root': { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs( - '
one
two
', - { moduleName: 'my-app/templates/components/two-root.hbs' }, - ), - }, - 'two-root-glimmer': { - component: GlimmerComponent, - template: hbs( - '
one
two
', - { moduleName: 'my-app/templates/components/two-root-glimmer.hbs' }, - ), - }, - 'root-comment-root': { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs( - '
one
two
', - { moduleName: 'my-app/templates/components/root-comment-root.hbs' }, - ), - }, - 'root-comment-root-glimmer': { - component: GlimmerComponent, - template: hbs( - '
one
two
', - { - moduleName: 'my-app/templates/components/root-comment-root-glimmer.hbs', - }, - ), - }, - 'comment-root-comment': { - component: EmberComponent.extend({ - tagName: '', - }), - template: hbs( - '
one
', - { moduleName: 'my-app/templates/components/comment-root-comment.hbs' }, - ), - }, - 'comment-root-comment-glimmer': { - component: GlimmerComponent, - template: hbs( - '
one
', - { moduleName: 'my-app/templates/components/comment-root-comment.hbs' }, - ), - }, - 'div-tag': { - component: EmberComponent.extend({ - classNames: ['simple-component'], - }), - template: hbs('text in div', { - moduleName: 'my-app/templates/components/div-tag.hbs', - }), - }, - 'div-roots': { - component: EmberComponent.extend({ - classNames: ['simple-component'], - }), - template: hbs('
one
two
', { - moduleName: 'my-app/templates/components/div-roots.hbs', - }), - }, +const mockedComponents = () => { + class OneRootGlimmer extends GlimmerComponent { + classNames = 'simple-component'; + } + + return { + text: { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs('text only', { + moduleName: 'my-app/templates/components/text.hbs', + }), + }, + 'text-glimmer': { + component: class extends GlimmerComponent {}, + template: hbs('text only', { + moduleName: 'my-app/templates/components/text-glimmer.hbs', + }), + }, + comment: { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs('', { + moduleName: 'my-app/templates/components/comment.hbs', + }), + }, + 'comment-glimmer': { + component: class extends GlimmerComponent {}, + template: hbs('', { + moduleName: 'my-app/templates/components/comment-glimmer.hbs', + }), + }, + 'one-root': { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs('
one root
', { + moduleName: 'my-app/templates/components/one-root.hbs', + }), + }, + 'one-root-glimmer': { + component: OneRootGlimmer, + template: hbs('
one root
', { + moduleName: 'my-app/templates/components/one-root-glimmer.hbs', + }), + }, + 'two-root': { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs( + '
one
two
', + { moduleName: 'my-app/templates/components/two-root.hbs' }, + ), + }, + 'two-root-glimmer': { + component: class extends GlimmerComponent {}, + template: hbs( + '
one
two
', + { moduleName: 'my-app/templates/components/two-root-glimmer.hbs' }, + ), + }, + 'root-comment-root': { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs( + '
one
two
', + { moduleName: 'my-app/templates/components/root-comment-root.hbs' }, + ), + }, + 'root-comment-root-glimmer': { + component: class extends GlimmerComponent {}, + template: hbs( + '
one
two
', + { + moduleName: + 'my-app/templates/components/root-comment-root-glimmer.hbs', + }, + ), + }, + 'comment-root-comment': { + component: EmberComponent.extend({ + tagName: '', + }), + template: hbs( + '
one
', + { moduleName: 'my-app/templates/components/comment-root-comment.hbs' }, + ), + }, + 'comment-root-comment-glimmer': { + component: class extends GlimmerComponent {}, + template: hbs( + '
one
', + { moduleName: 'my-app/templates/components/comment-root-comment.hbs' }, + ), + }, + 'div-tag': { + component: EmberComponent.extend({ + classNames: ['simple-component'], + }), + template: hbs('text in div', { + moduleName: 'my-app/templates/components/div-tag.hbs', + }), + }, + 'div-roots': { + component: EmberComponent.extend({ + classNames: ['simple-component'], + }), + template: hbs('
one
two
', { + moduleName: 'my-app/templates/components/div-roots.hbs', + }), + }, + }; }; const mockedRoutes = { @@ -264,6 +269,10 @@ const constructComponents = (owner, componentsMap) => { `template:components/${componentKey}`, componentsMap[componentKey].template, ); + setComponentTemplate( + componentsMap[componentKey].template, + componentsMap[componentKey].component, + ); } } }; @@ -398,7 +407,7 @@ module('Ember Debug - profile manager component highlight', function (hooks) { hooks.beforeEach(async function () { EmberDebug.IGNORE_DEPRECATIONS = true; constructBase(this.owner); - constructComponents(this.owner, mockedComponents); + constructComponents(this.owner, mockedComponents()); }); hooks.afterEach(function (assert) { diff --git a/tests/ember_debug/view-debug-test.js b/tests/ember_debug/view-debug-test.js index 629a56ba1b..2a5e6f1d8b 100644 --- a/tests/ember_debug/view-debug-test.js +++ b/tests/ember_debug/view-debug-test.js @@ -10,7 +10,7 @@ import hasEmberVersion from '@ember/test-helpers/has-ember-version'; import { A } from '@ember/array'; import { run } from '@ember/runloop'; // eslint-disable-next-line ember/no-classic-components -import EmberComponent from '@ember/component'; +import EmberComponent, { setComponentTemplate } from '@ember/component'; import EmberRoute from '@ember/routing/route'; import EmberObject from '@ember/object'; import Controller from '@ember/controller'; @@ -313,10 +313,20 @@ function HtmlElement( ); } +function RouteArgs() { + if (hasEmberVersion(6, 4)) { + return Args({ names: ['controller', 'model'] }); + } + if (hasEmberVersion(3, 14)) { + return Args({ names: ['model'] }); + } + return Args(); +} + function Route( { name, - args = hasEmberVersion(3, 14) ? Args({ names: ['model'] }) : Args(), + args = RouteArgs(), instance = Serialized(), template = `my-app/templates/${name}.hbs`, ...options @@ -369,6 +379,17 @@ module('Ember Debug - View', function (hooks) { hooks.beforeEach(async function () { EmberDebug.IGNORE_DEPRECATIONS = true; + const registry = {}; + + function register(fullName, value) { + const name = fullName.split('/').slice(-1)[0]; + registry[name] = registry[name] || {}; + if (fullName.startsWith('component:')) { + registry[name].component = value; + } else { + registry[name].template = value; + } + } this.owner.register( 'route:application', @@ -488,7 +509,7 @@ module('Ember Debug - View', function (hooks) { }), ); - this.owner.register( + register( 'component:test-foo', EmberComponent.extend({ classNames: ['simple-component'], @@ -498,7 +519,7 @@ module('Ember Debug - View', function (hooks) { }), ); - this.owner.register( + register( 'component:test-bar', templateOnlyComponent?.() || EmberComponent.extend({ @@ -509,7 +530,7 @@ module('Ember Debug - View', function (hooks) { }), ); - this.owner.register( + register( 'component:test-in-element-in-component', EmberComponent.extend({ init(...args) { @@ -522,7 +543,7 @@ module('Ember Debug - View', function (hooks) { }), ); - this.owner.register( + register( 'component:test-component-in-in-element', EmberComponent.extend({ toString() { @@ -601,13 +622,13 @@ module('Ember Debug - View', function (hooks) { 'template:posts', hbs('Posts', { moduleName: 'my-app/templates/posts.hbs' }), ); - this.owner.register( + register( 'template:components/test-foo', hbs('test-foo', { moduleName: 'my-app/templates/components/test-foo.hbs', }), ); - this.owner.register( + register( 'template:components/test-bar', hbs( ` @@ -621,7 +642,7 @@ module('Ember Debug - View', function (hooks) { ), ); - this.owner.register( + register( 'template:components/test-component-in-in-element', hbs(`

@@ -630,7 +651,7 @@ module('Ember Debug - View', function (hooks) { `), ); - this.owner.register( + register( 'template:components/test-in-element-in-component', hbs(` {{#in-element this.elementTarget}} @@ -642,6 +663,10 @@ module('Ember Debug - View', function (hooks) { ); this.owner.register('modifier:did-insert', didInsert); + + for (const { component, template } of Object.values(registry)) { + setComponentTemplate?.(template, component); + } }); test('Simple Inputs Tree', async function () { @@ -892,25 +917,29 @@ module('Ember Debug - View', function (hooks) { }); test('Does not list nested {{yield}} views', async function () { - this.owner.register('component:x-first', EmberComponent.extend()); - this.owner.register('component:x-second', EmberComponent.extend()); - this.owner.register( - 'template:posts', - hbs('{{#x-first}}Foo{{/x-first}}', { - moduleName: 'my-app/templates/posts.hbs', - }), + 'component:x-first', + setComponentTemplate( + hbs('{{#x-second}}{{yield}}{{/x-second}}', { + moduleName: 'my-app/templates/components/x-first.hbs', + }), + EmberComponent.extend(), + ), ); this.owner.register( - 'template:components/x-first', - hbs('{{#x-second}}{{yield}}{{/x-second}}', { - moduleName: 'my-app/templates/components/x-first.hbs', - }), + 'component:x-second', + setComponentTemplate( + hbs('{{yield}}', { + moduleName: 'my-app/templates/components/x-second.hbs', + }), + EmberComponent.extend(), + ), ); + this.owner.register( - 'template:components/x-second', - hbs('{{yield}}', { - moduleName: 'my-app/templates/components/x-second.hbs', + 'template:posts', + hbs('{{#x-first}}Foo{{/x-first}}', { + moduleName: 'my-app/templates/posts.hbs', }), ); diff --git a/tests/integration/injection-test.js b/tests/integration/injection-test.js index 6045600060..02561f9572 100644 --- a/tests/integration/injection-test.js +++ b/tests/integration/injection-test.js @@ -334,9 +334,10 @@ module('Integration | Injection', function (hooks) { test('triggering Ember Component Context Menu Item should call inspect nearest', async function (assert) { await inject(this.owner, assert); - assert.timeout(10); + assert.timeout(100); - const viewInspection = window.EmberInspector.viewDebug.viewInspection; + const emberDebug = requireModule('ember-debug/main')['default']; + const viewInspection = emberDebug.viewDebug.viewInspection; const inspectNearestCalled = new Promise((resolve) => { viewInspection.inspectNearest = () => {