@@ -175,51 +175,47 @@ function performLogin(
175175) : void {
176176 cy . visit ( Cypress . config ( 'baseUrl' ) ) ;
177177 cy . log ( 'Session - after visiting' ) ;
178- cy . window ( ) . then (
179- (
180- win : any , // eslint-disable-line @typescript-eslint/no-explicit-any
181- ) => {
182- // Check if auth is disabled (for a local development environment)
183- if ( win . SERVER_FLAGS ?. authDisabled ) {
184- cy . task ( 'log' , ' skipping login, console is running with auth disabled' ) ;
185- return ;
186- }
187- cy . exec (
188- `oc get node --selector=hypershift.openshift.io/managed --kubeconfig ${ Cypress . env (
189- 'KUBECONFIG_PATH' ,
190- ) } `,
191- ) . then ( ( result ) => {
192- cy . log ( result . stdout ) ;
193- cy . task ( 'log' , result . stdout ) ;
194- if ( result . stdout . includes ( 'Ready' ) ) {
195- cy . log ( `Attempting login via cy.origin to: ${ oauthurl } ` ) ;
196- cy . task ( 'log' , `Attempting login via cy.origin to: ${ oauthurl } ` ) ;
197- cy . origin ( oauthurl , { args : { username, password } } , ( { username, password } ) => {
178+ cy . window ( ) . then ( ( win : any ) => {
179+ // Check if auth is disabled (for a local development environment)
180+ if ( win . SERVER_FLAGS ?. authDisabled ) {
181+ cy . task ( 'log' , ' skipping login, console is running with auth disabled' ) ;
182+ return ;
183+ }
184+ cy . exec (
185+ `oc get node --selector=hypershift.openshift.io/managed --kubeconfig ${ Cypress . env (
186+ 'KUBECONFIG_PATH' ,
187+ ) } `,
188+ ) . then ( ( result ) => {
189+ cy . log ( result . stdout ) ;
190+ cy . task ( 'log' , result . stdout ) ;
191+ if ( result . stdout . includes ( 'Ready' ) ) {
192+ cy . log ( `Attempting login via cy.origin to: ${ oauthurl } ` ) ;
193+ cy . task ( 'log' , `Attempting login via cy.origin to: ${ oauthurl } ` ) ;
194+ cy . origin ( oauthurl , { args : { username, password } } , ( { username, password } ) => {
195+ cy . get ( '#inputUsername' ) . type ( username ) ;
196+ cy . get ( '#inputPassword' ) . type ( password ) ;
197+ cy . get ( 'button[type=submit]' ) . click ( ) ;
198+ } ) ;
199+ } else {
200+ cy . task ( 'log' , ` Logging in as ${ username } using fallback on ${ oauthurl } ` ) ;
201+ cy . origin (
202+ oauthurl ,
203+ { args : { provider, username, password } } ,
204+ ( { provider, username, password } ) => {
205+ cy . get ( '[data-test-id="login"]' ) . should ( 'be.visible' ) ;
206+ cy . get ( 'body' ) . then ( ( $body ) => {
207+ if ( $body . text ( ) . includes ( provider ) ) {
208+ cy . contains ( provider ) . should ( 'be.visible' ) . click ( ) ;
209+ }
210+ } ) ;
198211 cy . get ( '#inputUsername' ) . type ( username ) ;
199212 cy . get ( '#inputPassword' ) . type ( password ) ;
200213 cy . get ( 'button[type=submit]' ) . click ( ) ;
201- } ) ;
202- } else {
203- cy . task ( 'log' , ` Logging in as ${ username } using fallback on ${ oauthurl } ` ) ;
204- cy . origin (
205- oauthurl ,
206- { args : { provider, username, password } } ,
207- ( { provider, username, password } ) => {
208- cy . get ( '[data-test-id="login"]' ) . should ( 'be.visible' ) ;
209- cy . get ( 'body' ) . then ( ( $body ) => {
210- if ( $body . text ( ) . includes ( provider ) ) {
211- cy . contains ( provider ) . should ( 'be.visible' ) . click ( ) ;
212- }
213- } ) ;
214- cy . get ( '#inputUsername' ) . type ( username ) ;
215- cy . get ( '#inputPassword' ) . type ( password ) ;
216- cy . get ( 'button[type=submit]' ) . click ( ) ;
217- } ,
218- ) ;
219- }
220- } ) ;
221- } ,
222- ) ;
214+ } ,
215+ ) ;
216+ }
217+ } ) ;
218+ } ) ;
223219}
224220
225221Cypress . Commands . add ( 'validateLogin' , ( ) => {
@@ -283,29 +279,25 @@ Cypress.Commands.add('uiLogin', (provider: string, username: string, password: s
283279 cy . log ( 'Commands uiLogin' ) ;
284280 cy . clearCookie ( 'openshift-session-token' ) ;
285281 cy . visit ( '/' ) ;
286- cy . window ( ) . then (
287- (
288- win : any , // eslint-disable-line @typescript-eslint/no-explicit-any
289- ) => {
290- if ( win . SERVER_FLAGS ?. authDisabled ) {
291- cy . task ( 'log' , 'Skipping login, console is running with auth disabled' ) ;
292- return ;
282+ cy . window ( ) . then ( ( win : any ) => {
283+ if ( win . SERVER_FLAGS ?. authDisabled ) {
284+ cy . task ( 'log' , 'Skipping login, console is running with auth disabled' ) ;
285+ return ;
286+ }
287+ cy . get ( 'h1' ) . should ( 'have.text' , 'Login' ) ;
288+ cy . get ( 'body' ) . then ( ( $body ) => {
289+ if ( $body . text ( ) . includes ( provider ) ) {
290+ cy . contains ( provider ) . should ( 'be.visible' ) . click ( ) ;
291+ } else if ( $body . find ( 'li.idp' ) . length > 0 ) {
292+ //Using the last idp if doesn't provider idp name
293+ cy . get ( 'li.idp' ) . last ( ) . click ( ) ;
293294 }
294- cy . get ( 'h1' ) . should ( 'have.text' , 'Login' ) ;
295- cy . get ( 'body' ) . then ( ( $body ) => {
296- if ( $body . text ( ) . includes ( provider ) ) {
297- cy . contains ( provider ) . should ( 'be.visible' ) . click ( ) ;
298- } else if ( $body . find ( 'li.idp' ) . length > 0 ) {
299- //Using the last idp if doesn't provider idp name
300- cy . get ( 'li.idp' ) . last ( ) . click ( ) ;
301- }
302- } ) ;
303- cy . get ( '#inputUsername' ) . type ( username ) ;
304- cy . get ( '#inputPassword' ) . type ( password ) ;
305- cy . get ( 'button[type=submit]' ) . click ( ) ;
306- cy . byTestID ( 'username' , { timeout : 120000 } ) . should ( 'be.visible' ) ;
307- } ,
308- ) ;
295+ } ) ;
296+ cy . get ( '#inputUsername' ) . type ( username ) ;
297+ cy . get ( '#inputPassword' ) . type ( password ) ;
298+ cy . get ( 'button[type=submit]' ) . click ( ) ;
299+ cy . byTestID ( 'username' , { timeout : 120000 } ) . should ( 'be.visible' ) ;
300+ } ) ;
309301 cy . switchPerspective ( 'Administrator' ) ;
310302} ) ;
311303
@@ -362,20 +354,16 @@ Cypress.Commands.add('relogin', (provider: string, username: string, password: s
362354} ) ;
363355
364356Cypress . Commands . add ( 'uiLogout' , ( ) => {
365- cy . window ( ) . then (
366- (
367- win : any , // eslint-disable-line @typescript-eslint/no-explicit-any
368- ) => {
369- if ( win . SERVER_FLAGS ?. authDisabled ) {
370- cy . log ( 'Skipping logout, console is running with auth disabled' ) ;
371- return ;
372- }
373- cy . log ( 'Log out UI' ) ;
374- cy . byTestID ( 'username' ) . click ( ) ;
375- cy . wait ( 3000 ) ;
376- cy . byTestID ( 'log-out' ) . click ( { force : true } ) ;
377- } ,
378- ) ;
357+ cy . window ( ) . then ( ( win : any ) => {
358+ if ( win . SERVER_FLAGS ?. authDisabled ) {
359+ cy . log ( 'Skipping logout, console is running with auth disabled' ) ;
360+ return ;
361+ }
362+ cy . log ( 'Log out UI' ) ;
363+ cy . byTestID ( 'username' ) . click ( ) ;
364+ cy . wait ( 3000 ) ;
365+ cy . byTestID ( 'log-out' ) . click ( { force : true } ) ;
366+ } ) ;
379367} ) ;
380368
381369Cypress . Commands . add ( 'cliLogin' , ( username ?, password ?, hostapi ?) => {
0 commit comments