From aee277e5ce7a979dc2d2675fe6bfa2e2f058e74a Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 9 May 2024 15:20:57 -0400 Subject: [PATCH 1/2] Fix tests when deprecations are enabled --- .../application/debug-render-tree-test.ts | 8 +----- .../integration/components/append-test.js | 19 ++++++++++++- .../components/component-template-test.js | 2 -- .../components/strict-mode-test.js | 11 ++++++++ .../glimmer/tests/integration/mount-test.js | 19 ++++++++----- .../tests/unit/runtime-resolver-cache-test.js | 5 +++- .../tests/component_registration_test.js | 17 ++++++++++- .../non_application_test_test.js | 28 ++++++++++--------- tests/index.html | 5 ++++ 9 files changed, 82 insertions(+), 32 deletions(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts b/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts index fdec69d40a2..53181487625 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts +++ b/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts @@ -788,13 +788,7 @@ if (ENV._DEBUG_RENDER_TREE) { ]); } - async [`${testUnless( - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved - )} template-only components`]() { - expectDeprecation( - /resolved templates/, - DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled - ); + async [`@test template-only components`]() { this.addTemplate( 'application', strip` 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 e2ca6840649..af4efa92813 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/append-test.js @@ -1,4 +1,11 @@ -import { moduleFor, RenderingTestCase, strip, runTask, testUnless } from 'internal-test-helpers'; +import { + moduleFor, + RenderingTestCase, + strip, + runTask, + testUnless, + expectDeprecation, +} from 'internal-test-helpers'; import { set } from '@ember/object'; @@ -284,6 +291,11 @@ class AbstractAppendTest extends RenderingTestCase { )} lifecycle hooks during component append`](assert) { let hooks = []; + expectDeprecation( + /resolved templates/, + DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled + ); + let oldRegisterComponent = this.registerComponent; let componentsByName = {}; @@ -532,6 +544,11 @@ class AbstractAppendTest extends RenderingTestCase { )} 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', 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 d43ff551fbb..0607bb707f9 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 @@ -31,8 +31,6 @@ moduleFor( [`${testUnless( DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved )} it takes precedence over resolver`]() { - expectDeprecation('', DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled); - this.registerComponent('foo-bar', { ComponentClass: setComponentTemplate(compile('hello'), Component.extend()), resolveableTemplate: 'noooooo!', diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js index 01f2ad32399..ba78bdd0184 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js @@ -6,6 +6,7 @@ import { defineSimpleHelper, defineSimpleModifier, testUnless, + expectDeprecation, } from 'internal-test-helpers'; import { Input, Textarea } from '@ember/component'; @@ -268,6 +269,11 @@ moduleFor( [`${testUnless(DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isRemoved)} Can use action helper`]( assert ) { + expectDeprecation( + /Migrate to native functions/, + DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isEnabled + ); + let called = 0; let Foo = defineComponent( @@ -294,6 +300,11 @@ moduleFor( [`${testUnless(DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isRemoved)} Can use action modifier`]( assert ) { + expectDeprecation( + /Migrate to native functions/, + DEPRECATIONS.DEPRECATE_TEMPLATE_ACTION.isEnabled + ); + let called = 0; let Foo = defineComponent( diff --git a/packages/@ember/-internals/glimmer/tests/integration/mount-test.js b/packages/@ember/-internals/glimmer/tests/integration/mount-test.js index ce57ccd5586..e40bd54483f 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/mount-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/mount-test.js @@ -15,6 +15,7 @@ import Engine, { getEngineParent } from '@ember/engine'; import { backtrackingMessageFor } from '../utils/debug-stack'; import { compile, Component } from '../utils/helpers'; +import { setComponentTemplate } from '@glimmer/manager'; moduleFor( '{{mount}} single param assertion', @@ -142,19 +143,23 @@ moduleFor( }, }); - this.engineRegistrations['template:components/component-with-backtracking-set'] = compile( - '[component {{this.person.name}}]', - { - moduleName: 'my-app/templates/components/component-with-backtracking-set.hbs', - } - ); - this.engineRegistrations['component:component-with-backtracking-set'] = Component.extend({ + let ComponentWithBacktrackingSet = Component.extend({ init() { this._super(...arguments); this.set('person.name', 'Ben'); }, }); + setComponentTemplate( + compile('[component {{this.person.name}}]', { + moduleName: 'my-app/templates/components/component-with-backtracking-set.hbs', + }), + ComponentWithBacktrackingSet + ); + + this.engineRegistrations['component:component-with-backtracking-set'] = + ComponentWithBacktrackingSet; + let expectedBacktrackingMessage = backtrackingMessageFor('name', 'Person \\(Ben\\)', { renderTree: ['application', 'route-with-mount', 'chat', 'this.person.name'], }); 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 5321c033eae..e7aeb6eabe0 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 @@ -128,7 +128,10 @@ moduleFor( [`${testUnless( DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isRemoved )} each template is only compiled once`]() { - expectDeprecation(/msg here/, DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled); + expectDeprecation( + /resolved templates/, + DEPRECATIONS.DEPRECATE_COMPONENT_TEMPLATE_RESOLVING.isEnabled + ); // static layout this.registerComponent('component-one', { resolveableTemplate: 'One' }); diff --git a/packages/ember/tests/component_registration_test.js b/packages/ember/tests/component_registration_test.js index 4139bc55125..0bad6bf06de 100644 --- a/packages/ember/tests/component_registration_test.js +++ b/packages/ember/tests/component_registration_test.js @@ -2,7 +2,13 @@ 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 } from 'internal-test-helpers'; +import { + moduleFor, + testUnless, + ApplicationTestCase, + defineComponent, + expectDeprecation, +} from 'internal-test-helpers'; import { DEBUG } from '@glimmer/env'; import { DEPRECATIONS } from '@ember/-internals/deprecations'; import templateOnly from '@ember/component/template-only'; @@ -83,6 +89,10 @@ moduleFor( )} 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}}
` @@ -119,6 +129,11 @@ moduleFor( )} 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}}
` diff --git a/packages/ember/tests/routing/router_service_test/non_application_test_test.js b/packages/ember/tests/routing/router_service_test/non_application_test_test.js index d6104784600..bca216876af 100644 --- a/packages/ember/tests/routing/router_service_test/non_application_test_test.js +++ b/packages/ember/tests/routing/router_service_test/non_application_test_test.js @@ -82,20 +82,22 @@ moduleFor( this.addTemplate('parent.index', '{{foo-bar}}'); - this.addComponent('foo-bar', { - ComponentClass: Component.extend({ - routerService: service('router'), - init() { - this._super(...arguments); - componentInstance = this; - }, - actions: { - transitionToSister() { - get(this, 'routerService').transitionTo('parent.sister'); - }, + let FooBar = Component.extend({ + routerService: service('router'), + layout: this.compile('foo-bar'), + init() { + this._super(...arguments); + componentInstance = this; + }, + actions: { + transitionToSister() { + get(this, 'routerService').transitionTo('parent.sister'); }, - }), - template: `foo-bar`, + }, + }); + + this.addComponent('foo-bar', { + ComponentClass: FooBar, }); this.render('{{foo-bar}}'); diff --git a/tests/index.html b/tests/index.html index 4fde8fcfb0c..ca5e3e477de 100644 --- a/tests/index.html +++ b/tests/index.html @@ -109,6 +109,11 @@ label: 'Deprecation Version', }); + QUnit.config.urlConfig.push({ + id: 'ALL_DEPRECATIONS_ENABLED', + label: 'Enable All Deprecations', + }); + if (QUnit.config.seed) { QUnit.config.reorder = false; From d5abe417a20a00b83a7ff3e6ae0329c9a96ba21b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 9 May 2024 15:23:56 -0400 Subject: [PATCH 2/2] lints --- .../integration/application/debug-render-tree-test.ts | 3 --- .../integration/components/component-template-test.js | 8 +------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts b/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts index 53181487625..a9b2becaaff 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts +++ b/packages/@ember/-internals/glimmer/tests/integration/application/debug-render-tree-test.ts @@ -1,10 +1,8 @@ import { ApplicationTestCase, ModuleBasedTestResolver, - expectDeprecation, moduleFor, strip, - testUnless, } from 'internal-test-helpers'; import { ENV } from '@ember/-internals/environment'; @@ -24,7 +22,6 @@ import type { SimpleElement, SimpleNode } from '@simple-dom/interface'; import type { EmberPrecompileOptions } from 'ember-template-compiler'; import { compile } from 'ember-template-compiler'; import { runTask } from 'internal-test-helpers/lib/run'; -import { DEPRECATIONS } from '@ember/-internals/deprecations'; import templateOnly from '@ember/component/template-only'; interface CapturedBounds { 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 0607bb707f9..34ebccc2604 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,11 +1,5 @@ import { DEBUG } from '@glimmer/env'; -import { - expectDeprecation, - moduleFor, - RenderingTestCase, - runTask, - testUnless, -} from 'internal-test-helpers'; +import { moduleFor, RenderingTestCase, runTask, testUnless } from 'internal-test-helpers'; import { setComponentTemplate, getComponentTemplate } from '@glimmer/manager'; import { Component, compile } from '../../utils/helpers';