Skip to content

feat: PER-7348 add waitForReady() call before serialize()#1149

Draft
Shivanshu-07 wants to merge 1 commit intomasterfrom
PER-7348-readiness-in-serialize
Draft

feat: PER-7348 add waitForReady() call before serialize()#1149
Shivanshu-07 wants to merge 1 commit intomasterfrom
PER-7348-readiness-in-serialize

Conversation

@Shivanshu-07
Copy link
Copy Markdown

Summary

Adds Pattern C (in-browser) readiness gate ahead of PercyDOM.serialize() per PER-7348.

Pairs with: percy/cli#2184

Behavior

  • Before serialize, the SDK calls PercyDOM.waitForReady(readinessConfig) — async — and awaits the promise.
  • typeof PercyDOM.waitForReady === 'function' guard preserves backward compatibility with older CLI builds that don't ship the readiness API.
  • readiness.preset === 'disabled' short-circuits — waitForReady is not called.
  • If waitForReady rejects, the SDK logs at debug level and proceeds to serialize() so snapshot capture is never blocked.
  • Diagnostics returned by waitForReady are attached to domSnapshot.readiness_diagnostics so the CLI can log timing and pass/fail.
  • Readiness config resolves from per-snapshot options.readiness first, then utils.percy.config.snapshot.readiness from .percy.yml.

PercyDOM.serialize() itself is unchanged — still synchronous, called with the same options as today.

SDK-visible contract

// New — readiness step (skipped on old CLI / disabled preset)
if (preset !== 'disabled' && typeof window.PercyDOM?.waitForReady === 'function') {
  diagnostics = await window.PercyDOM.waitForReady(config);
}

// Unchanged
let domSnapshot = window.PercyDOM.serialize({ ...options });
if (diagnostics) domSnapshot.readiness_diagnostics = diagnostics;

Test plan

QUnit acceptance tests added to tests/acceptance/index-test.js under a readiness gate (PER-7348) module:

  • waitForReady is called before serialize when CLI exposes it
  • Backward compat — only serialize runs when waitForReady is absent
  • readiness.preset: disabled skips waitForReady
  • When waitForReady rejects, serialize still runs
  • Diagnostics returned by waitForReady are attached to domSnapshot.readiness_diagnostics

⚠️ Unit tests written but not executed locally (missing ember-cli toolchain in the fan-out environment). CI will exercise them.

Smoke test against example-percy-ember was not run as part of this fan-out.

🤖 Generated with Claude Code

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant