Skip to content

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

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

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

Conversation

@Shivanshu-07
Copy link
Copy Markdown

Summary

Adopts the readiness gate from percy/cli#2184 (PER-7348). New _wait_for_ready(page, kwargs) helper runs PercyDOM.waitForReady(config) via page.evaluate (sync Playwright auto-awaits Promises). Its return value is attached to dom_snapshot['readiness_diagnostics']. The PercyDOM.serialize call is unchanged.

Contract

  • Config precedence: kwargs['readiness'] → healthcheck-cached percy.config.snapshot.readiness{} (CLI applies balanced default).
  • Backward compat: in-browser typeof PercyDOM.waitForReady === 'function' guard.
  • Disabled preset skips the evaluate call. Graceful on any exception.

Tests

4 new tests in TestPercySnapshot: happy path (call order), config pass-through, disabled preset, readiness raising.

Test results

Check Status Notes
Syntax (python -c ast.parse) ✅ pass
Unit tests (make test) ⚠️ not executed locally Requires Chromium + Playwright-for-Python install
Smoke test ⚠️ skipped: toolchain missing

Related

Adds the readiness gate from percy/cli#2184. A new _wait_for_ready()
helper uses page.evaluate (sync Playwright auto-awaits Promises) with a
typeof guard so older CLI versions that lack waitForReady are no-ops.
The return value is attached to dom_snapshot['readiness_diagnostics'] so
the CLI can log timing and pass/fail. serialize itself is unchanged.

Config precedence: kwargs['readiness'] > healthcheck-cached
percy.config.snapshot.readiness > {} (CLI applies balanced default).
Disabled preset skips the evaluate call. Graceful on exception.

Tests cover happy path (call order), config pass-through, disabled
preset, and readiness raising.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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