@@ -99,11 +99,7 @@ class GitHubTests: XCTestCase {
99
99
100
100
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false )
101
101
let window = app. windows [ " Pipelines " ]
102
- let sheet = window. sheets. firstMatch
103
-
104
- // Navigate to add workflow sheet
105
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
106
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
102
+ let sheet = openAddGitHubPipelineSheet ( app: app)
107
103
108
104
// Enter owner
109
105
sheet. textFields [ " Owner field " ] . click ( )
@@ -155,11 +151,7 @@ class GitHubTests: XCTestCase {
155
151
156
152
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false )
157
153
let window = app. windows [ " Pipelines " ]
158
- let sheet = window. sheets. firstMatch
159
-
160
- // Navigate to add workflow sheet
161
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
162
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
154
+ let sheet = openAddGitHubPipelineSheet ( app: app)
163
155
164
156
// Enter owner
165
157
sheet. textFields [ " Owner field " ] . click ( )
@@ -202,11 +194,7 @@ class GitHubTests: XCTestCase {
202
194
203
195
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false )
204
196
let window = app. windows [ " Pipelines " ]
205
- let sheet = window. sheets. firstMatch
206
-
207
- // Navigate to add workflow sheet
208
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
209
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
197
+ let sheet = openAddGitHubPipelineSheet ( app: app)
210
198
211
199
// Enter owner
212
200
sheet. textFields [ " Owner field " ] . click ( )
@@ -231,7 +219,7 @@ class GitHubTests: XCTestCase {
231
219
XCTAssertEqual ( " main " , branchParam)
232
220
}
233
221
234
- func testAddGitHubPipelinePrivateRepos ( ) throws {
222
+ func testFindsPrivateReposForUser ( ) throws {
235
223
webapp. router. get ( " /users/erikdoe " ) { _ in
236
224
try TestHelper . contentsOfFile ( " GitHubUserResponse.json " )
237
225
}
@@ -243,23 +231,17 @@ class GitHubTests: XCTestCase {
243
231
}
244
232
245
233
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false , token: " TEST-TOKEN " )
246
- let window = app. windows [ " Pipelines " ]
247
- let sheet = window. sheets. firstMatch
248
-
249
- // Navigate to add workflow sheet
250
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
251
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
234
+ let sheet = openAddGitHubPipelineSheet ( app: app)
252
235
253
236
// Make sure the token is shown
254
237
let tokenField = sheet. textFields [ " Token field " ]
255
238
XCTAssertEqual ( " TEST-TOKEN " , tokenField. value as? String )
256
239
257
240
// Enter owner and wait for the repo list to load
258
- let ownerField = sheet. textFields [ " Owner field " ]
259
- ownerField. click ( )
241
+ sheet. textFields [ " Owner field " ] . click ( )
260
242
sheet. typeText ( " erikdoe " + " \n " )
261
243
262
- // Make sure that the repositories are loaded and sorted
244
+ // Make sure that the repositories are loaded
263
245
let repositoryBox = sheet. comboBoxes [ " Repository combo box " ]
264
246
expectation ( for: NSPredicate ( format: " value == 'ccmenu' " ) , evaluatedWith: repositoryBox)
265
247
waitForExpectations ( timeout: 2 )
@@ -274,6 +256,27 @@ class GitHubTests: XCTestCase {
274
256
XCTAssertTrue ( repositoryBox. textFields [ " jekyll-site-test " ] . exists)
275
257
}
276
258
259
+ func testRetrievesReposForOrg( ) throws {
260
+ webapp. router. get ( " /users/ccmenu " ) { _ in
261
+ try TestHelper . contentsOfFile ( " GitHubUserOrgResponse.json " )
262
+ }
263
+ webapp. router. get ( " /orgs/ccmenu/repos " ) { _ in
264
+ try TestHelper . contentsOfFile ( " GitHubReposByOrgResponse.json " )
265
+ }
266
+
267
+ let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false )
268
+ let sheet = openAddGitHubPipelineSheet ( app: app)
269
+
270
+ // Enter owner
271
+ sheet. textFields [ " Owner field " ] . click ( )
272
+ sheet. typeText ( " ccmenu " + " \n " )
273
+
274
+ // Make sure that the repositories and workflows are loaded and the default display name is set
275
+ let repositoryBox = sheet. comboBoxes [ " Repository combo box " ]
276
+ expectation ( for: NSPredicate ( format: " value == 'ccmenu' " ) , evaluatedWith: repositoryBox)
277
+ waitForExpectations ( timeout: 3 )
278
+ }
279
+
277
280
func testShowsRateLimitExceededForRepositories( ) throws {
278
281
webapp. router. get ( " /users/erikdoe " , options: . editResponse) { r -> String in
279
282
r. response. status = . forbidden
@@ -282,12 +285,7 @@ class GitHubTests: XCTestCase {
282
285
}
283
286
284
287
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false )
285
- let window = app. windows [ " Pipelines " ]
286
- let sheet = window. sheets. firstMatch
287
-
288
- // Navigate to add workflow sheet
289
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
290
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
288
+ let sheet = openAddGitHubPipelineSheet ( app: app)
291
289
292
290
// Enter owner
293
291
sheet. textFields [ " Owner field " ] . click ( )
@@ -310,16 +308,10 @@ class GitHubTests: XCTestCase {
310
308
}
311
309
312
310
let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " )
313
- let window = app. windows [ " Pipelines " ]
314
- let sheet = window. sheets. firstMatch
315
-
316
- // Navigate to add workflow sheet
317
- window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
318
- window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
311
+ let sheet = openAddGitHubPipelineSheet ( app: app)
319
312
320
313
// Enter owner and wait for the repo list to load
321
- let ownerField = sheet. textFields [ " Owner field " ]
322
- ownerField. click ( )
314
+ sheet. textFields [ " Owner field " ] . click ( )
323
315
sheet. typeText ( " erikdoe " ) // Note: not pressing return here
324
316
325
317
// Make sure that the repositories are loaded and sorted
@@ -330,9 +322,18 @@ class GitHubTests: XCTestCase {
330
322
// Now press return and wait for a little while
331
323
sheet. typeText ( " \n " )
332
324
Thread . sleep ( forTimeInterval: 1 )
333
-
325
+
334
326
// Assert that no further fetch occured
335
327
XCTAssertEqual ( 1 , fetchCount)
328
+
329
+ }
330
+
331
+ private func openAddGitHubPipelineSheet( app: XCUIApplication ) -> XCUIElement {
332
+ let window = app. windows [ " Pipelines " ]
333
+ let sheet = window. sheets. firstMatch
334
+ window. toolbars. popUpButtons [ " Add pipeline menu " ] . click ( )
335
+ window. toolbars. menuItems [ " Add GitHub Actions workflow... " ] . click ( )
336
+ return sheet
336
337
}
337
338
338
339
}
0 commit comments