feat: PER-7348 add waitForReady() call before serialize()#31
Draft
Shivanshu-07 wants to merge 1 commit intomainfrom
Draft
feat: PER-7348 add waitForReady() call before serialize()#31Shivanshu-07 wants to merge 1 commit intomainfrom
Shivanshu-07 wants to merge 1 commit intomainfrom
Conversation
Adds the readiness gate from percy/cli#2184. New waitForReady() helper runs PercyDOM.waitForReady before the existing PercyDOM.serialize page.evaluate inside getSerializedDOM. Playwright auto-awaits the returned Promise. Diagnostics are attached to the mutable domSnapshot as readiness_diagnostics so the CLI can log timing and pass/fail. Config precedence: options['readiness'] > cliConfig.snapshot.readiness > empty (CLI applies balanced default). Backward compat via in-browser typeof PercyDOM.waitForReady === 'function' guard. Disabled preset short-circuits. Any exception is swallowed at debug level. Tests (Mockito): diagnostics attached + readiness JS sent, disabled preset skips the evaluate, and readiness throw leaves the serialize path intact. Local: mvn test → 3 passed, 0 failed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopts the readiness gate from percy/cli#2184 (PER-7348). New
waitForReady(options)helper runsPercyDOM.waitForReady(config)viapage.evaluateinsidegetSerializedDOM. Playwright auto-awaits the returned Promise. The result (readiness diagnostics) is attached to the mutabledomSnapshotmap asreadiness_diagnostics. ThePercyDOM.serializecall is unchanged.Contract
options["readiness"]→cliConfig.snapshot.readiness→ empty (CLI appliesbalanceddefault)typeof PercyDOM.waitForReady === 'function'guardpage.evaluateat all)Tests
Three new tests in
SDKTestusing Mockito:readiness: { preset: 'disabled' }→ no 2-arg evaluate, no diagnosticsTest results
mvn compile+test-compile)mvn test -Dtest=...)Related