Commit 39e6deb
feat: PER-7348 add waitForReady() call before serialize() (#308)
* feat: PER-7348 add waitForReady() call before serialize()
Adds the readiness gate from percy/cli#2184. New waitForReady() helper
runs PercyDOM.waitForReady via executeAsyncScript (callback signal)
before the existing PercyDOM.serialize executeScript inside
getSerializedDOM. Diagnostics are attached to the mutable snapshot as
readiness_diagnostics. serialize is unchanged.
Config precedence: options['readiness'] > cliConfig.snapshot.readiness >
empty. Backward compat via in-browser typeof guard. Disabled preset
short-circuits. Graceful on exception.
Visibility: getSerializedDOM is now package-private so tests can call it
directly; it was previously private.
Tests (Mockito): diagnostics attached + readiness script contains
waitForReady, disabled preset skips executeAsyncScript, readiness throw
leaves serialize intact. Local: mvn test → 3 passed, 0 failed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix: address ce:review findings on readiness gate (PER-7348)
- Replaced exclusive precedence (`else if`) with shallow-merge in a new
`resolveReadinessConfig()` helper. Per-snapshot keys win, global keys
inherited — a partial per-snapshot override no longer silently drops
a global `preset: disabled` kill switch.
- Set driver script timeout to match `readiness.timeoutMs` (+ 2s buffer)
around the executeAsyncScript call, with finally-restore. WebDriver's
default ~30s script timeout was silently capping higher user-configured
readiness timeouts via ScriptTimeoutException.
- Strip `readiness` from `buildSnapshotJS` (so it doesn't leak into
PercyDOM.serialize args) and from `postSnapshot` JSON (so it doesn't
round-trip to the CLI which already has it via healthcheck).
`mvn compile` passes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ci: retrigger CI after upstream maven central resolution issue (PER-7348)
* chore: bump @percy/cli to ^1.31.15-beta.0 in tests (PER-7348)
CLI 1.31.15-beta.0 ships PercyDOM.waitForReady (the readiness gate). The SDK changes in this PR call waitForReady end-to-end in tests; old CLI pins (1.30.9, 1.31.10) don't have it, causing the typeof guard's done() callback path to never quite settle in geckodriver's async-script handling. Bump so tests run against a CLI that actually has the feature.
* comments: remove JIRA ticket reference from code comments
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9d7f79c commit 39e6deb
3 files changed
Lines changed: 178 additions & 2 deletions
File tree
- src
- main/java/io/percy/selenium
- test/java/io/percy/selenium
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
567 | 571 | | |
568 | 572 | | |
569 | 573 | | |
| |||
614 | 618 | | |
615 | 619 | | |
616 | 620 | | |
| 621 | + | |
| 622 | + | |
617 | 623 | | |
618 | 624 | | |
619 | 625 | | |
620 | 626 | | |
621 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
622 | 714 | | |
623 | 715 | | |
624 | 716 | | |
| |||
694 | 786 | | |
695 | 787 | | |
696 | 788 | | |
697 | | - | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
698 | 793 | | |
699 | 794 | | |
700 | 795 | | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
701 | 801 | | |
702 | 802 | | |
703 | 803 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1109 | 1109 | | |
1110 | 1110 | | |
1111 | 1111 | | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1112 | 1188 | | |
1113 | 1189 | | |
1114 | 1190 | | |
| |||
0 commit comments