abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

uploading file [Bug] #342

Closed mall3r closed 2 years ago

mall3r commented 2 years ago

Current behavior:

When i upload a Example.csv file it show that the file have been uploaded but the Upload button is still cant be clicked when i upload the file manually after cypress stop it works fine

image

Desired behavior:

the file get uploaded successfully and the upload button will be clickable

Steps to reproduce: (app code and test code)

 cy.get('#version-no').type('4')
        cy.get('#version-notes').type('added new Example')
        const test_upload = "../fixtures/example.csv";
        cy.get('#file')
            .attachFile(test_upload)

        cy.get('#file')
            .its('0.files')
            .its('0')
            .its('name')
            .should('eq', 'example.csv')

        cy.get('#file')
            .trigger('change', { force: true })

        cy.get('#file')
            .trigger('fileuploadsubmit', { force: true })

        cy.get('[data-cy=Submit_Example]').click({ force: true })
    })
})

HTML

<input _ngcontent-hsp-c143="" type="file" accept=".csv" id="file" formcontrolname="file" class="form-control ng-untouched ng-pristine ng-invalid">

Versions

8.7.0

abramenal commented 2 years ago

Hi, thanks for submitting the issue. I believe the file path is incorrect here, since it uses fixtures folder as a root by default. Can you try this? const test_upload = "example.csv"

Feel free to reopen if this is still not working.