Skip to content

Use settled from @ember/test-helpers in the RouterService transitionTo tests - #21658

Open
NullVoxPopuli-ai-agent wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/settled-from-test-helpers
Open

NullVoxPopuli-ai-agent wants to merge 1 commit into
emberjs:mainfrom
NullVoxPopuli-ai-agent:nvp/settled-from-test-helpers

Conversation

@NullVoxPopuli-ai-agent

Copy link
Copy Markdown
Contributor

import { settled } from '@ember/test-helpers' now works in the main test suite. transitionTo_test.js is the first file that uses it.

Before, @ember/test-helpers was only available in the smoke tests.

The test file

packages/ember/tests/routing/router_service_test/transitionTo_test.js had four tests that started a transition inside run(() => ...). They are a good fit for settled(), because the wait is for a route transition and not only for a render.

// before
run(function () {
  componentInstance.transitionToSister();
});

// after
componentInstance.transitionToSister();
await settled();

No test was added, removed or renamed.

The wiring

File Change
package.json @ember/test-helpers ^5.5.0 as a devDependency. This is the version that the smoke tests use, so the lockfile gets three lines.
rollup.config.mjs testDependencies gets @ember/test-helpers, @ember/test-waiters and dom-element-descriptors.
babel.test.config.mjs The @embroider/macros babel plugin, because the two addons use macros.

buildMacros() reads NODE_ENV, but the test build selects its mode with EMBER_ENV. The configure hook enables development mode from EMBER_ENV. Without it, a local vite build --mode development compiled @ember/test-waiters in production mode.

The published build does not use babel.test.config.mjs.

Limits

  • This repo is ember-source, and it does not depend on itself. As a result, appEmberSatisfies(...) and dependencySatisfies('ember-source', ...) are false inside @ember/test-helpers. settled() is not affected. render() from @ember/test-helpers is not tested here.
  • The internal test cases do not call setupContext. settled() waits for the runloop, timers, test waiters and pending renders. Its router transition flag is not active.

Verification

  • Router Service - transitionTo module: 19 pass in development, production, both "all deprecations enabled" variants, both "deprecations as errors" variants, and production with optional features.
  • Full suite, 0 failures in each build:
    • development (NODE_ENV=development, as CI): 9513 tests, 9495 pass, 18 skipped
    • production: 9351 tests, 9286 pass, 65 skipped
    • stable decorators: 9513 tests, 9495 pass, 18 skipped
    • stable decorators with TypeScript emit: 9513 tests, 9495 pass, 18 skipped
  • With the four await settled() lines removed, those four tests fail and the other 15 pass.
  • pnpm start (the vite dev server) in headless Chrome: 19 tests, 0 failed.
  • pnpm type-check:internals, eslint and prettier pass. pnpm build passes and leaves no diff.

Related

#21657 does the same move for renderSettled() in the renderComponent tests. The two PRs touch different files.

🤖 Generated with Claude Code

Four RouterService#transitionTo tests started a transition inside
`run(() => ...)`. They now start the transition directly and wait with
`await settled()`, as an application test does.

`@ember/test-helpers` was not available in the main test build. This
commit adds it:

- `@ember/test-helpers` is a devDependency of the root package.
- `testDependencies` in rollup.config.mjs lets the test build resolve
  `@ember/test-helpers`, `@ember/test-waiters` and
  `dom-element-descriptors` from node_modules.
- babel.test.config.mjs runs the `@embroider/macros` plugin, because
  those two addons use macros.

`buildMacros()` reads NODE_ENV, but the test build selects its mode with
EMBER_ENV. The `configure` hook enables development mode from EMBER_ENV,
so `isDevelopingApp()` is the same with and without NODE_ENV.

The published build does not use babel.test.config.mjs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants