From 81cf8f2f299f045e24a0810ca23f0c231e6ae2a9 Mon Sep 17 00:00:00 2001 From: konrad Date: Sun, 30 Jan 2022 16:17:03 +0000 Subject: [PATCH] feat(tests): replace cypress-file-upload with .selectFile() (#1460) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1460 Co-authored-by: konrad Co-committed-by: konrad --- cypress/integration/user/settings.spec.js | 8 +++++--- cypress/support/index.js | 1 - package.json | 3 +-- yarn.lock | 5 ----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cypress/integration/user/settings.spec.js b/cypress/integration/user/settings.spec.js index c6a645d5..21bd9c1d 100644 --- a/cypress/integration/user/settings.spec.js +++ b/cypress/integration/user/settings.spec.js @@ -8,12 +8,14 @@ describe('User Settings', () => { }) it('Changes the user avatar', () => { + cy.intercept(`${Cypress.env('API_URL')}/user/settings/avatar/upload`).as('uploadAvatar') + cy.visit('/user/settings/avatar') cy.get('input[name=avatarProvider][value=upload]') .click() - cy.get('input[type=file]', { timeout: 1000 }) - .attachFile('image.jpg') + cy.get('input[type=file]', {timeout: 1000}) + .selectFile('cypress/fixtures/image.jpg', {force: true}) // The input is not visible, but on purpose cy.get('.vue-handler-wrapper.vue-handler-wrapper--south .vue-simple-handler.vue-simple-handler--south') .trigger('mousedown', {which: 1}) .trigger('mousemove', {clientY: 100}) @@ -22,7 +24,7 @@ describe('User Settings', () => { .contains('Upload Avatar') .click() - cy.wait(3000) // Wait for the request to finish + cy.wait('@uploadAvatar') cy.get('.global-notification') .should('contain', 'Success') }) diff --git a/cypress/support/index.js b/cypress/support/index.js index 0c885c65..7b0c56d1 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -1,6 +1,5 @@ import './commands' -import 'cypress-file-upload' import '@4tw/cypress-drag-drop' // see https://github.com/cypress-io/cypress/issues/702#issuecomment-587127275 diff --git a/package.json b/package.json index 5afb88de..263a324d 100644 --- a/package.json +++ b/package.json @@ -72,13 +72,12 @@ "browserslist": "4.19.1", "caniuse-lite": "1.0.30001304", "cypress": "9.3.1", - "cypress-file-upload": "5.0.8", "esbuild": "0.14.14", "eslint": "8.8.0", "eslint-plugin-vue": "8.4.0", "express": "4.17.2", - "netlify-cli": "8.13.0", "happy-dom": "2.30.1", + "netlify-cli": "8.13.0", "postcss": "8.4.5", "postcss-preset-env": "7.2.3", "rollup": "2.66.1", diff --git a/yarn.lock b/yarn.lock index 55188f78..a54c7dca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5215,11 +5215,6 @@ cyclist@^1.0.1: resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= -cypress-file-upload@5.0.8: - version "5.0.8" - resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1" - integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g== - cypress@9.3.1: version "9.3.1" resolved "https://registry.yarnpkg.com/cypress/-/cypress-9.3.1.tgz#8116f52d49d6daf90a91e88f3eafd940234d2958"