Skip to content

Commit

Permalink
Merge pull request #977 from uploadcare/chore/fix-e2e
Browse files Browse the repository at this point in the history
chore: fix e2e tests
  • Loading branch information
nd0ut authored Aug 26, 2024
2 parents 7b66560 + e69bd4a commit dfd11a2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 59 deletions.
59 changes: 32 additions & 27 deletions cypress/e2e/index.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />
/* eslint-env mocha */
/* global cy */
/* global Cypress */

import { setup } from '../templates'

Expand All @@ -26,44 +27,48 @@ describe('uploadcare widget', () => {
const fileName = 'image.jpeg'
setup()

cy.fixture(fileName).then((fileContent) => {
cy.get('.uploadcare--widget__button_type_open').click()
cy.fixture(fileName, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
cy.get('.uploadcare--widget__button_type_open').click()

cy.get('.uploadcare--draganddrop').attachFile(
{ fileContent, fileName, mimeType: 'image/jpeg' },
{ subjectType: 'drag-n-drop', events: ['dragcenter', 'drop'] }
)
cy.get('.uploadcare--draganddrop').attachFile(
{ fileContent, fileName, mimeType: 'image/jpeg' },
{ subjectType: 'drag-n-drop', events: ['dragcenter', 'drop'] }
)

cy.get('.uploadcare--progress').should('exist')
cy.get('.uploadcare--progress').should('exist')

cy.get('.uploadcare--link')
.should('exist')
.should('contain.text', fileName)
})
cy.get('.uploadcare--link')
.should('exist')
.should('contain.text', fileName)
})
})

it('should upload images', () => {
const fileName = 'image.jpeg'

cy.fixture(fileName).then((fileContent) => {
setup()
cy.fixture(fileName, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
setup()

cy.get('.uploadcare--widget__button_type_open').click()
cy.get('.uploadcare--widget__button_type_open').click()

cy.get(
'.uploadcare--tab_name_file .uploadcare--tab__action-button'
).click()
cy.get('input[type="file"]').attachFile({
fileContent,
fileName,
mimeType: 'image/jpeg'
})
cy.get(
'.uploadcare--tab_name_file .uploadcare--tab__action-button'
).click()
cy.get('input[type="file"]').attachFile({
fileContent,
fileName,
mimeType: 'image/jpeg'
})

cy.get('.uploadcare--progress').should('exist')
cy.get('.uploadcare--progress').should('exist')

cy.get('.uploadcare--link')
.should('exist')
.should('contain.text', fileName)
})
cy.get('.uploadcare--link')
.should('exist')
.should('contain.text', fileName)
})
})
})
54 changes: 23 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"cpy-cli": "5.0.0",
"cross-env": "7.0.3",
"cssnano": "6.0.2",
"cypress": "13.6.1",
"cypress": "13.13.3",
"cypress-file-upload": "5.0.8",
"dotenv": "8.6.0",
"eslint": "8.56.0",
Expand Down

0 comments on commit dfd11a2

Please sign in to comment.