Skip to content

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

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

feat: PER-7348 add waitForReady() call before serialize()#30
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(driver, options) helper runs PercyDOM.waitForReady via driver.execute_async_script (callback signal) before the existing PercyDOM.serialize execute_script inside get_serialized_dom. The return value is attached to the snapshot hash as 'readiness_diagnostics'. Serialize is unchanged.

Contract

  • Config precedence: options[:readiness] / options['readiness']@cli_config.dig('snapshot','readiness'){} (CLI balanced default)
  • Backward compat: in-browser typeof PercyDOM.waitForReady === 'function' guard
  • Disabled preset short-circuits
  • Graceful on any StandardError; logged at debug

Tests

4 new RSpec tests inside describe '.get_serialized_dom':

  • ✅ happy path — execute_async_script called with waitForReady + typeof guard; diagnostics attached
  • ✅ per-snapshot config embedded in the script (JSON-escaped)
  • ✅ disabled preset skips execute_async_script
  • ✅ raised execute_async_script leaves serialize intact

Test results

Check Status Notes
Syntax (ruby -c) ✅ pass
Unit tests (bundle exec rspec) ⚠️ not executed locally bundle install needs capybara ~> 3.35; not present on fan-out machine
Smoke test ⚠️ skipped: toolchain missing

Related

Adds the readiness gate from percy/cli#2184. New wait_for_ready() helper
runs PercyDOM.waitForReady via driver.execute_async_script (callback
signal) before the existing PercyDOM.serialize execute_script inside
get_serialized_dom. The return value is attached to the domSnapshot
hash as 'readiness_diagnostics'. serialize is unchanged.

Config precedence: options[:readiness] (or 'readiness') >
@cli_config.dig('snapshot','readiness') > {} (CLI applies balanced
default). Backward compat via in-browser typeof guard. Disabled preset
skips the execute_async_script. Graceful on any StandardError.

Tests (RSpec): happy path (execute_async_script called with
waitForReady + typeof guard, diagnostics on snapshot), per-snapshot
config embedded, disabled preset skips execute_async_script, and
execute_async_script raising leaves serialize intact.

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