Skip to content

test(atomic-cdn-smoke): wait for fully loaded pages in CDN smoke tests j:KIT-6445 - #8748

Open
alexprudhomme wants to merge 2 commits into
mainfrom
KIT-6445-flaky-commerce-smoke
Open

alexprudhomme wants to merge 2 commits into
mainfrom
KIT-6445-flaky-commerce-smoke

Conversation

@alexprudhomme

@alexprudhomme alexprudhomme commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Jira

https://coveord.atlassian.net/browse/KIT-6445

Motivation

In ui-kit-cd, the CDN smoke test tests/commerce.spec.ts › Commerce page renders products sometimes times out with locator.evaluate: Test timeout of 30000ms exceeded (run 39815902139). Chromatic then stores the page in its loading state, because @chromatic-com/playwright takes 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 on customElements.whenDefined() for every Atomic child, with no time limit. The CDN autoloader loads each component with a dynamic import from static.cloud.coveo.com and never retries one that fails. If a component download fails, that component is never defined and initialize() 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

  • Moved the shared flow of the four specs (register the MSW handlers, open the page, load the theme and Atomic from the CDN, initialize, run the first request, wait for the page to render) into a single renderPage fixture in fixtures.ts. Each spec now passes only what differs: the page, handlers, interface tag, initialize options, first-request method and item selector. It replaces the openPage and useHandlers fixtures.
  • Before the snapshot, every test now waits until nothing is still loading:
    • the first item (product or result) is visible
    • no atomic-result-placeholder is left in the interface
    • no undefined (:not(:defined)) element is left in the interface

No 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 passed

  • Before the refactor, the commerce spec with a random 0–1.5 s delay on every CDN request, --repeat-each 20: 20/20 passed

  • Checked 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

  • PR title follows Conventional Commits 1.0.0 format (test(<scope>): <description>)
  • No changeset is included in this PR (@coveo/atomic-cdn-smoke is private)

🤖 Generated with Claude Code

…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.
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1187a90

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svcsnykcoveo

svcsnykcoveo commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@chromatic-com

chromatic-com Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 439 tests unchanged
🟢 UI Review: No changes
Storybook icon Storybook Publish: 471 stories published

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
@coveo/atomic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic@8748

@coveo/atomic-hosted-page

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-hosted-page@8748

@coveo/atomic-legacy

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-legacy@8748

@coveo/atomic-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-react@8748

@coveo/bueno

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/bueno@8748

coveo.analytics

npm i https://pkg.pr.new/coveo/ui-kit/coveo.analytics@8748

@coveo/create-atomic-rollup-plugin

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-rollup-plugin@8748

@coveo/headless

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless@8748

@coveo/headless-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless-react@8748

@coveo/quantic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/quantic@8748

@coveo/relay

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/relay@8748

@coveo/shopify

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/shopify@8748

@coveo/thermidor

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/thermidor@8748

@coveo/atomic-angular

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-angular@8748

commit: 1187a90

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Scratch Orgs ready to test this PR:

@alexprudhomme
alexprudhomme marked this pull request as ready for review October 23, 2026 19:57
Copilot AI balanced review requested due to automatic review settings October 23, 2026 19:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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

Comment on lines 19 to 21
const registrationError = failOnAtomicRegistrationError(page);
await useHandlers(commerceApi.handlers);
await openPage('commerce.html');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@alexprudhomme alexprudhomme changed the title test(atomic-cdn-smoke): wait for rendered products in commerce smoke test j:KIT-6445 test(atomic-cdn-smoke): wait for fully loaded pages in CDN smoke tests j:KIT-6445 Oct 23, 2026

This branch was successfully deployed

2 active deployments
pr-workflows — 1187a90c Deployed Oct 23, 2026 by alexprudhomme via label #9963
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.

3 participants