From bb84789d39bc504e2c0138971eb3c101735ab4fc Mon Sep 17 00:00:00 2001 From: Tommy Carter Date: Tue, 1 Apr 2025 13:30:37 -0500 Subject: [PATCH 1/4] Removed tests targeting DEPRECATE_COMPONENT_TEMPLATE_RESOLVING --- .../integration/components/append-test.js | 24 +--- .../components/component-template-test.js | 20 +-- .../tests/unit/runtime-resolver-cache-test.js | 121 +----------------- .../tests/component_registration_test.js | 84 +----------- 4 files changed, 7 insertions(+), 242 deletions(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js index af4efa92813..97cdf98ad3c 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js @@ -286,16 +286,9 @@ class AbstractAppendTest extends RenderingTestCase { ); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} lifecycle hooks during component append`](assert) { + [`@test lifecycle hooks during component append`](assert) { let hooks = []; - expectDeprecation( - /resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); - let oldRegisterComponent = this.registerComponent; let componentsByName = {}; @@ -539,16 +532,9 @@ class AbstractAppendTest extends RenderingTestCase { ); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} appending, updating and destroying a single component`](assert) { + [`@test appending, updating and destroying a single component`](assert) { let willDestroyCalled = 0; - expectDeprecation( - /separately resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); - this.registerComponent('x-parent', { ComponentClass: Component.extend({ layoutName: 'components/x-parent', @@ -566,7 +552,7 @@ class AbstractAppendTest extends RenderingTestCase { tagName: '', }), - resolveableTemplate: '[child: {{this.bar}}]{{yield}}', + template: '[child: {{this.bar}}]{{yield}}', }); let XParent; @@ -652,9 +638,7 @@ class AbstractAppendTest extends RenderingTestCase { assert.equal(renderer._roots.length, 0, 'released the root component'); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} appending, updating and destroying multiple components`](assert) { + [`@test appending, updating and destroying multiple components`](assert) { let willDestroyCalled = 0; this.registerComponent('x-first', { diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js index 34ebccc2604..71f3af04db1 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js @@ -1,9 +1,8 @@ import { DEBUG } from '@glimmer/env'; -import { moduleFor, RenderingTestCase, runTask, testUnless } from 'internal-test-helpers'; +import { moduleFor, RenderingTestCase, runTask } from 'internal-test-helpers'; import { setComponentTemplate, getComponentTemplate } from '@glimmer/manager'; import { Component, compile } from '../../utils/helpers'; -import { DEPRECATIONS } from '../../../../deprecations'; moduleFor( 'Components test: setComponentTemplate', @@ -22,23 +21,6 @@ moduleFor( this.assertComponentElement(this.firstChild, { content: 'hello' }); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} it takes precedence over resolver`]() { - this.registerComponent('foo-bar', { - ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), - resolveableTemplate: 'noooooo!', - }); - - this.render(''); - - this.assertComponentElement(this.firstChild, { content: 'hello' }); - - runTask(() => this.rerender()); - - this.assertComponentElement(this.firstChild, { content: 'hello' }); - } - '@test calling it with primitives asserts'(assert) { if (!DEBUG) { assert.expect(0); diff --git a/packages/@ember/-internals/glimmer/tests/unit/runtime-resolver-cache-test.js b/packages/@ember/-internals/glimmer/tests/unit/runtime-resolver-cache-test.js index e7aeb6eabe0..a6264fb603b 100644 --- a/packages/@ember/-internals/glimmer/tests/unit/runtime-resolver-cache-test.js +++ b/packages/@ember/-internals/glimmer/tests/unit/runtime-resolver-cache-test.js @@ -1,18 +1,9 @@ import { ENV } from '@ember/-internals/environment'; -import { - RenderingTestCase, - moduleFor, - runDestroy, - runAppend, - runTask, - testUnless, - expectDeprecation, -} from 'internal-test-helpers'; +import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers'; import { set } from '@ember/object'; import { templateCacheCounters } from '@ember/-internals/glimmer'; import { Component } from '../utils/helpers'; -import { DEPRECATIONS } from '../../../deprecations'; moduleFor( 'ember-glimmer runtime resolver cache', @@ -125,116 +116,6 @@ moduleFor( this.expectCacheChanges({}, 'toggle back to component-two no change'); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} each template is only compiled once`]() { - expectDeprecation( - /resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); - // static layout - this.registerComponent('component-one', { resolveableTemplate: 'One' }); - - // test directly import template factory onto late bound layout - let Two = Component.extend({ - layout: this.compile('Two'), - }); - this.registerComponent('component-two', { ComponentClass: Two }); - - // inject layout onto component, share layout with component-one - let Root = Component.extend({ - layout: this.owner.lookup('template:components/component-one'), - }); - - this.registerComponent('root-component', { ComponentClass: Root }); - - // template instance shared between to template managers - let rootFactory = this.owner.factoryFor('component:root-component'); - - // snapshot counters - this.getCacheCounters(); - - // show component-one for the first time - this.render( - ` - {{~#if this.cond~}} - {{component-one}} - {{~else~}} - {{component-two}} - {{~/if}}`, - { - cond: true, - } - ); - - this.assertText('One'); - this.expectCacheChanges( - { - componentDefinitionCount: 1, - templateCacheMisses: 2, - templateCacheHits: ENV._DEBUG_RENDER_TREE ? 1 : 0, - }, - 'test case component and component-one no change' - ); - - // show component-two for the first time - runTask(() => set(this.context, 'cond', false)); - - this.assertText('Two'); - this.expectCacheChanges( - { - templateCacheMisses: 1, - componentDefinitionCount: 1, - templateCacheHits: ENV._DEBUG_RENDER_TREE ? 1 : 0, - }, - 'component-two first render misses template cache' - ); - - // show component-one again - runTask(() => set(this.context, 'cond', true)); - - this.assertText('One'); - this.expectCacheChanges({}, 'toggle back to component-one no change'); - - // show component-two again - runTask(() => set(this.context, 'cond', false)); - - this.assertText('Two'); - this.expectCacheChanges( - { - templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1, - }, - 'toggle back to component-two hits template cache' - ); - - // render new root append - let root = rootFactory.create(); - try { - runAppend(root); - this.assertText('TwoOne'); - // roots have different capabilities so this will hit - this.expectCacheChanges( - { templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1 }, - 'append root with component-one no change' - ); - - // render new root append - let root2 = rootFactory.create(); - try { - runAppend(root2); - this.assertText('TwoOneOne'); - this.expectCacheChanges( - { templateCacheHits: ENV._DEBUG_RENDER_TREE ? 2 : 1 }, - 'append another root no change' - ); - } finally { - runDestroy(root2); - } - } finally { - runDestroy(root); - } - } - getCacheCounters() { let { componentDefinitionCount, helperDefinitionCount } = this.renderer._context.constants; diff --git a/packages/ember/tests/component_registration_test.js b/packages/ember/tests/component_registration_test.js index 0bad6bf06de..23e1f1fd4ea 100644 --- a/packages/ember/tests/component_registration_test.js +++ b/packages/ember/tests/component_registration_test.js @@ -2,15 +2,8 @@ import Application from '@ember/application'; import Controller from '@ember/controller'; import { Component } from '@ember/-internals/glimmer'; import { compile } from 'ember-template-compiler'; -import { - moduleFor, - testUnless, - ApplicationTestCase, - defineComponent, - expectDeprecation, -} from 'internal-test-helpers'; +import { moduleFor, ApplicationTestCase, defineComponent } from 'internal-test-helpers'; import { DEBUG } from '@glimmer/env'; -import { DEPRECATIONS } from '@ember/-internals/deprecations'; import templateOnly from '@ember/component/template-only'; moduleFor( @@ -84,81 +77,6 @@ moduleFor( }); } - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} Late-registered components can be rendered with template registered on the container`]( - assert - ) { - expectDeprecation( - /resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); - this.addTemplate( - 'application', - `
hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
` - ); - - this.application.instanceInitializer({ - name: 'sally-rutherford-component-template', - initialize(applicationInstance) { - applicationInstance.register( - 'template:components/sally-rutherford', - compile('funkytowny{{yield}}') - ); - }, - }); - this.application.instanceInitializer({ - name: 'sally-rutherford-component', - initialize(applicationInstance) { - applicationInstance.register('component:sally-rutherford', Component); - }, - }); - - return this.visit('/').then(() => { - let text = this.$('#wrapper').text().trim(); - assert.equal( - text, - 'hello world funkytowny-funkytowny!!!', - 'The component is composed correctly' - ); - }); - } - - [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} Late-registered components can be rendered with ONLY the template registered on the container`]( - assert - ) { - expectDeprecation( - /resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); - - this.addTemplate( - 'application', - `
hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
` - ); - - this.application.instanceInitializer({ - name: 'borf-snorlax-component-template', - initialize(applicationInstance) { - applicationInstance.register( - 'template:components/borf-snorlax', - compile('goodfreakingTIMES{{yield}}') - ); - }, - }); - - return this.visit('/').then(() => { - let text = this.$('#wrapper').text().trim(); - assert.equal( - text, - 'hello world goodfreakingTIMES-goodfreakingTIMES!!!', - 'The component is composed correctly' - ); - }); - } - ['@test Assigning layoutName to a component should setup the template as a layout'](assert) { assert.expect(1); From 1c8c8129e548987b2e71fa239f6dea0485832d5b Mon Sep 17 00:00:00 2001 From: Tommy Carter Date: Tue, 1 Apr 2025 13:31:22 -0500 Subject: [PATCH 2/4] Updated code for removal of DEPRECATE_COMPONENT_TEMPLATE_RESOLVING --- .../@ember/-internals/glimmer/lib/resolver.ts | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/packages/@ember/-internals/glimmer/lib/resolver.ts b/packages/@ember/-internals/glimmer/lib/resolver.ts index 1942792b99a..af51ab9865d 100644 --- a/packages/@ember/-internals/glimmer/lib/resolver.ts +++ b/packages/@ember/-internals/glimmer/lib/resolver.ts @@ -1,4 +1,4 @@ -import type { InternalFactory, InternalOwner, RegisterOptions } from '@ember/-internals/owner'; +import type { InternalFactory, InternalOwner } from '@ember/-internals/owner'; import { isFactory } from '@ember/-internals/owner'; import { assert } from '@ember/debug'; import { _instrumentStart } from '@ember/instrumentation'; @@ -42,7 +42,6 @@ import { default as uniqueId } from './helpers/unique-id'; import { mountHelper } from './syntax/mount'; import { outletHelper } from './syntax/outlet'; -import { DEPRECATIONS, deprecateUntil } from '@ember/-internals/deprecations'; function instrumentationPayload(name: string) { return { object: `component:${name}` }; @@ -56,29 +55,6 @@ function componentFor( return owner.factoryFor(fullName) || null; } -function layoutFor( - name: string, - owner: InternalOwner, - options?: RegisterOptions -): Nullable