Skip to content

Commit

Permalink
Fix tests when deprecations are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed May 9, 2024
1 parent ddfbcea commit aee277e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`
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
Expand Up @@ -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!',
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
5 changes: 5 additions & 0 deletions tests/index.html
Original file line number Diff line number Diff line change
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 aee277e

Please sign in to comment.