Skip to content

Commit

Permalink
chore: fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nd0ut committed Aug 26, 2024
1 parent 7b66560 commit e69bd4a
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 e69bd4a

Please sign in to comment.