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

Remove old code that existed for now unsupported ember-sources (2.4, etc) #1486

Merged
merged 10 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- ember-canary
- ember-default
- embroider-safe
# - embroider-optimized # see comments in ember-try.js
- embroider-optimized

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@
"@ember/-internals",
"@ember/renderer"
]
},
"volta": {
"extends": "../package.json"
}
}
11 changes: 8 additions & 3 deletions addon/src/settled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,24 @@ if (loader.registry['ember-testing/test/waiters']) {
function checkWaiters() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
type Waiter = [any, Function];
const EmberTest = Ember.Test as any as { waiters: Array<Waiter> };
const EmberTest = Ember.Test as any as {
waiters: Array<Waiter>;
checkWaiters: () => boolean;
};

if (_internalCheckWaiters) {
return _internalCheckWaiters();
} else if (EmberTest.waiters) {
}

if (EmberTest.waiters) {
if (
EmberTest.waiters.some(([context, callback]) => !callback.call(context))
) {
return true;
}
}

return false;
return EmberTest.checkWaiters();
Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

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

changing this from false to EmberTest.checkWaiters() is a meaningful change, but the only mainingful change in this PR (for consumers).

The code for checkWaiters is here: https://github.com/emberjs/ember.js/blob/85a4f298f67ff70395cf7f9103682335162e0606/packages/ember-testing/lib/test/waiters.ts#L111

and those callbacks are part of the legacy waiter system.

There are existing comments about removing code for accessing legacy-waiter stuff (because ember.js has since abstracted it so we don't need to be so weird in this library) -- cleaning that up can happen in a followup PR, and should be non-breaking, and retain legacy waiter support.

Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

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

So.... I suppose this should be a patch-release, rather than non-release.

}

export interface SettledState {
Expand Down
16 changes: 2 additions & 14 deletions test-app/config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe } = require('@embroider/test-setup');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
const latestVersion = require('latest-version');

module.exports = async function () {
Expand Down Expand Up @@ -122,19 +122,7 @@ module.exports = async function () {
},
},
embroiderSafe(),
// disable embroider optimized test scenarios, as the dynamism these
// tests use is not compatible with embroider we are still exploring
// appropriate paths forward.
//
// Steps to re-enable:
//
// 1. have a strategy to make this work, import from '@embroider/test-setup'
// 2. uncomment the next line
// embroiderOptimized();
//
// 3. add "embroider-optimized" to .github/workflows/ci-build.yml's
// ember-try-scenario list.
//
embroiderOptimized(),
],
};
};
36 changes: 35 additions & 1 deletion test-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,39 @@ module.exports = function (defaults) {
// Add options here
});

return app.toTree();
const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app, {
packageRules: [
{
package: 'test-app',
components: {
/**
* All of these were found by searching for 'component:
* and all of those happen to be in-app registrations
*
* It very well could be that we don't actually need to interact
* with the resolver or registry anymore, but that investigation
* has been left for a future date.
*/
'{{x-test-1}}': { safeToIgnore: true },
'{{x-test-2}}': { safeToIgnore: true },
'{{x-test-3}}': { safeToIgnore: true },
'{{x-test-4}}': { safeToIgnore: true },
'{{x-test-5}}': { safeToIgnore: true },
'{{x-foo}}': { safeToIgnore: true },
'{{x-input}}': { safeToIgnore: true },
'{{foo}}': { safeToIgnore: true },
'{{foo-bar}}': { safeToIgnore: true },
'{{my-input}}': { safeToIgnore: true },
'{{my-component}}': { safeToIgnore: true },
'{{click-me-button}}': { safeToIgnore: true },
'{{promise-wrapper}}': { safeToIgnore: true },
'{{js-only}}': { safeToIgnore: true },
'{{outer-comp}}': { safeToIgnore: true },
'{{inner-comp}}': { safeToIgnore: true },
'{{template-only}}': { safeToIgnore: true },
},
},
],
});
};
11 changes: 8 additions & 3 deletions test-app/tests/unit/setup-rendering-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ module('setupRenderingContext', function (hooks) {
'component:js-only': Component.extend({
classNames: ['js-only'],
}),
'helper:jax': helper(([name]) => `${name}-jax`),
'component:outer-comp': setComponentTemplate(
hbs`outer{{inner-comp}}outer`,
class extends Component {}
Expand Down Expand Up @@ -287,15 +286,21 @@ module('setupRenderingContext', function (hooks) {
});

test('can invoke helper', async function (assert) {
await render(hbs`{{jax "max"}}`);
this.setProperties({
jax: helper(([name]) => `${name}-jax`),
});
await render(hbs`{{this.jax "max"}}`);
Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

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

these helpers were (rightfully so!) trying to look up the helper defined in app/helpers/jax.

However, that doesn't exist, and since we don't actually support custom resolvers for normal apps, this is fine. These tests are testing that render can invoke helpers, and helpers can be defined on this


assert.equal(this.element.textContent, 'max-jax');
});

test('can pass arguments to helper from context', async function (assert) {
this.setProperties({
jax: helper(([name]) => `${name}-jax`),
});
this.set('name', 'james');

await render(hbs`{{jax this.name}}`);
await render(hbs`{{this.jax this.name}}`);

assert.equal(this.element.textContent, 'james-jax');
});
Expand Down