@@ -59,7 +59,7 @@ class GitHubTests: XCTestCase {
5959 return try TestHelper . contentsOfFile ( " GitHubWorkflowRunsResponse.json " )
6060 }
6161
62- let app = TestHelper . launchApp ( pipelines: " GitHubPipelineLocalhost.json " , pauseMonitor: false )
62+ let app = TestHelper . launchApp ( pipelines: " GitHubPipelineLocalhost.json " , pauseMonitor: false , token : " TEST-TOKEN " )
6363 let window = app. windows [ " Pipelines " ]
6464
6565 // Make sure the update message shows that the limit was exceeded
@@ -128,6 +128,62 @@ class GitHubTests: XCTestCase {
128128 waitForExpectations ( timeout: 5 )
129129 }
130130
131+ func testAddsGitHubPrivatePipeline( ) throws {
132+ webapp. router. get ( " /users/erikdoe " ) { _ in
133+ try TestHelper . contentsOfFile ( " GitHubUserResponse.json " )
134+ }
135+ webapp. router. get ( " /users/erikdoe/repos " ) { _ in
136+ return " [] "
137+ }
138+ webapp. router. get ( " /user/repos " ) { _ in
139+ try TestHelper . contentsOfFile ( " GitHubReposByUserCCM2OnlyResponse.json " )
140+ }
141+ webapp. router. get ( " /repos/erikdoe/ccmenu2/actions/workflows " ) { _ in
142+ try TestHelper . contentsOfFile ( " GitHubWorkflowsResponse.json " )
143+ }
144+ webapp. router. get ( " /repos/erikdoe/ccmenu2/branches " ) { _ in
145+ try TestHelper . contentsOfFile ( " GitHubBranchesResponse.json " )
146+ }
147+ webapp. router. get ( " /repos/erikdoe/ccmenu2/actions/workflows/build-and-test.yaml/runs " , options: . editResponse) { r -> String in
148+ if r. headers [ " Authorization " ] . first != " Bearer TEST-TOKEN " {
149+ r. response. status = . notFound
150+ return " { \" message \" : \" Not found \" } "
151+ }
152+ return try TestHelper . contentsOfFile ( " GitHubWorkflowRunsResponse.json " )
153+ }
154+
155+ let app = TestHelper . launchApp ( pipelines: " EmptyPipelines.json " , pauseMonitor: false , token: " TEST-TOKEN " )
156+ let window = app. windows [ " Pipelines " ]
157+ let sheet = openAddGitHubPipelineSheet ( app: app)
158+
159+ // Enter owner
160+ sheet. textFields [ " Owner field " ] . click ( )
161+ sheet. typeText ( " erikdoe " + " \n " )
162+
163+ // Make sure that the repositories and workflows are loaded and the default display name is set
164+ let repositoryBox = sheet. comboBoxes [ " Repository combo box " ]
165+ expectation ( for: NSPredicate ( format: " value == 'ccmenu2' " ) , evaluatedWith: repositoryBox)
166+ let workflowPicker = sheet. popUpButtons [ " Workflow picker " ]
167+ expectation ( for: NSPredicate ( format: " value == 'Build and test' " ) , evaluatedWith: workflowPicker)
168+ let displayNameField = sheet. textFields [ " Display name field " ]
169+ expectation ( for: NSPredicate ( format: " value == 'ccmenu2 | Build and test' " ) , evaluatedWith: displayNameField)
170+ waitForExpectations ( timeout: 3 )
171+
172+ // Set a custom display name, and close the sheet
173+ displayNameField. click ( )
174+ sheet. typeKey ( " a " , modifierFlags: [ . command ] )
175+ sheet. typeText ( " CCMenu " )
176+ sheet. buttons [ " Apply " ] . click ( )
177+
178+ // Make sure the pipeline is shown, and that its status is fetched immediately
179+ let titleText = window. outlines. staticTexts [ " Pipeline title " ]
180+ expectation ( for: NSPredicate ( format: " value == 'CCMenu' " ) , evaluatedWith: titleText)
181+ let descriptionText = window. outlines. staticTexts [ " Status description " ]
182+ expectation ( for: NSPredicate ( format: " value CONTAINS 'Label: 42' " ) , evaluatedWith: descriptionText)
183+ waitForExpectations ( timeout: 5 )
184+ }
185+
186+
131187 func testAddsGitHubPipelineByIdIfNeccessary( ) throws {
132188 webapp. router. get ( " /users/erikdoe " ) { _ in
133189 try TestHelper . contentsOfFile ( " GitHubUserResponse.json " )
@@ -221,6 +277,8 @@ class GitHubTests: XCTestCase {
221277 XCTAssertEqual ( " main " , branchParam)
222278 }
223279
280+
281+
224282 func testFindsPrivateReposForUser( ) throws {
225283 webapp. router. get ( " /users/erikdoe " ) { _ in
226284 try TestHelper . contentsOfFile ( " GitHubUserResponse.json " )
0 commit comments