1
- import { KUBEADMIN_IDP , KUBEADMIN_USERNAME } from '../consts' ;
1
+ import { KUBEADMIN_IDP , KUBEADMIN_USERNAME , SECOND } from '../consts' ;
2
2
import { submitButton , masthead } from './views' ;
3
3
4
4
declare global {
@@ -9,7 +9,6 @@ declare global {
9
9
username ?: string ,
10
10
password ?: string
11
11
) : Chainable < Element > ;
12
- logout ( ) : Chainable < Element > ;
13
12
}
14
13
}
15
14
}
@@ -25,68 +24,77 @@ Cypress.Commands.add(
25
24
26
25
cy . window ( ) . then ( ( win : any ) => {
27
26
if ( win . SERVER_FLAGS ?. authDisabled ) {
28
- cy . task (
29
- 'log' ,
30
- ' skipping login, console is running with auth disabled'
31
- ) ;
32
- return ;
33
- }
34
-
35
- cy . origin (
36
- Cypress . env ( 'OAUTH_BASE_ADDRESS' ) ,
37
- {
38
- args : {
27
+ cy . log ( 'Skipping login, console is running with auth disabled' ) ;
28
+ } else {
29
+ cy . origin (
30
+ Cypress . env ( 'OAUTH_BASE_ADDRESS' ) ,
31
+ {
32
+ args : {
33
+ provider,
34
+ username,
35
+ password,
36
+ KUBEADMIN_IDP ,
37
+ KUBEADMIN_USERNAME ,
38
+ SECOND ,
39
+ submitButton,
40
+ } ,
41
+ } ,
42
+ ( {
43
+ /* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/naming-convention */
39
44
provider,
40
45
username,
41
46
password,
42
47
KUBEADMIN_IDP ,
43
48
KUBEADMIN_USERNAME ,
49
+ SECOND ,
44
50
submitButton,
45
- } ,
46
- } ,
47
- ( {
48
- /* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/naming-convention */
49
- provider,
50
- username,
51
- password,
52
- KUBEADMIN_IDP ,
53
- KUBEADMIN_USERNAME ,
54
- submitButton,
55
- /* eslint-enable @typescript-eslint/no-shadow, @typescript-eslint/naming-convention */
56
- } ) => {
57
- const idp = provider || KUBEADMIN_IDP ;
51
+ /* eslint-enable @typescript-eslint/no-shadow, @typescript-eslint/naming-convention */
52
+ } ) => {
53
+ const idp = provider || KUBEADMIN_IDP ;
58
54
59
- cy . task (
60
- 'log' ,
61
- ` Logging in as ${ username || KUBEADMIN_USERNAME } `
62
- ) ;
63
- cy . get ( '[data-test-id="login"]' , { timeout : 10000 } ) . should (
64
- 'be.visible'
65
- ) ;
55
+ cy . log ( `Logging in as ${ username || KUBEADMIN_USERNAME } ` ) ;
56
+ // We cannot use byLegacyTestID here.
57
+ cy . get ( '[data-test-id="login"]' , {
58
+ timeout : 10 * SECOND ,
59
+ } ) . should ( 'be.visible' ) ;
66
60
67
- // eslint-disable-next-line cypress/require-data-selectors
68
- cy . get ( 'body' ) . then ( ( $body ) => {
69
- if ( $body . text ( ) . includes ( idp ) ) {
70
- cy . contains ( idp ) . should ( 'be.visible' ) . click ( ) ;
71
- }
72
- } ) ;
61
+ // eslint-disable-next-line cypress/require-data-selectors
62
+ cy . get ( 'body' ) . then ( ( $body ) => {
63
+ if ( $body . text ( ) . includes ( idp ) ) {
64
+ cy . contains ( idp ) . should ( 'be.visible' ) . click ( ) ;
65
+ }
66
+ } ) ;
73
67
74
- /* eslint-disable cypress/require-data-selectors */
75
- cy . get ( '#inputUsername' ) . type ( username || KUBEADMIN_USERNAME ) ;
76
- cy . get ( '#inputPassword' ) . type (
77
- password || Cypress . env ( 'BRIDGE_KUBEADMIN_PASSWORD' ) ,
78
- {
79
- log : false ,
80
- }
81
- ) ;
82
- cy . get ( submitButton ) . click ( ) ;
83
- }
84
- ) ;
68
+ /* eslint-disable cypress/require-data-selectors */
69
+ cy . get ( '#inputUsername' ) . type ( username || KUBEADMIN_USERNAME ) ;
70
+ cy . get ( '#inputPassword' ) . type (
71
+ password || Cypress . env ( 'BRIDGE_KUBEADMIN_PASSWORD' ) ,
72
+ {
73
+ log : false ,
74
+ }
75
+ ) ;
76
+ cy . get ( submitButton ) . click ( ) ;
77
+ }
78
+ ) ;
85
79
86
- // Back to the console's origin and ensure user is logged in.
87
- cy . visit ( '' ) ;
88
- /* eslint-enable cypress/require-data-selectors */
89
- masthead . username . shouldBeVisible ( ) ;
80
+ // Ensure the user is logged in.
81
+ /* eslint-enable cypress/require-data-selectors */
82
+ masthead . username . shouldBeVisible ( ) ;
83
+ }
84
+
85
+ // Close console tour modal.
86
+ cy . byTestID ( 'detail-item-title' )
87
+ . contains ( 'Cluster API address' )
88
+ . should ( 'be.visible' ) ;
89
+ // eslint-disable-next-line cypress/require-data-selectors
90
+ cy . get ( 'body' ) . then ( ( $body ) => {
91
+ if ( $body . find ( `[data-test="guided-tour-modal"]` ) . length > 0 ) {
92
+ cy . byTestID ( 'tour-step-footer-secondary' )
93
+ . contains ( 'Skip tour' )
94
+ . click ( ) ;
95
+ cy . byTestID ( 'guided-tour-modal' ) . should ( 'not.exist' ) ;
96
+ }
97
+ } ) ;
90
98
} ) ;
91
99
} ,
92
100
{ cacheAcrossSpecs : true }
0 commit comments