Repository navigation
test(atomic-cdn-smoke): wait for fully loaded pages in CDN smoke tests j:KIT-6445 - #8748
alexprudhomme wants to merge 2 commits into
Conversation
…test j:KIT-6445 The commerce smoke test hung in initialize() when an Atomic component chunk failed to load from the CDN: the autoloader never retries, so customElements.whenDefined never resolves. The test now fails fast on the autoloader's registration error and waits for the first request, visible products, no placeholders and no undefined elements before the snapshot.
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Tip All tests passed and all changes approved!🟢 UI Tests: 439 tests unchanged |
@coveo/atomic
@coveo/atomic-hosted-page
@coveo/atomic-legacy
@coveo/atomic-react
@coveo/bueno
coveo.analytics
@coveo/create-atomic-rollup-plugin
@coveo/headless
@coveo/headless-react
@coveo/quantic
@coveo/relay
@coveo/shopify
@coveo/thermidor
@coveo/atomic-angular
commit: |
There was a problem hiding this comment.
🟡 Changes recommended
Registration errors during page setup can reject the monitoring promise before its rejection handler is attached.
1 open issue
What changed in this PR
Improves the commerce CDN smoke test so snapshots wait for rendered products and component registration failures report their cause instead of timing out.
Changes:
- Adds monitoring for Atomic autoloader registration errors.
- Waits for the first request, visible products, removed placeholders, and defined custom elements.
- Changes only the test; production behavior is unchanged.
| File | Description |
|---|---|
packages/atomic-cdn-smoke/tests/commerce.spec.ts |
Adds registration-error monitoring and explicit rendering assertions. |
Review effort: Balanced
| const registrationError = failOnAtomicRegistrationError(page); | ||
| await useHandlers(commerceApi.handlers); | ||
| await openPage('commerce.html'); |
There was a problem hiding this comment.
Good catch for b953287, but this no longer applies: 1187a90 removed failOnAtomicRegistrationError and the Promise.race. The four specs now share the renderPage fixture in fixtures.ts, which waits for visible items, no placeholders and no undefined Atomic elements. The listener only changed the failure message, so there is no early rejection left to handle.
…n all smoke tests j:KIT-6445 Move the shared setup of the four CDN smoke specs into a renderPage fixture, and make every spec wait for visible items, no placeholders and no undefined Atomic elements before the snapshot. Drop the registration-error listener: it only changed the failure message.

Jira
https://coveord.atlassian.net/browse/KIT-6445
Motivation
In ui-kit-cd, the CDN smoke test
tests/commerce.spec.ts › Commerce page renders productssometimes times out withlocator.evaluate: Test timeout of 30000ms exceeded(run 39815902139). Chromatic then stores the page in its loading state, because@chromatic-com/playwrighttakes its snapshot when the test body ends, even when the test fails.Root cause
The timeout is in the
initialize()call, not in the wait for products.initialize()waits oncustomElements.whenDefined()for every Atomic child, with no time limit. The CDN autoloader loads each component with a dynamic import fromstatic.cloud.coveo.comand never retries one that fails. If a component download fails, that component is never defined andinitialize()never resolves. A slow CDN only delays it: with a random 0–1.5 s delay added to every CDN request, the test still passes in about 2–3 s. Locally, against the same CDN build as the failing run, aborting a single component chunk reproduces the exact CI error at the same line. CI kept no browser logs, so the failed download in CI is inferred, not observed.The search, IPX and insight tests have the same weakness: their interfaces wait the same way, and each test stopped as soon as the first result was visible, without checking that placeholders were gone or that every component was defined. In the last 40 "Update CDN pointers" runs, only the commerce test failed: it runs first and loads the most components.
Changes
renderPagefixture infixtures.ts. Each spec now passes only what differs: the page, handlers, interface tag, initialize options, first-request method and item selector. It replaces theopenPageanduseHandlersfixtures.atomic-result-placeholderis left in the interface:not(:defined)) element is left in the interfaceNo timeouts were raised and no retries were added. A real CDN failure still fails the test.
Validation
Run locally against the CDN build from the failing run (
COMMIT_SHA=b267405456ead7af591d00a816e84b5505990ba2):Full suite,
playwright test --repeat-each 20: 80/80 passedBefore the refactor, the commerce spec with a random 0–1.5 s delay on every CDN request,
--repeat-each 20: 20/20 passedChecked that
:not(:defined)really matches undefined elements on the commerce page: 20 before the components load, 0 after. Checked that the placeholders on that page actually show (50) before the products replace them.All new and existing tests pass
No production code was modified (test files only)
Tests cover the intended scenarios
Checklist
test(<scope>): <description>)@coveo/atomic-cdn-smokeis private)🤖 Generated with Claude Code