88 * SPDX-License-Identifier: EPL-2.0
99 **********************************************************************/
1010
11- import {
12- ActivityBar ,
13- ContextMenu ,
14- InputBox ,
15- Key ,
16- Locators ,
17- NewScmView ,
18- SingleScmProvider ,
19- ViewControl ,
20- ViewSection
21- } from 'monaco-page-objects' ;
11+ import { ActivityBar , ContextMenu , Key , Locators , NewScmView , SingleScmProvider , ViewControl , ViewSection } from 'monaco-page-objects' ;
2212import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests' ;
2313import { CLASSES , TYPES } from '../../configs/inversify.types' ;
2414import { e2eContainer } from '../../configs/inversify.config' ;
@@ -36,6 +26,8 @@ import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
3626import { Logger } from '../../utils/Logger' ;
3727import { DriverHelper } from '../../utils/DriverHelper' ;
3828import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader' ;
29+ import { ViewsMoreActionsButton } from '../../pageobjects/ide/ViewsMoreActionsButton' ;
30+ import { SourceControlView } from '../../pageobjects/ide/SourceControlView' ;
3931
4032suite ( `The SshUrlNoOauthPatFactory userstory ${ BASE_TEST_CONSTANTS . TEST_ENVIRONMENT } ` , function ( ) : void {
4133 const projectAndFileTests : ProjectAndFileTests = e2eContainer . get ( CLASSES . ProjectAndFileTests ) ;
@@ -47,7 +39,8 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
4739 const dashboard : Dashboard = e2eContainer . get ( CLASSES . Dashboard ) ;
4840 const testWorkspaceUtil : ITestWorkspaceUtil = e2eContainer . get ( TYPES . WorkspaceUtil ) ;
4941 const cheCodeLocatorLoader : CheCodeLocatorLoader = e2eContainer . get ( CLASSES . CheCodeLocatorLoader ) ;
50-
42+ const viewsMoreActionsButton : ViewsMoreActionsButton = e2eContainer . get ( CLASSES . ViewsMoreActionsButton ) ;
43+ const sourceControlView : SourceControlView = e2eContainer . get ( CLASSES . SourceControlView ) ;
5144 const webCheCodeLocators : Locators = cheCodeLocatorLoader . webCheCodeLocators ;
5245
5346 const factoryUrl : string =
@@ -70,7 +63,6 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
7063 const refreshButtonLabel : string = 'Refresh' ;
7164 const pushItemLabel : string = 'Push' ;
7265 let testRepoProjectName : string ;
73- const isPrivateRepo : string = FACTORY_TEST_CONSTANTS . TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO ? 'private' : 'public' ;
7466
7567 async function deleteSshKeys ( ) : Promise < void > {
7668 Logger . debug ( 'Deleting SSH keys if they are present' ) ;
@@ -117,28 +109,31 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
117109 . undefined ;
118110 } ) ;
119111 test ( 'Accept the project as a trusted one' , async function ( ) : Promise < void > {
120- await projectAndFileTests . performTrustAuthorDialog ( ) ;
112+ await projectAndFileTests . performTrustDialogs ( ) ;
113+ // it needs to wait here for the Trust dialogs to be closed and the Editor to be ready
114+ await driverHelper . wait ( 5000 ) ;
121115 } ) ;
122116 test ( 'Check the project files was imported' , async function ( ) : Promise < void > {
123117 expect (
124118 await projectAndFileTests . getProjectTreeItem ( projectSection , BASE_TEST_CONSTANTS . TS_SELENIUM_PROJECT_ROOT_FILE_NAME ) ,
125119 'Project files were not imported'
126120 ) . not . undefined ;
127- testRepoProjectName = StringUtil . getProjectNameFromGitUrl ( FACTORY_TEST_CONSTANTS . TS_SELENIUM_FACTORY_GIT_REPO_URL ) ;
121+ testRepoProjectName = StringUtil . getProjectNameFromGitUrl ( factoryUrl ) ;
128122 } ) ;
129123
130124 test ( 'Make changes to the file' , async function ( ) : Promise < void > {
131125 Logger . debug ( `projectSection.openItem: "${ fileToChange } "` ) ;
132126 await projectSection . openItem ( testRepoProjectName , fileToChange ) ;
133127 await driverHelper . waitVisibility ( webCheCodeLocators . Editor . inputArea ) ;
134128 await driverHelper . getDriver ( ) . findElement ( webCheCodeLocators . Editor . inputArea ) . click ( ) ;
129+ await driverHelper . wait ( 1000 ) ;
135130
136131 Logger . debug ( 'Clearing the editor with Ctrl+A' ) ;
137132 await driverHelper . getDriver ( ) . actions ( ) . keyDown ( Key . CONTROL ) . sendKeys ( 'a' ) . keyUp ( Key . CONTROL ) . perform ( ) ;
138- await driverHelper . wait ( 500 ) ;
133+ await driverHelper . wait ( 1000 ) ;
139134 Logger . debug ( 'Deleting selected text' ) ;
140135 await driverHelper . getDriver ( ) . actions ( ) . sendKeys ( Key . DELETE ) . perform ( ) ;
141- await driverHelper . wait ( 500 ) ;
136+ await driverHelper . wait ( 1000 ) ;
142137 Logger . debug ( `Entering text: "${ changesToCommit } "` ) ;
143138 await driverHelper . getDriver ( ) . actions ( ) . sendKeys ( changesToCommit ) . perform ( ) ;
144139 } ) ;
@@ -167,6 +162,57 @@ suite(`The SshUrlNoOauthPatFactory userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONM
167162 expect ( changes ) . eql ( 1 ) ;
168163 } ) ;
169164
165+ test ( 'Stage the changes' , async function ( ) : Promise < void > {
166+ await driverHelper . waitVisibility ( webCheCodeLocators . ScmView . more ) ;
167+ viewsActionsButton = await viewsMoreActionsButton . viewsAndMoreActionsButtonIsVisible ( ) ;
168+ if ( viewsActionsButton ) {
169+ await viewsMoreActionsButton . closeSourceControlGraph ( ) ;
170+ }
171+ scmContextMenu = await scmProvider . openMoreActions ( ) ;
172+ await driverHelper . waitVisibility ( webCheCodeLocators . ContextMenu . contextView ) ;
173+ Logger . debug ( 'scmContextMenu.select: "Changes" -> "Stage All Changes"' ) ;
174+ await scmContextMenu . select ( 'Changes' , 'Stage All Changes' ) ;
175+ } ) ;
176+
177+ test ( 'Commit the changes' , async function ( ) : Promise < void > {
178+ Logger . info ( `ScmView inputField locator: "${ ( webCheCodeLocators . ScmView as any ) . scmEditor } "` ) ;
179+ Logger . debug ( 'Click on the Scm Editor' ) ;
180+ await driverHelper
181+ . getDriver ( )
182+ . findElement ( ( webCheCodeLocators . ScmView as any ) . scmEditor )
183+ . click ( ) ;
184+ await sourceControlView . typeCommitMessage ( changesToCommit ) ;
185+ await driverHelper . waitVisibility ( webCheCodeLocators . ScmView . more ) ;
186+ await driverHelper . wait ( timeToRefresh ) ;
187+ Logger . debug ( `wait and click on: "${ refreshButtonLabel } "` ) ;
188+ await driverHelper . waitAndClick ( webCheCodeLocators . ScmView . actionConstructor ( refreshButtonLabel ) ) ;
189+ // wait while changes counter will be refreshed
190+ await driverHelper . wait ( timeToRefresh ) ;
191+ const changes : number = await scmProvider . getChangeCount ( ) ;
192+ Logger . debug ( `scmProvider.getChangeCount: number of changes is "${ changes } "` ) ;
193+ expect ( changes ) . eql ( 0 ) ;
194+ } ) ;
195+
196+ test ( 'Push the changes and check if the changes were pushed' , async function ( ) : Promise < void > {
197+ await driverHelper . waitVisibility ( webCheCodeLocators . Notification . action ) ;
198+ await driverHelper . waitVisibility ( webCheCodeLocators . ScmView . more ) ;
199+ Logger . debug ( 'scmProvider.openMoreActions' ) ;
200+ scmContextMenu = await scmProvider . openMoreActions ( ) ;
201+ await driverHelper . waitVisibility ( webCheCodeLocators . ContextMenu . itemConstructor ( pushItemLabel ) ) ;
202+ Logger . debug ( `scmContextMenu.select: "${ pushItemLabel } "` ) ;
203+ await scmContextMenu . select ( pushItemLabel ) ;
204+
205+ await driverHelper . waitVisibility ( webCheCodeLocators . ScmView . more ) ;
206+ await driverHelper . wait ( timeToRefresh ) ;
207+ Logger . debug ( `wait and click on: "${ refreshButtonLabel } "` ) ;
208+ await driverHelper . waitAndClick ( webCheCodeLocators . ScmView . actionConstructor ( refreshButtonLabel ) ) ;
209+ const isCommitButtonDisabled : string = await driverHelper . waitAndGetElementAttribute (
210+ webCheCodeLocators . Notification . action ,
211+ 'aria-disabled'
212+ ) ;
213+ expect ( isCommitButtonDisabled ) . to . equal ( 'true' ) ;
214+ } ) ;
215+
170216 suiteTeardown ( 'Delete SSH keys' , async function ( ) : Promise < void > {
171217 await dashboard . openDashboard ( ) ;
172218 await deleteSshKeys ( ) ;
0 commit comments