@@ -63,8 +63,19 @@ export class ApplicationsPage {
6363 await locator . press ( 'Enter' ) ;
6464 }
6565
66- async createApp ( appName : string , repoUrl : string , repoPath : string ) {
66+ async createApp ( appName : string , repoUrl : string , repoPath : string ) {
6767 await this . newAppButton . click ( ) ;
68+
69+ //handle the "failed to load data" banner if it appears inside the slide-out panel
70+ const errorBanner = this . page . getByText ( 'try again' ) ;
71+ try {
72+ //wait 3 secs
73+ await errorBanner . waitFor ( { state : 'visible' , timeout : 3000 } ) ;
74+ await errorBanner . click ( ) ;
75+ } catch ( error ) {
76+ //banner didn't appear so just continue
77+ }
78+
6879 await this . page . getByText ( 'Loading...' ) . first ( ) . waitFor ( { state : 'hidden' , timeout : 15000 } ) ;
6980
7081 await this . appNameInput . fill ( appName ) ;
@@ -82,31 +93,33 @@ export class ApplicationsPage {
8293 await this . createButton . click ( ) ;
8394 }
8495
85- async syncApplication ( appName : string , expectedResource : string = 'spring-petclinic' ) {
96+ async syncApplication ( appName : string , expectedResource : string = 'spring-petclinic' ) {
8697 //search for app
8798 await this . page . getByPlaceholder ( / S e a r c h a p p l i c a t i o n s / i) . fill ( appName ) ;
8899
89100 const appContainer = this . page . locator ( '.white-box, .argo-table-list__row' ) . filter ( { hasText : appName } ) ;
90101 await appContainer . waitFor ( { state : 'visible' , timeout : 20000 } ) ;
102+ await expect ( appContainer . getByText ( / O u t O f S y n c | O u t o f S y n c / i) . first ( ) ) . toBeVisible ( { timeout : 45000 } ) ;
103+ //safe to open the panel
91104 await appContainer . getByText ( 'Sync' , { exact : true } ) . click ( ) ;
92105
93- //slideout panel
94- // Wait for the manifests to fetch from Git and render on the panel
95- await expect ( this . page . getByText ( expectedResource ) . first ( ) ) . toBeVisible ( { timeout : 15000 } ) ;
96-
97- //click 'all' to ensure all resource checkboxes are ticked across all Argo CD versions
106+ //click 'all'
98107 const allLink = this . page . getByRole ( 'link' , { name : 'all' , exact : true } ) ;
99108 try {
100- await allLink . waitFor ( { state : 'visible' , timeout : 3000 } ) ;
109+ await allLink . waitFor ( { state : 'visible' , timeout : 5000 } ) ;
101110 await allLink . click ( ) ;
102111 } catch ( error ) {
103- //all link didn't appear within 3 sec
112+ // all link didn't appear within 5 sec
104113 }
114+
115+ //wait for the manifests to render on the panel
116+ await expect ( this . page . getByText ( expectedResource ) . first ( ) ) . toBeVisible ( { timeout : 30000 } ) ;
117+
105118 //click the main sync button
106119 await this . page . getByRole ( 'button' , { name : / ^ s y n c h r o n i z e $ / i } ) . first ( ) . click ( ) ;
107120
108- //wait for the panel to close
109- await expect ( this . page . getByText ( 'SYNCHRONIZE RESOURCES' ) ) . toBeHidden ( { timeout : 10000 } ) ;
121+ //wait for the panel to close
122+ await expect ( this . page . getByText ( 'SYNCHRONIZE RESOURCES' ) ) . toBeHidden ( { timeout : 15000 } ) ;
110123 }
111124
112125 async verifyStatus ( appName : string ) {
@@ -118,4 +131,20 @@ async syncApplication(appName: string, expectedResource: string = 'spring-petcli
118131 await expect ( appContainer . getByText ( / s y n c e d / i) ) . toBeVisible ( { timeout : 90000 } ) ;
119132 await expect ( appContainer . getByText ( / h e a l t h y / i) ) . toBeVisible ( { timeout : 90000 } ) ;
120133 }
134+
135+ async openApplication ( appName : string ) {
136+ //re-apply search filter just in case the UI refreshed
137+ await this . page . getByPlaceholder ( / S e a r c h a p p l i c a t i o n s / i) . fill ( appName ) ;
138+
139+ //find the container, then specifically click the link of the app name
140+ const appLink = this . page . locator ( '.white-box, .argo-table-list__row' )
141+ . filter ( { hasText : appName } )
142+ . getByRole ( 'link' , { name : appName } ) ;
143+
144+ await appLink . waitFor ( { state : 'visible' , timeout : 15000 } ) ;
145+ await appLink . click ( ) ;
146+
147+ //wait for the URL to change to the details page to ensure the click worked
148+ await expect ( this . page ) . toHaveURL ( / .* \/ a p p l i c a t i o n s \/ .* \/ .* / , { timeout : 15000 } ) ;
149+ }
121150}
0 commit comments