@@ -53,15 +53,13 @@ const checkFilePreviewInFileAttachment = (component) => {
5353
5454const deleteSelectedFiles = ( component , fileNames ) => {
5555 cy . get ( component ) . then ( ( ) => {
56- cy . wrap ( fileNames ) . each ( ( fileName ) => {
57- cy . get ( '.cmp-adaptiveform-fileinput__filedelete' ) . should ( 'have.attr' , 'role' , 'button' ) ;
58- cy . get ( '.cmp-adaptiveform-fileinput__filename' ) . contains ( fileName ) . first ( ) . next ( ) . click ( ) ;
59- cy . wait ( 500 ) ;
60- } ) ;
56+ fileNames . forEach ( ( fileName ) => {
57+ cy . get ( ".cmp-adaptiveform-fileinput__filedelete" ) . should ( 'have.attr' , 'role' , 'button' ) ;
58+ cy . get ( ".cmp-adaptiveform-fileinput__filename" ) . contains ( fileName ) . next ( ) . click ( ) ;
59+ } )
6160 } ) ;
6261} ;
6362
64-
6563const checkFileNamesInFileAttachmentView = ( component , fileNames ) => {
6664 // check if file present in view
6765 cy . get ( component ) . then ( ( ) => {
@@ -233,21 +231,19 @@ describe("Form with File Input - Basic Tests", () => {
233231 } )
234232
235233 it ( "check preview and delete functionality of duplicate files" , ( ) => {
236- let sampleFileNames = [ 'sample2.txt' , 'sample.txt' , 'sample2.txt' ] ;
234+ let sampleFileNames = [ 'sample2.txt' , 'sample.txt' , 'sample2.txt' ] ;
237235 const fileInput = "input[name='fileinput1']" ;
238-
239- // Attach files
240236 cy . attachFile ( fileInput , [ sampleFileNames [ 0 ] ] ) ;
241237 cy . attachFile ( fileInput , [ sampleFileNames [ 1 ] ] ) ;
242- cy . attachFile ( fileInput , [ sampleFileNames [ 2 ] ] ) ;
243-
238+ cy . attachFile ( fileInput , [ sampleFileNames [ 0 ] ] ) ;
239+
244240 checkFilePreviewInFileAttachment ( fileInput ) ;
245241
246- deleteSelectedFiles ( fileInput , sampleFileNames ) ;
242+ deleteSelectedFiles ( fileInput , sampleFileNames )
243+
244+ cy . get ( '.cmp-adaptiveform-fileinput__filelist' ) . eq ( 0 ) . children ( ) . should ( 'have.length' , 0 ) ;
245+ } )
247246
248- cy . get ( '.cmp-adaptiveform-fileinput__fileitem' ) . should ( 'have.length' , 0 ) ;
249- } ) ;
250-
251247 it ( `fielinput is disabled when readonly property is true` , ( ) => {
252248 const fileInput5 = "input[name='fileinput5']" ;
253249 cy . get ( fileInput5 ) . should ( "have.attr" , "disabled" , "disabled" ) ;
0 commit comments