Avoid irrelevant scroll-action searches in Mac snapshots (#24731)

Check the current pure action name before searching for vertical scroll actions in the same immutable array.
This commit is contained in:
Neil
2026-10-03 00:14:03 -07:00
committed by GitHub
parent 9e11375a67
commit 832caea15d
2 changed files with 30 additions and 2 deletions
@@ -109,8 +109,8 @@ public enum SnapshotRenderHeuristics {
return action != "AXCancel" && action != "AXPick"
}
if role == "AXScrollArea",
(rawActions.contains("AXScrollUpByPage") || rawActions.contains("AXScrollDownByPage")),
action == "AXScrollLeftByPage" || action == "AXScrollRightByPage" {
action == "AXScrollLeftByPage" || action == "AXScrollRightByPage",
(rawActions.contains("AXScrollUpByPage") || rawActions.contains("AXScrollDownByPage")) {
return false
}
return true
@@ -74,6 +74,34 @@ final class SnapshotRenderingTests: XCTestCase {
XCTAssertEqual(SnapshotRenderHeuristics.meaningfulActions(node.rawActions, role: node.role), ["AXScrollUpByPage", "AXScrollDownByPage"])
}
func testKeepsHorizontalOnlyActionsInTheirOriginalOrder() {
let actions = ["AXScrollRightByPage", "AXPress", "AXScrollLeftByPage", "AXScrollRightByPage"]
let node = SnapshotRenderNode(role: "AXScrollArea", rawActions: actions)
XCTAssertEqual(
SnapshotRenderHeuristics.meaningfulActions(actions, role: node.role),
["AXScrollRightByPage", "AXScrollLeftByPage", "AXScrollRightByPage"]
)
XCTAssertEqual(
SnapshotRenderHeuristics.line(index: 2, node: node),
"2 scroll area, Secondary Actions: scroll right, scroll left, scroll right"
)
}
func testKeepsMixedScrollActionsOutsideScrollAreas() {
let actions = ["AXScrollLeftByPage", "AXScrollDownByPage", "AXScrollRightByPage", "AXCancel"]
let node = SnapshotRenderNode(role: "AXMenu", rawActions: actions)
XCTAssertEqual(
SnapshotRenderHeuristics.meaningfulActions(actions, role: node.role),
["AXScrollLeftByPage", "AXScrollDownByPage", "AXScrollRightByPage"]
)
XCTAssertEqual(
SnapshotRenderHeuristics.line(index: 3, node: node),
"3 menu, Secondary Actions: scroll left, scroll down, scroll right"
)
}
func testTextFieldsKeepDistinctValueAndPlaceholder() {
let node = SnapshotRenderNode(
role: "AXTextField",