Skip to content

Commit

Permalink
Merge pull request #6528 from Ocelot-Social-Community/6375-refactor-c…
Browse files Browse the repository at this point in the history
…ypress-migrate-from-cypress-file-upload-to-selectfile

refactor(other): cypress - migrate from cypress-file-upload to .selectFile()
  • Loading branch information
mahula authored Jul 13, 2023
2 parents f9afdc9 + c9e4029 commit e3b6197
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 1,023 deletions.
1 change: 0 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// Cypress.Commands.add('login', (email, password) => { ... })

/* globals Cypress cy */
import "cypress-file-upload";
import { GraphQLClient, request } from 'graphql-request'
import CONFIG from '../../backend/build/src/config'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import { Then } from "@badeball/cypress-cucumber-preprocessor";

Then("I should be able to {string} a teaser image", condition => {
// cy.reload()
let postTeaserImage = ""

switch(condition){
case 'change':
cy.get('.delete-image-button')
case "change":
postTeaserImage = "humanconnection.png"
cy.get(".delete-image-button")
.click()
cy.fixture('humanconnection.png').as('postTeaserImage').then(function() {
cy.get("#postdropzone").upload(
{ fileContent: this.postTeaserImage, fileName: 'humanconnection.png', mimeType: "image/png" },
{ subjectType: "drag-n-drop", force: true }
).wait(750);
})
cy.get("#postdropzone").selectFile(
{ contents: `cypress/fixtures/${postTeaserImage}`, fileName: postTeaserImage, mimeType: "image/png" },
{ action: "drag-drop", force: true }
).wait(750);
break;
case 'add':
cy.fixture('onourjourney.png').as('postTeaserImage').then(function() {
cy.get("#postdropzone").upload(
{ fileContent: this.postTeaserImage, fileName: 'onourjourney.png', mimeType: "image/png" },
{ subjectType: "drag-n-drop", force: true }
).wait(750);
})
case "add":
postTeaserImage = "onourjourney.png"
cy.get("#postdropzone").selectFile(
{ contents: `cypress/fixtures/${postTeaserImage}`, fileName: postTeaserImage, mimeType: "image/png" },
{ action: "drag-drop", force: true }
).wait(750);
break;
case 'remove':
cy.get('.delete-image-button')
case "remove":
cy.get(".delete-image-button")
.click()
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { Then } from "@badeball/cypress-cucumber-preprocessor";

Then("I should be able to change my profile picture", () => {
const avatarUpload = "onourjourney.png";

cy.fixture(avatarUpload, "base64").then(fileContent => {
cy.get("#customdropzone").upload(
{ fileContent, fileName: avatarUpload, mimeType: "image/png" },
{ subjectType: "drag-n-drop", force: true }
);
});

cy.get("#customdropzone").selectFile(
{ contents: `cypress/fixtures/${avatarUpload}`, fileName: avatarUpload, mimeType: "image/png" },
{ action: "drag-drop" }
);
cy.get(".profile-page-avatar img")
.should("have.attr", "src")
.and("contains", "onourjourney");
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"scripts": {
"db:seed": "cd backend && yarn run db:seed",
"db:reset": "cd backend && yarn run db:reset",
"cypress:run": "cypress run --browser electron --config-file ./cypress/cypress.config.js",
"cypress:open": "cypress open --browser electron --config-file ./cypress/cypress.config.js",
"cypress:run": "cypress run --e2e --browser electron --config-file ./cypress/cypress.config.js",
"cypress:open": "cypress open --e2e --browser electron --config-file ./cypress/cypress.config.js",
"cucumber:setup": "cd backend && yarn run dev",
"cucumber": "wait-on tcp:4000 && cucumber-js --require-module @babel/register --exit",
"release": "yarn version --no-git-tag-version --no-commit-hooks --no-commit && auto-changelog --latest-version $(node -p -e \"require('./package.json').version\") && cd backend && yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version $(node -p -e \"require('./../package.json').version\") && cd ../webapp && yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version $(node -p -e \"require('./../package.json').version\") && cd ../webapp/maintenance/source && yarn version --no-git-tag-version --no-commit-hooks --no-commit --new-version $(node -p -e \"require('./../../../package.json').version\")"
Expand All @@ -33,7 +33,6 @@
"cross-env": "^7.0.3",
"cucumber": "^6.0.5",
"cypress": "^12.17.0",
"cypress-file-upload": "^3.5.3",
"cypress-network-idle": "^1.14.2",
"date-fns": "^2.25.0",
"dotenv": "^8.2.0",
Expand Down
Loading

0 comments on commit e3b6197

Please # to comment.