5
5
CLUSTER_CREATION_TIMEOUT ,
6
6
HOST_DISCOVERY_TIMEOUT ,
7
7
HOST_REGISTRATION_TIMEOUT ,
8
+ FILE_DOWNLOAD_TIMEOUT ,
8
9
} from './constants' ;
9
10
10
11
export const testInfraClusterName = 'test-infra-cluster' ;
@@ -127,7 +128,8 @@ export const generateIso = (sshPubKey) => {
127
128
cy . get ( '.pf-c-modal-box__footer > .pf-m-primary' ) . click ( ) ;
128
129
// cy.get('.pf-c-modal-box__footer > .pf-m-primary', { timeout: 5 * 60 * 1000 });
129
130
// bug: cy.get() timeout is ignored since former inner XHR is aborted by Cypress
130
- cy . wait ( 90 * 1000 ) . then ( ( ) => {
131
+ // using constant GENERATE_ISO_TIMEOUT causes a lint crash https://github.com/cypress-io/eslint-plugin-cypress/issues/43
132
+ cy . wait ( 2 * 60 * 1000 ) . then ( ( ) => {
131
133
// yield potentially onAnyAbort()
132
134
if ( aborted ) {
133
135
cy . log ( 'Long-running XHR was aborted' ) ;
@@ -139,9 +141,30 @@ export const generateIso = (sshPubKey) => {
139
141
} else {
140
142
cy . log ( 'Waiting for ISO was successful' ) ;
141
143
}
142
- cy . get ( '.pf-c-modal-box__footer > .pf-m-primary' ) . contains ( 'Download Discovery ISO' ) ;
143
144
} ) ;
144
- cy . get ( '#pf-modal-part-7 > footer > button.pf-c-button.pf-m-secondary' ) . click ( ) ; // now close the dialog
145
+ cy . get ( 'button[data-test-id="download-iso-btn"]' , { timeout : 2 * 60 * 1000 } ) . contains (
146
+ 'Download Discovery ISO' ,
147
+ ) ;
148
+ cy . get ( 'button[data-test-id="close-iso-btn"]' ) . click ( ) ; // now close the dialog
149
+ } ;
150
+
151
+ export const downloadFileWithChrome = ( downloadButton , resultantFilename ) => {
152
+ // NOTE: This works only with Chrome, where the default behavior is:
153
+ // 1) It starts the download without popping up a save dialog (which would require automating native windows)
154
+ // 2) It caches to a temporary location, and when the download is complete it moves the file to ~/Downloads
155
+
156
+ // first delete old downloads
157
+ cy . exec ( `[ -f ${ resultantFilename } ] && rm -rf ${ resultantFilename } ` , {
158
+ failOnNonZeroExit : false ,
159
+ } ) ;
160
+ cy . get ( downloadButton ) . click ( ) ;
161
+
162
+ // wait until the file shows up, to know that the download finshed
163
+ cy . exec ( `while [ ! -f ${ resultantFilename } ]; do sleep 1; done` , {
164
+ timeout : FILE_DOWNLOAD_TIMEOUT ,
165
+ } ) . should ( ( result ) => {
166
+ expect ( result . code ) . to . be . eq ( 0 ) ;
167
+ } ) ;
145
168
} ;
146
169
147
170
export const assertTestClusterPresence = ( cy ) => {
0 commit comments