Skip to content

Commit 4351a2d

Browse files
test: make percy-disabled and responsive-height tests CI-deterministic
The new PercyLogicTest cases passed locally (no Percy CLI) but failed on CI where `percy exec` runs a live CLI: - screenshotReturnsNullWhenPercyDisabled relied on isPercyEnabled defaulting to false; under percy exec the healthcheck enables it. Force isPercyEnabled =false via reflection so the disabled-path assertion is deterministic. - resolveResponsiveTargetHeightHonoursFeatureFlag's no-minHeight branch read cliConfig.snapshot.minHeight (1024 on CI). Clear cliConfig so it falls back to currentHeight as intended. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b271085 commit 4351a2d

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/test/java/io/percy/selenium/PercyLogicTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,23 @@ public void createRegionWithBoundingBoxAndPadding() {
125125
// ------------------------------------------------------------------
126126

127127
@Test
128-
public void snapshotReturnsNullWhenPercyDisabled() {
128+
public void snapshotReturnsNullWhenPercyDisabled() throws Exception {
129129
Percy percy = spy(new Percy(mock(RemoteWebDriver.class)));
130-
// isPercyEnabled defaults to false because no CLI is running locally.
130+
// Force the disabled state so the assertion holds regardless of whether a
131+
// live Percy CLI is running (e.g. under `percy exec` on CI).
132+
setField(percy, "isPercyEnabled", false);
131133
assertNull(percy.snapshot("disabled"));
132134
assertNull(percy.snapshot("disabled", Arrays.asList(800)));
133135
assertNull(percy.snapshot("disabled", Arrays.asList(800), 600));
134136
assertNull(percy.snapshot("disabled", new HashMap<String, Object>()));
135137
}
136138

137139
@Test
138-
public void screenshotReturnsNullWhenPercyDisabled() {
140+
public void screenshotReturnsNullWhenPercyDisabled() throws Exception {
139141
Percy percy = spy(new Percy(mock(RemoteWebDriver.class)));
142+
// Force the disabled state so the assertion holds regardless of whether a
143+
// live Percy CLI is running (e.g. under `percy exec` on CI).
144+
setField(percy, "isPercyEnabled", false);
140145
assertNull(percy.screenshot("disabled"));
141146
}
142147

@@ -369,6 +374,10 @@ public void resolveConfiguredMinHeightFromOptionsThenCliFallbackThenInvalid() th
369374
@Test
370375
public void resolveResponsiveTargetHeightHonoursFeatureFlag() throws Exception {
371376
Percy mockedPercy = spy(new Percy(mock(RemoteWebDriver.class)));
377+
// Clear any cliConfig that a live Percy CLI (e.g. `percy exec` on CI) may
378+
// have populated, so the "no minHeight anywhere" branch deterministically
379+
// falls back to currentHeight instead of reading cliConfig.snapshot.minHeight.
380+
setField(mockedPercy, "cliConfig", null);
372381
boolean originalFlag = getStaticBooleanField(Percy.class, "PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT");
373382
try {
374383
setStaticField(Percy.class, "PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT", false);

0 commit comments

Comments
 (0)