Update cypress version (#3053)

* update cypress

* Fix clearAndtypeCommand

* Fix selects

* Fix attribute query, and logging errored responses

* Fix mailhog commands

* Fix mailhog

* Fix for warehouses

* fix tests for plugins and sku

* Fix creating variants

* Fix plugins

* move cypress to optionalDependencies

* move cypress to optionalDependencies
This commit is contained in:
Karolina Rakoczy 2023-01-27 16:27:49 +01:00 committed by GitHub
parent 4ae2748e8e
commit 2b3c566e09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 71 additions and 41 deletions

View file

@ -53,6 +53,10 @@ describe("As an unlogged customer I want to order physical and digital products"
}); });
}); });
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
});
it( it(
"should purchase digital product as unlogged customer. TC: SALEOR_0402", "should purchase digital product as unlogged customer. TC: SALEOR_0402",
{ tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] }, { tags: ["@checkout", "@allEnv", "@stable", "@oldRelease"] },

View file

@ -120,6 +120,7 @@ describe("Manage products stocks in checkout", () => {
}) })
.then(({ order }) => { .then(({ order }) => {
expect(order, "order should be created").to.be.ok; expect(order, "order should be created").to.be.ok;
cy.clearSessionData().loginUserViaRequest();
getVariants([lastVariantInStock]); getVariants([lastVariantInStock]);
}) })
.then(variantsList => { .then(variantsList => {

View file

@ -1,6 +1,6 @@
export const VARIANTS_SELECTORS = { export const VARIANTS_SELECTORS = {
variantNameInput: '[data-test-id="variant-name"]', variantNameInput: '[data-test-id="variant-name"]',
skuTextField: '[data-test-id="sku"] input', skuTextField: '[data-test-id="sku"]',
attributeOption: attributeOption:
"[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']", "[data-test-type='option'], [data-test-id='multi-autocomplete-select-option']",
attributeSelector: "[data-test-id='attribute-value']", attributeSelector: "[data-test-id='attribute-value']",

View file

@ -88,7 +88,7 @@ export function getAttribute(attributeId) {
visibleInStorefront visibleInStorefront
availableInGrid availableInGrid
unit unit
choices{ choices(first: 100){
edges{ edges{
node{ node{
file{ file{

View file

@ -30,6 +30,7 @@ Cypress.Commands.add(
const respInSting = JSON.stringify(response.body); const respInSting = JSON.stringify(response.body);
if (respInSting.includes(`"errors":[{`)) { if (respInSting.includes(`"errors":[{`)) {
cy.log(query).log(JSON.stringify(response.body)); cy.log(query).log(JSON.stringify(response.body));
cy.wrap(response);
} }
}); });
}, },

View file

@ -31,7 +31,7 @@ export function getMailActivationLinkForUser(email, regex, i = 0) {
`There is no email invitation for user ${serverStoredEmail}`, `There is no email invitation for user ${serverStoredEmail}`,
); );
} }
return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
if (!mails.length) { if (!mails.length) {
cy.wait(10000); cy.wait(10000);
getMailActivationLinkForUser(serverStoredEmail, regex, i + 1); getMailActivationLinkForUser(serverStoredEmail, regex, i + 1);
@ -56,14 +56,14 @@ export function getMailActivationLinkForUserAndSubject(email, subject, i = 0) {
`There is no email invitation for user ${serverStoredEmail}`, `There is no email invitation for user ${serverStoredEmail}`,
); );
} }
return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
if (!mails.length) { if (!mails.length) {
cy.wait(10000); cy.wait(10000);
getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1); getMailActivationLinkForUserAndSubject(serverStoredEmail, subject, i + 1);
} else { } else {
cy.wrap(mails) cy.wrap(mails)
.mhGetMailsBySubject(subject) .mhGetMailsBySubject(subject)
.should(mailsWithSubject => { .then(mailsWithSubject => {
if (!mailsWithSubject.length) { if (!mailsWithSubject.length) {
cy.wait(10000); cy.wait(10000);
getMailActivationLinkForUserAndSubject( getMailActivationLinkForUserAndSubject(
@ -98,13 +98,19 @@ export function getMailWithResetPasswordLink(email, subject, i = 0) {
`There is no email with reset password for user ${serverStoredEmail}`, `There is no email with reset password for user ${serverStoredEmail}`,
); );
} }
return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
if (!mails.length) { if (!mails.length) {
cy.wait(3000); cy.wait(3000);
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1); getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
} else { } else {
cy.mhGetMailsBySubject(subject); cy.mhGetMailsBySubject(subject).then(resetPasswordMails => {
return mails; if (!resetPasswordMails.length) {
cy.wait(3000);
getMailWithResetPasswordLink(serverStoredEmail, subject, i + 1);
} else {
cy.wrap(resetPasswordMails);
}
});
} }
}); });
} }
@ -117,7 +123,7 @@ export function getMailsForUser(email, i = 0) {
`There is no email invitation for user ${serverStoredEmail}`, `There is no email invitation for user ${serverStoredEmail}`,
); );
} }
return cy.mhGetMailsByRecipient(serverStoredEmail).should(mails => { return cy.mhGetMailsByRecipient(serverStoredEmail).then(mails => {
if (!mails.length) { if (!mails.length) {
cy.wait(3000); cy.wait(3000);
getMailsForUser(serverStoredEmail, i + 1); getMailsForUser(serverStoredEmail, i + 1);
@ -136,7 +142,7 @@ export function getMailWithGiftCardExportWithAttachment(
if (i > 5) { if (i > 5) {
throw new Error(`There is no email Gift Card export for user ${email}`); throw new Error(`There is no email Gift Card export for user ${email}`);
} }
return cy.mhGetMailsByRecipient(email).should(mails => { return cy.mhGetMailsByRecipient(email).then(mails => {
if (!mails.length) { if (!mails.length) {
cy.wait(3000); cy.wait(3000);
getMailWithGiftCardExportWithAttachment( getMailWithGiftCardExportWithAttachment(
@ -146,7 +152,7 @@ export function getMailWithGiftCardExportWithAttachment(
i + 1, i + 1,
); );
} else { } else {
cy.mhGetMailsBySubject(subject).should(mailsWithSubject => { cy.mhGetMailsBySubject(subject).then(mailsWithSubject => {
if (!mailsWithSubject.length) { if (!mailsWithSubject.length) {
cy.wait(10000); cy.wait(10000);
getMailWithGiftCardExportWithAttachment( getMailWithGiftCardExportWithAttachment(

View file

@ -3,9 +3,13 @@ Cypress.Commands.add("getTextFromElement", element =>
); );
Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => { Cypress.Commands.add("clearAndType", { prevSubject: true }, (subject, text) => {
cy.wrap(subject) cy.wrap(subject).then(subject => {
.clear() if (subject.find("[contenteditable]").length > 0) {
.type(text); cy.wrap(subject).find("[contenteditable]").clear().type(text);
} else {
cy.wrap(subject).clear().type(text);
}
});
}); });
Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => { Cypress.Commands.add("waitForRequestAndCheckIfNoErrors", alias => {

View file

@ -35,6 +35,7 @@ Cypress.Commands.add("fillBaseSelect", (selectSelector, value) => {
}); });
Cypress.Commands.add("fillAutocompleteSelect", (selectSelector, option) => { Cypress.Commands.add("fillAutocompleteSelect", (selectSelector, option) => {
let selectedOption = option;
cy.get(selectSelector) cy.get(selectSelector)
.click() .click()
.get(BUTTON_SELECTORS.selectOption) .get(BUTTON_SELECTORS.selectOption)
@ -43,25 +44,36 @@ Cypress.Commands.add("fillAutocompleteSelect", (selectSelector, option) => {
cy.get(BUTTON_SELECTORS.selectOption) cy.get(BUTTON_SELECTORS.selectOption)
.first() .first()
.then(detachedOption => { .then(detachedOption => {
cy.get(selectSelector).clear(); cy.get(selectSelector).then(select => {
cy.get(selectSelector).type(option, { delay: 10 }); if (select.find("input").length > 0) {
cy.get(selectSelector)
.find("input")
.clear()
.type(option, { delay: 10 });
} else {
cy.get(selectSelector).clear().type(option, { delay: 10 });
}
});
cy.wrap(detachedOption).should(det => { cy.wrap(detachedOption).should(det => {
Cypress.dom.isDetached(det); Cypress.dom.isDetached(det);
}); });
cy.contains(BUTTON_SELECTORS.selectOption, option) cy.contains(BUTTON_SELECTORS.selectOption, option)
.should("be.visible") .should("be.visible")
.click({ force: true }); .click({ force: true })
cy.wrap(option).as("option"); .then(() => selectedOption);
}); });
} else { } else {
cy.get(BUTTON_SELECTORS.selectOption) cy.get(BUTTON_SELECTORS.selectOption)
.wait(1000) .wait(1000)
.first() .first()
.invoke("text") .invoke("text")
.as("option") .then(text => {
selectedOption = text;
});
return cy
.get(BUTTON_SELECTORS.selectOption) .get(BUTTON_SELECTORS.selectOption)
.first() .first()
.click(); .click()
.then(() => selectedOption);
} }
return cy.get("@option");
}); });

View file

@ -35,7 +35,8 @@ export function createVariant({
cy.get(VARIANTS_SELECTORS.saveButton) cy.get(VARIANTS_SELECTORS.saveButton)
.click() .click()
.get(VARIANTS_SELECTORS.skuTextField) .get(VARIANTS_SELECTORS.skuTextField)
.and("be.enabled") .find("input")
.should("be.enabled")
.get(BUTTON_SELECTORS.back) .get(BUTTON_SELECTORS.back)
.click() .click()
.get(PRODUCT_DETAILS.productNameInput) .get(PRODUCT_DETAILS.productNameInput)

32
package-lock.json generated
View file

@ -179,7 +179,7 @@
"@types/jest": "^26.0.14", "@types/jest": "^26.0.14",
"@types/setup-polly-jest": "^0.5.0", "@types/setup-polly-jest": "^0.5.0",
"@types/storybook__react": "^4.0.2", "@types/storybook__react": "^4.0.2",
"cypress": "^10.0.2", "cypress": "^12.4.0",
"cypress-file-upload": "^5.0.8", "cypress-file-upload": "^5.0.8",
"cypress-mailhog": "^1.3.0", "cypress-mailhog": "^1.3.0",
"cypress-mochawesome-reporter": "^2.3.0", "cypress-mochawesome-reporter": "^2.3.0",
@ -15084,9 +15084,9 @@
"optional": true "optional": true
}, },
"node_modules/cypress": { "node_modules/cypress": {
"version": "10.0.2", "version": "12.4.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.0.2.tgz", "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.4.0.tgz",
"integrity": "sha512-7+C4KHYBcfZrawss+Gt5PlS35rfc6ySc59JcHDVsIMm1E/J35dqE41UEXpdtwIq3549umCerNWnFADzqib4kcA==", "integrity": "sha512-//h93K/yGC/7pxv1KamlkADbKHLp5h3f9rZDE2McRjXZDagMETH0sXowOOanvhsH8cFt/JWspIcK+p9cuaoAqg==",
"hasInstallScript": true, "hasInstallScript": true,
"optional": true, "optional": true,
"dependencies": { "dependencies": {
@ -15109,7 +15109,7 @@
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"debug": "^4.3.2", "debug": "^4.3.2",
"enquirer": "^2.3.6", "enquirer": "^2.3.6",
"eventemitter2": "^6.4.3", "eventemitter2": "6.4.7",
"execa": "4.1.0", "execa": "4.1.0",
"executable": "^4.1.1", "executable": "^4.1.1",
"extract-zip": "2.0.1", "extract-zip": "2.0.1",
@ -15137,7 +15137,7 @@
"cypress": "bin/cypress" "cypress": "bin/cypress"
}, },
"engines": { "engines": {
"node": ">=12.0.0" "node": "^14.0.0 || ^16.0.0 || >=18.0.0"
} }
}, },
"node_modules/cypress-file-upload": { "node_modules/cypress-file-upload": {
@ -18796,9 +18796,9 @@
} }
}, },
"node_modules/eventemitter2": { "node_modules/eventemitter2": {
"version": "6.4.5", "version": "6.4.7",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.5.tgz", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz",
"integrity": "sha512-bXE7Dyc1i6oQElDG0jMRZJrRAn9QR2xyyFGmBdZleNmyQX0FqGYmhZIrIrpPfm/w//LTo4tVQGOGQcGCb5q9uw==", "integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==",
"optional": true "optional": true
}, },
"node_modules/eventemitter3": { "node_modules/eventemitter3": {
@ -51045,9 +51045,9 @@
"optional": true "optional": true
}, },
"cypress": { "cypress": {
"version": "10.0.2", "version": "12.4.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.0.2.tgz", "resolved": "https://registry.npmjs.org/cypress/-/cypress-12.4.0.tgz",
"integrity": "sha512-7+C4KHYBcfZrawss+Gt5PlS35rfc6ySc59JcHDVsIMm1E/J35dqE41UEXpdtwIq3549umCerNWnFADzqib4kcA==", "integrity": "sha512-//h93K/yGC/7pxv1KamlkADbKHLp5h3f9rZDE2McRjXZDagMETH0sXowOOanvhsH8cFt/JWspIcK+p9cuaoAqg==",
"optional": true, "optional": true,
"requires": { "requires": {
"@cypress/request": "^2.88.10", "@cypress/request": "^2.88.10",
@ -51069,7 +51069,7 @@
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"debug": "^4.3.2", "debug": "^4.3.2",
"enquirer": "^2.3.6", "enquirer": "^2.3.6",
"eventemitter2": "^6.4.3", "eventemitter2": "6.4.7",
"execa": "4.1.0", "execa": "4.1.0",
"executable": "^4.1.1", "executable": "^4.1.1",
"extract-zip": "2.0.1", "extract-zip": "2.0.1",
@ -53709,9 +53709,9 @@
"dev": true "dev": true
}, },
"eventemitter2": { "eventemitter2": {
"version": "6.4.5", "version": "6.4.7",
"resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.5.tgz", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz",
"integrity": "sha512-bXE7Dyc1i6oQElDG0jMRZJrRAn9QR2xyyFGmBdZleNmyQX0FqGYmhZIrIrpPfm/w//LTo4tVQGOGQcGCb5q9uw==", "integrity": "sha512-tYUSVOGeQPKt/eC1ABfhHy5Xd96N3oIijJvN3O9+TsC28T5V9yX9oEfEK5faP0EFSNVOG97qtAS68GBrQB2hDg==",
"optional": true "optional": true
}, },
"eventemitter3": { "eventemitter3": {

View file

@ -24,6 +24,7 @@
"@editorjs/list": "^1.7.0", "@editorjs/list": "^1.7.0",
"@editorjs/paragraph": "^2.8.0", "@editorjs/paragraph": "^2.8.0",
"@editorjs/quote": "^2.4.0", "@editorjs/quote": "^2.4.0",
"@floating-ui/react-dom-interactions": "^0.5.0",
"@glideapps/glide-data-grid": "^5.0.0", "@glideapps/glide-data-grid": "^5.0.0",
"@graphiql/plugin-explorer": "^0.1.12", "@graphiql/plugin-explorer": "^0.1.12",
"@graphiql/react": "^0.15.0", "@graphiql/react": "^0.15.0",
@ -182,7 +183,7 @@
"@types/jest": "^26.0.14", "@types/jest": "^26.0.14",
"@types/setup-polly-jest": "^0.5.0", "@types/setup-polly-jest": "^0.5.0",
"@types/storybook__react": "^4.0.2", "@types/storybook__react": "^4.0.2",
"cypress": "^10.0.2", "cypress": "^12.4.0",
"cypress-file-upload": "^5.0.8", "cypress-file-upload": "^5.0.8",
"cypress-mailhog": "^1.3.0", "cypress-mailhog": "^1.3.0",
"cypress-mochawesome-reporter": "^2.3.0", "cypress-mochawesome-reporter": "^2.3.0",
@ -204,6 +205,7 @@
"husky": "^8.0.0", "husky": "^8.0.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"jest-canvas-mock": "^2.4.0", "jest-canvas-mock": "^2.4.0",
"jest-environment-jsdom": "^27.5.1",
"jest-file": "^1.0.0", "jest-file": "^1.0.0",
"jest-localstorage-mock": "^2.4.3", "jest-localstorage-mock": "^2.4.3",
"lint-staged": "^10.5.1", "lint-staged": "^10.5.1",
@ -213,8 +215,7 @@
"mochawesome-report-generator": "^6.0.1", "mochawesome-report-generator": "^6.0.1",
"prettier": "^2.8.3", "prettier": "^2.8.3",
"setup-polly-jest": "^0.9.1", "setup-polly-jest": "^0.9.1",
"ts-jest": "^27.1.5", "ts-jest": "^27.1.5"
"jest-environment-jsdom": "^27.5.1"
}, },
"jest": { "jest": {
"resetMocks": false, "resetMocks": false,