abramenal / cypress-file-upload

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

MimeType option question #313

Open JonathanDaflon opened 3 years ago

JonathanDaflon commented 3 years ago

Hi, I'm currently testing an application that can be configured to accept or deny some mimeTypes based on the customer settings. So I'm using this lib to upload files, and it has worked great, but I stumbled on this scenario where I want to set a different mimeType for an extension (example: 'file.pdf' with mimeType 'video/x-ms-wmv') to see if everything works fine.

Current Behavior: Setting a mimeType option doesn't alter the mimeType of the file (even if cypress says it does).

Sem título

Desired Behavior: Setting a mimeType option should change the file mimeType.

Question: Is this behavior intended? The mimeType option just describes the file type or it should change the type?

Steps to reproduce: obs: I'm using cucumber. The website visited tests the file to get its mimeType.

Given('test', () => {
    cy.visit('https://www.htmlstrip.com/mime-file-type-checker');
    cy.get('input#file')
    .attachFile({
        filePath: 'your_file.pdf',
        fileName: `some_name.mp4`,
        mimeType: 'video/x-ms-wmv',
        encoding: 'base64'
    })

    cy.get('button')
        .contains('Find File')
        .click()
})
aldipower commented 2 years ago

I have a simillar problem here, which makes my upload fail. The "Content-type" in the multipart/form-data for the file is not set and is just "null", not respecting the mimeType setting.