Skip to content

Commit 5ec65af

Browse files
aryanku-devclaude
andcommitted
test: retarget removed processFrame check at processFrameTree
The legacy processFrame(WebElement, Map) helper was removed as dead code once processFrameTree subsumed it. The reflection-based unit test still called the old name and failed with NoSuchMethodException in CI. Rewrite it to drive the same skip-when-percyElementId-missing path through processFrameTree, asserting an empty result and that the driver is never switched into the frame. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5641a88 commit 5ec65af

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,16 +784,35 @@ public void skipsSameOriginIframeInSerializedDom() throws Exception {
784784
}
785785

786786
@Test
787-
public void processFrameReturnsNullWhenPercyElementIdMissing() throws Exception {
787+
public void processFrameTreeSkipsFrameWhenPercyElementIdMissing() throws Exception {
788788
RemoteWebDriver mockedDriver = mock(RemoteWebDriver.class);
789789
Percy mockedPercy = spy(new Percy(mockedDriver));
790790

791791
WebElement iframe = mock(WebElement.class);
792792
when(iframe.getAttribute("src")).thenReturn("https://cdn.other.com/frame");
793793
when(iframe.getAttribute("data-percy-element-id")).thenReturn(null);
794794

795-
Object result = invokePrivate(mockedPercy, "processFrame", new Class[]{WebElement.class, Map.class}, iframe, new HashMap<String, Object>());
796-
assertNull(result);
795+
// processFrameTree takes (WebElement, int depth, Set<String> ancestorUrls,
796+
// Map<String, Object> ctx). Build the minimal ctx the method reads before
797+
// bailing on the missing data-percy-element-id attribute.
798+
Map<String, Object> ctx = new HashMap<String, Object>();
799+
ctx.put("options", new HashMap<String, Object>());
800+
ctx.put("maxFrameDepth", 5);
801+
ctx.put("ignoreSelectors", Collections.emptyList());
802+
803+
@SuppressWarnings("unchecked")
804+
List<Map<String, Object>> result = (List<Map<String, Object>>) invokePrivate(
805+
mockedPercy,
806+
"processFrameTree",
807+
new Class[]{WebElement.class, int.class, Set.class, Map.class},
808+
iframe,
809+
1,
810+
new HashSet<String>(),
811+
ctx
812+
);
813+
814+
assertNotNull(result);
815+
assertTrue(result.isEmpty());
797816
verify(mockedDriver, never()).switchTo();
798817
}
799818

0 commit comments

Comments
 (0)