Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c22d07243
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Preview deployments |
Host Test Results 1 files ± 0 1 suites ±0 2h 6m 42s ⏱️ + 2m 43s Results for commit 8ef968d. ± Comparison against base commit 86cb8e6. This pull request removes 1 and adds 185 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
518f28f to
891ea2c
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a “live test” runner page intended to execute realm-hosted (card) tests in a host-like Ember/QUnit environment, and refactors an experiments realm sample card test to use a consolidated host test setup helper.
Changes:
- Add a dedicated
live-test.html+live-test.jsrunner to load realm modules and execute theirrunTests()exports under QUnit. - Update the standard host
tests/test-helper.jsboot to skip normal initialization when running on the live-test page. - Add a
setupCardTest(hooks)helper and updatesample-command-card.gtstests (including a new search assertion).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/host/tests/test-helper.js | Skips normal test initialization on live-test.html; imports live-test runner module. |
| packages/host/tests/live-test.js | New runtime for loading realm test modules and starting QUnit manually. |
| packages/host/tests/live-test.html | New test runner HTML page with QUnit UI and a “Start QUnit” button. |
| packages/host/tests/helpers/index.gts | Adds setupCardTest() convenience helper used by realm-hosted tests. |
| packages/host/ember-cli-build.js | Formatting-only change. |
| packages/host/app/lib/externals.ts | Adds shims for QUnit/test helpers/test modules to support realm-loaded tests. |
| packages/experiments-realm/sample-command-card.gts | Refactors test setup to setupCardTest() and adds a search-based assertion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import './live-test'; | ||
|
|
||
| QUnit.dump.maxDepth = 20; | ||
| const isLiveTest = new URL(window.location.href).pathname.endsWith( | ||
| '/live-test.html', | ||
| ); | ||
|
|
||
| useTestWaiters(TestWaiters); | ||
| setApplication(Application.create(config.APP)); | ||
| if (!isLiveTest) { | ||
| QUnit.dump.maxDepth = 20; |
There was a problem hiding this comment.
Pull request overview
This PR adds a “live” test runner mode that can load and execute test modules served from a running realm (instead of only running the host’s compiled test bundle), and wires it into CI.
Changes:
- Add a live-test bootstrap (
tests/live-test.js+ optionaltests/live-test.html) and gate the normaltests/test-helper.jsstartup when?liveTest=true. - Add a Testem config + wait-for-services script + CI job to run these realm-backed tests headlessly.
- Add a convenience helper (
setupCardTest) and a sample realm card test that validates indexing/search against a live realm.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/host/tests/test-helper.js | Skips standard Ember Exam/QUnit startup when running in live-test mode; imports live-test bootstrap. |
| packages/host/tests/live-test.js | New live-test runner: boot app, discover realm modules, shim helpers into loader, run runTests() exports. |
| packages/host/tests/live-test.html | Optional standalone HTML runner with UI controls/status for live tests. |
| packages/host/tests/helpers/index.gts | Adds setupCardTest() helper for realm card tests. |
| packages/host/testem-live.js | New Testem config to run tests/index.html?liveTest=true... and emit junit in CI. |
| packages/host/scripts/live-test-wait-for-servers.sh | Waits for dependent services/readiness endpoints then runs live tests. |
| packages/host/package.json | Adds test:live script. |
| packages/host/ember-cli-build.js | No functional change (whitespace). |
| packages/host/app/lib/externals.ts | Adds QUnit shim + test-module shims intended to let cards with colocated tests load. |
| packages/host/.eslintrc.js | Allows linting testem-live.js. |
| packages/catalog-realm/sample-command-card.gts | Updates sample card’s colocated tests; adds an indexing/search assertion. |
| mise-tasks/test-services-host | Keeps sample-command-card.gts when preparing the catalog realm for tests. |
| .github/workflows/ci-host.yaml | Adds a new “Live Tests (realm)” job to CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const testOnlyStub = (moduleId: string) => | ||
| new Proxy( | ||
| {}, | ||
| { | ||
| get: () => { | ||
| throw new Error( | ||
| `${moduleId} is only available in a test environment.`, | ||
| ); | ||
| }, | ||
| }, | ||
| ); |
There was a problem hiding this comment.
testOnlyStub throws on any property access via Proxy.get. That will break module evaluation for realm cards that have static imports like import { click } from '@ember/test-helpers' or import { setupCardTest } from '@cardstack/host/tests/helpers', because the export is accessed during module instantiation (before any test code runs). To allow cards to load outside tests, the stub should return callable functions (or undefined) and only throw when those functions are invoked, not when the export is imported.
| const testOnlyStub = (moduleId: string) => | |
| new Proxy( | |
| {}, | |
| { | |
| get: () => { | |
| throw new Error( | |
| `${moduleId} is only available in a test environment.`, | |
| ); | |
| }, | |
| }, | |
| ); | |
| const testOnlyStub = (moduleId: string) => { | |
| const throwingFunction = function () { | |
| throw new Error(`${moduleId} is only available in a test environment.`); | |
| }; | |
| return new Proxy( | |
| {}, | |
| { | |
| get() { | |
| return throwingFunction; | |
| }, | |
| }, | |
| ); | |
| }; |
|
|
||
| if (!isLiveTest) { | ||
| console.warn('[live-test] Skipping initialization outside live-test.html'); |
There was a problem hiding this comment.
live-test.js is imported unconditionally from tests/test-helper.js, so this console.warn will execute for every normal (non-live) test run and add noise to CI logs. Consider removing the warning (or gating it behind an explicit debug flag) so standard test runs stay quiet.
| if (!isLiveTest) { | |
| console.warn('[live-test] Skipping initialization outside live-test.html'); | |
| const isLiveTestDebug = url.searchParams.has('liveTestDebug'); | |
| if (!isLiveTest) { | |
| if (isLiveTestDebug) { | |
| console.warn('[live-test] Skipping initialization outside live-test.html'); | |
| } |
| // eslint-disable-next-line ember/no-test-import-export | ||
| import './live-test'; | ||
|
|
||
| QUnit.dump.maxDepth = 20; | ||
| const url = new URL(window.location.href); | ||
| const isLiveTest = | ||
| url.pathname.endsWith('/live-test.html') || url.searchParams.has('liveTest'); |
There was a problem hiding this comment.
Static-importing ./live-test means its side effects run on every test entrypoint load. Combined with live-test.js's non-live console.warn, this will spam warnings in regular test runs. Prefer conditionally loading the live-test bootstrap only when liveTest is present (e.g., via import('./live-test') inside an if (isLiveTest) block) or ensure the imported module is silent when inactive.
| } catch { | ||
| testModuleNames = []; |
There was a problem hiding this comment.
The fetch(realmURL) error is swallowed and replaced with testModuleNames = [], which can lead to a confusing "0 tests" outcome without indicating why test discovery failed. It would be more diagnosable to log the exception (or surface a failing test) when realm discovery fails, especially in CI.
| } catch { | |
| testModuleNames = []; | |
| } catch (error) { | |
| console.error('Failed to discover tests from realm', realmURL, error); | |
| throw error; |
How to run locally