@@ -39,6 +39,25 @@ final class ProjectNavigatorUITests: XCTestCase {
3939 XCTAssertTrue ( readmeEditor. exists)
4040 XCTAssertNotNil ( readmeEditor. value as? String )
4141
42+ let cursorPositionLabel = window. staticTexts [ " CursorPositionLabel " ]
43+ XCTAssertTrue ( cursorPositionLabel. waitForExistence ( timeout: 2.0 ) , " Cursor position label not found " )
44+ assertResolvedCursorPosition ( cursorPositionLabel)
45+
46+ let licenseRow = Query . Navigator. getProjectNavigatorRow ( fileTitle: " LICENSE.md " , navigator)
47+ XCTAssertFalse ( Query . Navigator. rowContainsDisclosureIndicator ( licenseRow) , " File has disclosure indicator " )
48+ licenseRow. click ( )
49+
50+ let licenseTab = Query . TabBar. getTab ( labeled: " LICENSE.md " , tabBar)
51+ XCTAssertTrue ( licenseTab. exists)
52+
53+ let licenseEditor = Query . Window. getFirstEditor ( window)
54+ let licenseContent = NSPredicate ( format: " value CONTAINS %@ " , " MIT License " )
55+ expectation ( for: licenseContent, evaluatedWith: licenseEditor)
56+ waitForExpectations ( timeout: 2.0 )
57+
58+ assertResolvedCursorPosition ( cursorPositionLabel)
59+ assertCursorPositionChanges ( in: licenseEditor, cursorPositionLabel)
60+
4261 let rowCount = navigator. descendants ( matching: . outlineRow) . count
4362
4463 // Open a folder
@@ -59,4 +78,41 @@ final class ProjectNavigatorUITests: XCTestCase {
5978 XCTAssertTrue ( newRowCount > finalRowCount, " Rows were not hidden after closing a folder " )
6079 XCTAssertEqual ( rowCount, finalRowCount, " Different Number of rows loaded " )
6180 }
81+
82+ private func assertResolvedCursorPosition( _ cursorPositionLabel: XCUIElement ) {
83+ let resolvedCursorPosition = NSPredicate (
84+ format: " value CONTAINS %@ AND NOT value CONTAINS %@ " ,
85+ " Line: " ,
86+ " -1 "
87+ )
88+ expectation ( for: resolvedCursorPosition, evaluatedWith: cursorPositionLabel)
89+ waitForExpectations ( timeout: 2.0 )
90+ }
91+
92+ private func assertCursorPositionChanges( in editor: XCUIElement , _ cursorPositionLabel: XCUIElement ) {
93+ assertCursorPositionChanges ( cursorPositionLabel) {
94+ editor. coordinate ( withNormalizedOffset: CGVector ( dx: 0.15 , dy: 0.15 ) ) . click ( )
95+ }
96+ assertCursorPositionChanges ( cursorPositionLabel) {
97+ editor. coordinate ( withNormalizedOffset: CGVector ( dx: 0.75 , dy: 0.75 ) ) . click ( )
98+ }
99+ }
100+
101+ private func assertCursorPositionChanges( _ cursorPositionLabel: XCUIElement , after action: ( ) -> Void ) {
102+ guard let originalValue = cursorPositionLabel. value as? String else {
103+ XCTFail ( " Cursor position label value not found " )
104+ return
105+ }
106+
107+ action ( )
108+
109+ let updatedCursorPosition = NSPredicate (
110+ format: " value CONTAINS %@ AND NOT value CONTAINS %@ AND value != %@ " ,
111+ " Line: " ,
112+ " -1 " ,
113+ originalValue
114+ )
115+ expectation ( for: updatedCursorPosition, evaluatedWith: cursorPositionLabel)
116+ waitForExpectations ( timeout: 2.0 )
117+ }
62118}
0 commit comments