@@ -180,10 +180,10 @@ describe('Form Designer', () => {
180180 } ) ;
181181 } ) ;
182182 it ( 'Verify submission' , ( ) => {
183- cy . viewport ( 1000 , 1800 ) ;
184- cy . waitForLoad ( ) ;
185- cy . waitForLoad ( ) ;
186- cy . intercept ( 'GET' , `/${ depEnv } /api/v1/forms/*` ) . as ( 'getForm' ) ;
183+ cy . viewport ( 1000 , 1800 ) ;
184+ cy . waitForLoad ( ) ;
185+ cy . waitForLoad ( ) ;
186+ cy . intercept ( 'GET' , `/${ depEnv } /api/v1/forms/*` ) . as ( 'getForm' ) ;
187187 // Form saving
188188 let savedButton = cy . get ( '[data-cy=saveButton]' ) ;
189189 expect ( savedButton ) . to . not . be . null ;
@@ -192,37 +192,25 @@ describe('Form Designer', () => {
192192 // Filter the newly created form
193193 cy . location ( 'search' ) . then ( search => {
194194 //let pathName = fullUrl.pathname
195- let arr = search . split ( '=' ) ;
196- let arrayValues = arr [ 1 ] . split ( '&' ) ;
197- cy . log ( arrayValues [ 0 ] ) ;
198- cy . visit ( `/${ depEnv } /form/manage?f=${ arrayValues [ 0 ] } ` ) ;
199- cy . waitForLoad ( ) ;
200- } )
201-
195+ let arr = search . split ( '=' ) ;
196+ let arrayValues = arr [ 1 ] . split ( '&' ) ;
197+ cy . log ( arrayValues [ 0 ] ) ;
198+ cy . visit ( `/${ depEnv } /form/manage?f=${ arrayValues [ 0 ] } ` ) ;
199+ cy . waitForLoad ( ) ;
202200 //Publish the form
203201 cy . get ( '.v-label > span' ) . click ( ) ;
204202 cy . get ( 'span' ) . contains ( 'Publish Version 1' ) ;
205203 cy . contains ( 'Continue' ) . should ( 'be.visible' ) ;
206204 cy . contains ( 'Continue' ) . trigger ( 'click' ) ;
207205
208206 //Share link verification
209- let shareFormButton = cy . get ( '[data-cy=shareFormButton]' ) ;
210- expect ( shareFormButton ) . to . not . be . null ;
211- shareFormButton . trigger ( 'click' ) . then ( ( ) => {
212- //let shareFormLinkButton = cy.get('[data-cy=shareFormLinkButtonss]');
213- let shareFormLinkButton = cy . get ( '.mx-2' ) ;
214- expect ( shareFormLinkButton ) . to . not . be . null ;
215- shareFormLinkButton . trigger ( 'click' ) ;
216- //Close form share window
217- cy . get ( '.v-card-actions > .v-btn > .v-btn__content > span' ) . click ( ) ;
218- } ) ;
207+ cy . get ( '[data-cy=shareFormButton]' ) . should ( 'be.visible' ) . click ( ) ;
208+ cy . get ( '.v-card-actions > .v-btn > .v-btn__content > span' ) . click ( ) ;
219209 cy . location ( 'search' ) . then ( search => {
220210 //let pathName = fullUrl.pathname
221211 let arr = search . split ( '=' ) ;
222212 let arrayValues = arr [ 1 ] . split ( '&' ) ;
223213 cy . visit ( `/${ depEnv } /form/submit?f=${ arrayValues [ 0 ] } ` ) ;
224- cy . waitForLoad ( ) ;
225-
226214 cy . waitForLoad ( ) ;
227215 // for print option verification
228216 cy . get ( ':nth-child(2) > .d-print-none > :nth-child(1) > .v-btn' ) . should ( 'be.visible' ) ;
@@ -247,32 +235,55 @@ describe('Form Designer', () => {
247235 cy . get ( '.browse' ) . should ( 'have.attr' , 'ref' ) . and ( 'include' , 'fileBrowse' ) ;
248236 cy . get ( '.browse' ) . should ( 'have.attr' , 'href' ) . and ( 'include' , '#' ) ;
249237 cy . get ( '.browse' ) . click ( ) ;
250- let fileUploadInputField = cy . get ( 'input[type=file]' ) ;
251- cy . get ( 'input[type=file]' ) . should ( 'not.to.be.null' ) ;
252- fileUploadInputField . attachFile ( 'add1.png' ) ;
253- cy . waitForLoad ( ) ;
254- //verify file uploads to object storage
238+ // Intercept POST upload
239+ cy . intercept ( 'POST' , '/api/v1/files' ) . as ( 'uploadFile' ) ;
240+ // Trigger upload (adjust selector as needed)
241+ cy . get ( 'input[type="file"]' ) . selectFile ( 'fixtures/add1.png' , {
242+ force : true
243+ } ) ;
244+ //verify file uploads to object storage and extract fileId
255245 cy . get ( '.col-md-9 > a' ) . should ( 'have.attr' , 'ref' ) . and ( 'include' , 'fileLink' ) ;
256246 cy . get ( 'div.col-md-2' ) . contains ( '61.48 kB' ) ;
257- cy . wait ( 2000 ) ;
258- //form submission
247+ cy . wait ( 1000 ) ;
248+ cy . get ( '.col-md-9 > a' )
249+ . should ( 'have.attr' , 'href' )
250+ . then ( ( href ) => {
251+ const fileId = href . split ( '/' ) . pop ( ) ; // get last part
252+ cy . wrap ( fileId ) . as ( 'fileId' ) ;
253+ //form submission
259254 cy . get ( 'button' ) . contains ( 'Submit' ) . click ( ) ;
260255 cy . wait ( 2000 ) ;
261256 cy . get ( '[data-test="continue-btn-continue"]' ) . click ( ) ;
257+ // Validate file exists via API
258+ cy . then ( ( ) => {
259+ cy . request ( {
260+ method : 'GET' ,
261+ url : `/api/v1/files/${ fileId } ` ,
262+ failOnStatusCode : false
263+ } ) . then ( ( res ) => {
264+ expect ( res . status ) . to . eq ( 503 ) ;
265+ } ) ;
266+ } ) ;
267+ } ) ;
262268 // verify the components after submission
263269 cy . get ( 'span' ) . contains ( 'Canadian' ) . should ( 'be.visible' ) ;
264270 cy . get ( 'span' ) . contains ( 'Eligible' ) . should ( 'be.visible' ) ;
265271 cy . get ( '.choices__inner > .choices__list > .choices__item' ) . contains ( 'hello' ) ;
266272 cy . get ( '.col-md-9 > a' ) . contains ( 'add1.png' ) ;
267273 cy . get ( '.ui > .choices__list > .choices__item' ) . contains ( 'THRIFTY FOODS' ) ;
274+ //Verify uploaded file is downloadable
275+ cy . get ( '.col-md-9 > a' ) . contains ( 'add1.png' ) . click ( ) ;
276+ const path = require ( "path" ) ;
277+ const downloadsFolder = Cypress . config ( "downloadsFolder" ) ;
278+ cy . readFile ( path . join ( downloadsFolder , 'add1.png' ) ) . should ( 'exist' ) ;
268279 //Delete form after test run
269280 cy . visit ( `/${ depEnv } /form/manage?f=${ arrayValues [ 0 ] } ` ) ;
270281 cy . waitForLoad ( ) ;
271282 cy . waitForLoad ( ) ;
272283 cy . get ( '.mdi-delete' ) . click ( ) ;
273284 cy . get ( '[data-test="continue-btn-continue"]' ) . click ( ) ;
274-
275285 } )
286+ } ) ;
276287
277288 } ) ;
278289} ) ;
0 commit comments