Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations failing the build #1448

Merged
merged 2 commits into from Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/helpers/setup-no-deprecations.js
Expand Up @@ -4,12 +4,17 @@ import { registerDeprecationHandler } from '@ember/debug';
let isRegistered = false;
let deprecations;

// Ignore deprecations that are not caused by our own code, and which we cannot fix easily.
const ignoredDeprecations = [/Versions of modifier manager capabilities prior to 3\.22 have been deprecated/];

export default function setupNoDeprecations({ beforeEach, afterEach }) {
beforeEach(function () {
deprecations = [];
if (!isRegistered) {
registerDeprecationHandler((message, options, next) => {
deprecations.push(message);
if (!ignoredDeprecations.some((regex) => message.match(regex))) {
deprecations.push(message);
}
next(message, options);
});
isRegistered = true;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/bs-dropdown-test.js
Expand Up @@ -321,7 +321,7 @@ module('Integration | Component | bs-dropdown', function (hooks) {
<dd.toggle>Dropdown</dd.toggle>
<dd.menu as |menu|>
<menu.item>
{{menu.link-to "Home" "index"}}
<menu.link-to @route="index">Home</menu.link-to>
</menu.item>
</dd.menu>
</BsDropdown>`);
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/components/bs-dropdown/menu-test.js
Expand Up @@ -58,8 +58,8 @@ module('Integration | Component | bs-dropdown/menu', function (hooks) {
hbs`
<BsDropdown as |dd|>
<dd.menu @toggleElement={{this.element}} @isOpen={{true}} as |ddm|>
{{#ddm.link-to "index"}}Link{{/ddm.link-to}}
{{#ddm.linkTo "index"}}Link{{/ddm.linkTo}}
<ddm.link-to @route="index">Link</ddm.link-to>
<ddm.linkTo @route="index">Link</ddm.linkTo>
</dd.menu>
</BsDropdown>
`
Expand Down
46 changes: 20 additions & 26 deletions tests/integration/components/bs-dropdown/menu/link-to-test.js
Expand Up @@ -4,13 +4,9 @@ import { render } from '@ember/test-helpers';
import { testBS3, testBS4 } from '../../../../helpers/bootstrap';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../../helpers/setup-no-deprecations';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

const supportsAngleBracketsLinkTo = hasEmberVersion(3, 10);

module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});
Expand Down Expand Up @@ -64,32 +60,30 @@ module('Integration | Component | bs-dropdown/menu/link-to', function (hooks) {
});
});

if (supportsAngleBracketsLinkTo) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking hasEmberVersion(3, 10), i.e. guards against Ember <3.10, which we don't support anymore.

module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index">Link</BsDropdown::menu::link-to>`);
module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff looks large, but basically I just moved that setupNoDeprecations call from the outer module() to this submodule, thus not applying it to the module testing positional params.


test('simple route link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index">Link</BsDropdown::menu::link-to>`);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});

test('link with model', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsDropdown::menu::link-to>`
);
test('link with model', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsDropdown::menu::link-to>`
);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});

test('disabled link', async function (assert) {
await render(
hbs`<BsDropdown::menu::link-to @route="index" @disabled={{true}}>Link</BsDropdown::menu::link-to>`
);
test('disabled link', async function (assert) {
await render(hbs`<BsDropdown::menu::link-to @route="index" @disabled={{true}}>Link</BsDropdown::menu::link-to>`);

assert.dom('a').hasClass('disabled');
});
assert.dom('a').hasClass('disabled');
});
}
});
});
8 changes: 4 additions & 4 deletions tests/integration/components/bs-nav-test.js
Expand Up @@ -52,10 +52,10 @@ module('Integration | Component | bs-nav', function (hooks) {
await render(hbs`
<BsNav as |nav|>
<nav.item>
{{#nav.link-to "application"}}Dummy{{/nav.link-to}}
<nav.link-to @route="application">Dummy</nav.link-to>
</nav.item>
<nav.item>
{{#nav.linkTo "application"}}Dummy{{/nav.linkTo}}
<nav.linkTo @route="application">Dummy</nav.linkTo>
</nav.item>
<nav.dropdown as |dd|>
<dd.toggle>Dropdown <span class="caret"></span></dd.toggle>
Expand All @@ -76,10 +76,10 @@ module('Integration | Component | bs-nav', function (hooks) {
await render(hbs`
<BsNav as |nav|>
<nav.item>
{{#nav.link-to "application"}}Dummy{{/nav.link-to}}
<nav.link-to @route="application">Dummy</nav.link-to>
</nav.item>
<nav.item>
{{#nav.linkTo "application"}}Dummy{{/nav.linkTo}}
<nav.linkTo @route="application">Dummy</nav.linkTo>
</nav.item>
<nav.dropdown as |dd|>
<dd.toggle>Dropdown <span class="caret"></span></dd.toggle>
Expand Down
52 changes: 24 additions & 28 deletions tests/integration/components/bs-nav/link-to-test.js
Expand Up @@ -4,13 +4,9 @@ import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import setupNoDeprecations from '../../../helpers/setup-no-deprecations';
import { testBS4 } from '../../../helpers/bootstrap';
import hasEmberVersion from '@ember/test-helpers/has-ember-version';

const supportsAngleBracketsLinkTo = hasEmberVersion(3, 10);

module('Integration | Component | bs-nav/link-to', function (hooks) {
setupRenderingTest(hooks);
setupNoDeprecations(hooks);
hooks.beforeEach(function () {
this.owner.setupRouter();
});
Expand Down Expand Up @@ -44,36 +40,36 @@ module('Integration | Component | bs-nav/link-to', function (hooks) {
});
});

if (supportsAngleBracketsLinkTo) {
module('<LinkTo> properties', function () {
test('simple route link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);
module('<LinkTo> properties', function (hooks) {
setupNoDeprecations(hooks);

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});
test('simple route link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);

test('link with model', async function (assert) {
await render(
hbs`<BsNav::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsNav::link-to>`
);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasText('Link');
assert.dom('a').hasAttribute('href', '/');
});

assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});
test('link with model', async function (assert) {
await render(
hbs`<BsNav::link-to @route="acceptance.link" @model="1" @query={{hash foo="bar"}}>Link</BsNav::link-to>`
);

testBS4('link has nav-link class', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);
assert.dom('a').exists({ count: 1 });
assert.dom('a').hasAttribute('href', '/acceptance/link/1?foo=bar');
});

testBS4('link has nav-link class', async function (assert) {
await render(hbs`<BsNav::link-to @route="index">Link</BsNav::link-to>`);

assert.dom('a').hasClass('nav-link');
});
assert.dom('a').hasClass('nav-link');
});

test('disabled link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index" @disabled={{true}}>Link</BsNav::link-to>`);
test('disabled link', async function (assert) {
await render(hbs`<BsNav::link-to @route="index" @disabled={{true}}>Link</BsNav::link-to>`);

assert.dom('a').hasClass('disabled');
});
assert.dom('a').hasClass('disabled');
});
}
});
});