@@ -27,13 +27,84 @@ final class NavigatorDemoUITests: XCTestCase {
2727
2828 let app = XCUIApplication ( )
2929 app. activate ( )
30- app/*@START_MENU_TOKEN@*/ . menuBarItems [ " File " ] /*[[".menuBarItems",".containing(.menuItem, identifier: \"Open Recent\")",".containing(.menuItem, identifier: \"openDocument:\")",".containing(.menuItem, identifier: \"newDocument:\")",".menuBars.menuBarItems[\"File\"]",".menuBarItems[\"File\"]"],[[[-1,5],[-1,4],[-1,0,1]],[[-1,3],[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/ . firstMatch. click ( )
31- app/*@START_MENU_TOKEN@*/ . menuItems [ " newDocument: " ] /*[[".menus",".menuItems[\"New\"]",".menuItems[\"newDocument:\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/ . firstMatch. click ( )
30+ app. menuBarItems [ " File " ] . firstMatch. click ( )
31+ app. menuItems [ " newDocument: " ] . firstMatch. click ( )
3232
33- XCTAssertTrue ( app. staticTexts [ " Untitled " ] . waitForExistence ( timeout: 3 ) , " Untitled document exists " )
33+ XCTAssertTrue ( app. staticTexts [ " Untitled " ] . waitForExistence ( timeout: 2 ) , " Untitled document exists " )
3434
35- app/*@START_MENU_TOKEN@*/. buttons [ " MyText.txt " ] /*[[".cells.buttons[\"MyText.txt\"]",".buttons[\"MyText.txt\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/. firstMatch. click ( )
36- app/*@START_MENU_TOKEN@*/. outlines [ " Sidebar " ] . firstMatch/*[[".scrollViews.outlines[\"Sidebar\"].firstMatch",".outlines",".containing(.outlineRow, identifier: nil).firstMatch",".firstMatch",".outlines[\"Sidebar\"].firstMatch"],[[[-1,4],[-1,1,1],[-1,0]],[[-1,3],[-1,2]]],[0]]@END_MENU_TOKEN@*/. typeKey ( " q " , modifierFlags: . command)
35+ app. buttons [ " MyText.txt " ] . firstMatch. click ( )
36+
37+ app. outlines [ " Sidebar " ] . firstMatch. typeKey ( " q " , modifierFlags: . command)
38+ }
39+
40+ @MainActor
41+ func testNewFile( ) throws {
42+ let app = XCUIApplication ( )
43+ app. activate ( )
44+ app. menuBarItems [ " File " ] . firstMatch. click ( )
45+ app. menuItems [ " newDocument: " ] . firstMatch. click ( )
46+
47+ _ = app. buttons [ " Untitled " ] . waitForExistence ( timeout: 2 )
48+ app. buttons [ " Untitled " ] . firstMatch. rightClick ( )
49+ app. menuItems [ " doc.badge.plus " ] . firstMatch. click ( )
50+
51+ let element = app. cells. containing ( . group, identifier: nil ) . firstMatch
52+ element. typeKey ( . leftArrow, modifierFlags: . function)
53+ element. typeKey ( . rightArrow, modifierFlags: [ . shift, . function] )
54+ element. typeKey ( . rightArrow, modifierFlags: [ . shift, . function] )
55+ element. typeKey ( . rightArrow, modifierFlags: [ . shift, . function] )
56+ element. typeKey ( . rightArrow, modifierFlags: [ . shift, . function] )
57+ element. typeText ( " Test \r " )
58+
59+ XCTAssertTrue ( app. buttons [ " Test.txt " ] . waitForExistence ( timeout: 2 ) , " Test.txt file exists " )
60+
61+ app. outlines [ " Sidebar " ] . firstMatch. typeKey ( " q " , modifierFlags: . command)
62+ }
63+
64+ @MainActor
65+ func testTwoNewFiles( ) throws {
66+ let app = XCUIApplication ( )
67+ app. activate ( )
68+ app. menuBarItems [ " File " ] . firstMatch. click ( )
69+ app. menuItems [ " newDocument: " ] . firstMatch. click ( )
70+
71+ _ = app. buttons [ " Untitled " ] . waitForExistence ( timeout: 2 )
72+ app. buttons [ " Untitled " ] . firstMatch. rightClick ( )
73+ app. menuItems [ " doc.badge.plus " ] . firstMatch. click ( )
74+
75+ app. buttons [ " Untitled " ] . firstMatch. rightClick ( )
76+ app. menuItems [ " doc.badge.plus " ] . firstMatch. click ( )
77+
78+ app. cells. element ( boundBy: 0 ) . typeText ( " \r " )
79+ XCTAssertTrue ( app. buttons [ " Text1.txt " ] . waitForExistence ( timeout: 2 ) , " Text1.txt file exists " )
80+
81+ app. outlines [ " Sidebar " ] . firstMatch. typeKey ( " q " , modifierFlags: . command)
82+ }
83+
84+ @MainActor
85+ func testTwoNewDeleteOneFiles( ) throws {
86+ let app = XCUIApplication ( )
87+ app. activate ( )
88+ app. menuBarItems [ " File " ] . firstMatch. click ( )
89+ app. menuItems [ " newDocument: " ] . firstMatch. click ( )
90+
91+ _ = app. buttons [ " Untitled " ] . waitForExistence ( timeout: 2 )
92+ app. buttons [ " Untitled " ] . firstMatch. rightClick ( )
93+ app. menuItems [ " doc.badge.plus " ] . firstMatch. click ( )
94+
95+ app. buttons [ " Untitled " ] . firstMatch. rightClick ( )
96+ app. menuItems [ " doc.badge.plus " ] . firstMatch. click ( )
97+
98+ app. cells. element ( boundBy: 0 ) . typeText ( " \r " )
99+ XCTAssertTrue ( app. buttons [ " Text1.txt " ] . waitForExistence ( timeout: 2 ) , " Text1.txt file exists " )
100+
101+ app. buttons [ " Untitled " ] . firstMatch. click ( )
102+ app. buttons [ " Text1.txt " ] . firstMatch. rightClick ( )
103+ app/*@START_MENU_TOKEN@*/. menuItems [ " trash " ] /*[[".outlines.menuItems[\"Delete\"]",".menus.menuItems[\"trash\"]",".menuItems[\"trash\"]"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/. firstMatch. click ( )
104+
105+ XCTAssertTrue ( app. buttons [ " Text1.txt " ] . waitForNonExistence ( timeout: 3 ) , " Text1.txt doesn't exist (anymore) " )
106+
107+ app. outlines [ " Sidebar " ] . firstMatch. typeKey ( " q " , modifierFlags: . command)
37108 }
38109
39110// @MainActor
0 commit comments