Skip to content

Commit

Permalink
Merge pull request #20693 from emberjs/kg-fix-run-with-deprecations-e…
Browse files Browse the repository at this point in the history
…nabled

Fix running tests with all deprecations enabled.
  • Loading branch information
kategengler committed May 9, 2024
2 parents c85fed3 + 6f260cb commit 47f3eeb
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
ApplicationTestCase,
ModuleBasedTestResolver,
expectDeprecation,
moduleFor,
strip,
testUnless,
} from 'internal-test-helpers';

import { ENV } from '@ember/-internals/environment';
Expand All @@ -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 {
Expand Down Expand Up @@ -788,13 +785,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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -31,8 +25,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!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
defineSimpleHelper,
defineSimpleModifier,
testUnless,
expectDeprecation,
} from 'internal-test-helpers';

import { Input, Textarea } from '@ember/component';
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
19 changes: 12 additions & 7 deletions packages/@ember/-internals/glimmer/tests/integration/mount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' });

Expand Down
17 changes: 16 additions & 1 deletion packages/ember/tests/component_registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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',
`<div id='wrapper'>hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}</div>`
Expand Down Expand Up @@ -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',
`<div id='wrapper'>hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}</div>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}');
Expand Down
7 changes: 6 additions & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
EmberENV['RAISE_ON_DEPRECATION'] = true;

if (QUnit.urlParams.ALL_DEPRECATIONS_ENABLED) {
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = QUnit.urlParams.ALL_DEPRECATIONS_ENABLED;
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = true;
}

if (QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 47f3eeb

Please sign in to comment.