abramenal / cypress-file-upload

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

[Bug] lastModified on file is changed on every use #277

Closed anark closed 3 years ago

anark commented 3 years ago

Current behavior:

Currently if you upload the same file fixture twice it will create two uploads with a different lastModified and lastModifiedAt` data on the file uploads. This makes it impossible to create a test that tests what happens if the same file(with the same metadata) is uploaded twice

    cy.get('.dropzone').attachFile('logo.png', { subjectType: 'drag-n-drop' })
    cy.get('.dropzone').attachFile('logo.png', { subjectType: 'drag-n-drop' })

Each upload will have a different lastModified and lastModifiedAt

The same is true if you use the following

cy.fixture('logo.png', 'binary')
  .then(Cypress.Blob.binaryStringToBlob)
  .then(fileContent => {
    cy.get('[data-cy="file-input"]').attachFile({
      fileContent,
      fileName: 'whatever',
      mimeType: 'application/octet-stream',
      encoding: 'utf-8',
    });

    cy.get('[data-cy="file-input"]').attachFile({
      fileContent,
      fileName: 'whatever',
      mimeType: 'application/octet-stream',
      encoding: 'utf-8',
    });
  });

Desired behavior:

If you upload the same file twice both uploads should reflect the files actual lastModifiedAt value.

Steps to reproduce: (app code and test code)

Versions

cypress 6.7.1 cypress-file-upload 5.0.2

abramenal commented 3 years ago

Thanks for submitting the issue and making a contribution as well! Release in v5.0.3