test for elements visibility, TODO - api requests for creating order
This commit is contained in:
parent
167b77e18a
commit
f1d4b11a81
7 changed files with 228 additions and 0 deletions
11
cypress/elements/dashboard/dashboard-selectors.js
Normal file
11
cypress/elements/dashboard/dashboard-selectors.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
export const DASHBOARD_SELECTORS = {
|
||||
sales: "div:nth-child(1) > [class*='HomeAnalyticsCard-cardContent']",
|
||||
orders: "div:nth-child(2) > [class*='HomeAnalyticsCard-cardContent']",
|
||||
activity: "[class*='Grid-root'] > div:nth-child(2) > [class*='MuiPaper']",
|
||||
topProducts:
|
||||
"[class*='Grid-root'] > div:nth-child(1) > [class*='MuiPaper']:nth-child(4)",
|
||||
ordersReadyToFulfill: "[class*='HomeNotificationTable'] > tr:nth-child(1)",
|
||||
paymentsWaitingForCapture:
|
||||
"[class*='HomeNotificationTable'] > tr:nth-child(2)",
|
||||
productsOutOfStock: "[class*='HomeNotificationTable'] > tr:nth-child(3)"
|
||||
};
|
12
cypress/fixtures/addresses.json
Normal file
12
cypress/fixtures/addresses.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"plAddress": {
|
||||
"companyName": "Test3",
|
||||
"streetAddress1": "Smolna",
|
||||
"streetAddress2": "13/1",
|
||||
"city": "Wrocław",
|
||||
"postalCode": "53-346",
|
||||
"country": "PL",
|
||||
"countryArea": "Dolny Śląsk",
|
||||
"phone": "123456787"
|
||||
}
|
||||
}
|
36
cypress/integration/dashboard.js
Normal file
36
cypress/integration/dashboard.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
// import { DASHBOARD_SELECTORS } from "../elements/dashboard/dashboard-selectors";
|
||||
|
||||
// // <reference types="cypress" />
|
||||
// describe("User authorization", () => {
|
||||
// beforeEach(() => {
|
||||
// cy.clearSessionData().loginUserViaRequest();
|
||||
// });
|
||||
|
||||
// xit("should all elements be visible on the dashboard", () => {
|
||||
// cy.visit("/");
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.sales);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.orders);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.activity);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.topProducts);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.ordersReadyToFulfill);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.paymentsWaitingForCapture);
|
||||
// softAssertVisibility(DASHBOARD_SELECTORS.productsOutOfStock);
|
||||
// });
|
||||
|
||||
// xit("aa", () => {
|
||||
// // cy.fixture('addresses').then((json) => {
|
||||
// // cy.createCustomer("Test9","Test9", json.plAddress);
|
||||
// // });
|
||||
// // createChannel();
|
||||
// // createRateShipping();
|
||||
// // addChannelToProduct();
|
||||
// // createOrder();
|
||||
// });
|
||||
|
||||
// function softAssertVisibility(selector){
|
||||
// const {softExpect} = chai;
|
||||
// cy.get(selector).then( element => {
|
||||
// softExpect(element).to.be.visible;
|
||||
// })
|
||||
// }
|
||||
// });
|
37
cypress/support/customer/index.js
Normal file
37
cypress/support/customer/index.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
Cypress.Commands.add(
|
||||
"createCustomer",
|
||||
(email, name, address, isActive = false) => {
|
||||
const mustation = `
|
||||
mutation{
|
||||
customerCreate(input:{
|
||||
firstName: "${name}"
|
||||
lastName: "${name}"
|
||||
email: "${email}"
|
||||
isActive: ${isActive}
|
||||
defaultBillingAddress: {
|
||||
companyName: "${address.companyName}"
|
||||
streetAddress1: "${address.streetAddress1}"
|
||||
streetAddress2: "${address.streetAddress2}"
|
||||
city: "${address.city}"
|
||||
postalCode: "${address.postalCode}"
|
||||
country: ${address.country}
|
||||
phone: "${address.phone}"
|
||||
}
|
||||
defaultShippingAddress: {
|
||||
companyName: "${address.companyName}"
|
||||
streetAddress1: "${address.streetAddress1}"
|
||||
streetAddress2: "${address.streetAddress2}"
|
||||
city: "${address.city}"
|
||||
postalCode: "${address.postalCode}"
|
||||
country: ${address.country}
|
||||
phone: "${address.phone}"
|
||||
}
|
||||
}){
|
||||
accountErrors{
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
}
|
||||
);
|
|
@ -1,4 +1,7 @@
|
|||
import "./user";
|
||||
import "./softAsserations";
|
||||
import "./customer";
|
||||
import "./shippingMethod";
|
||||
|
||||
Cypress.Commands.add("clearSessionData", () => {
|
||||
// Because of known cypress bug, not all local storage data are cleared.
|
||||
|
|
48
cypress/support/shippingMethod.js
Normal file
48
cypress/support/shippingMethod.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
Cypress.Commands.add("createShippingRate", (name, shippingZone) => {
|
||||
const mutation = `
|
||||
mutation{
|
||||
CreateShippingRate(input:{
|
||||
maximumDeliveryDays: null
|
||||
minimumDeliveryDays: null
|
||||
name: "${name}"
|
||||
shippingZone: "${shippingZone}"
|
||||
type: "PRICE"
|
||||
})
|
||||
}
|
||||
`;
|
||||
});
|
||||
|
||||
Cypress.Commands.add("createShippingZone", (name, country) => {
|
||||
const mutation = `
|
||||
mutation{
|
||||
shippingZoneCreate(input:{
|
||||
name: "${name}"
|
||||
countries: "${country}"
|
||||
}){
|
||||
shippingZone{
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
});
|
||||
|
||||
Cypress.Commands.add("", (shippingRateId, channelId) => {
|
||||
const mutation = `
|
||||
mutation{
|
||||
shippingMethodChannelListingUpdate(id:"${shippingRateId}", input:{
|
||||
addChannels: {
|
||||
channelId:"${channelId}"
|
||||
}
|
||||
}){
|
||||
shippingMethod{
|
||||
id
|
||||
}
|
||||
shippingErrors{
|
||||
code
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
});
|
81
cypress/support/softAsserations/index.js
Normal file
81
cypress/support/softAsserations/index.js
Normal file
|
@ -0,0 +1,81 @@
|
|||
// let isSoftAssertion = false;
|
||||
// let errors = [];
|
||||
|
||||
// chai.softExpect = function ( ...args ) {
|
||||
// isSoftAssertion = true;
|
||||
// return chai.expect(...args);
|
||||
// },
|
||||
// chai.softAssert = function ( ...args ) {
|
||||
// isSoftAssertion = true;
|
||||
// return chai.assert(...args);
|
||||
// }
|
||||
|
||||
// const origAssert = chai.Assertion.prototype.assert;
|
||||
// chai.Assertion.prototype.assert = function (...args) {
|
||||
// if ( isSoftAssertion ) {
|
||||
// try {
|
||||
// origAssert.call(this, ...args)
|
||||
// } catch ( error ) {
|
||||
// errors.push(error);
|
||||
// }
|
||||
// isSoftAssertion = false;
|
||||
// } else {
|
||||
|
||||
// origAssert.call(this, ...args)
|
||||
// }
|
||||
// };
|
||||
|
||||
// // monkey-patch `Cypress.log` so that the last `cy.then()` isn't logged to command log
|
||||
// const origLog = Cypress.log;
|
||||
// Cypress.log = function ( data ) {
|
||||
// if ( data && data.error && /soft assertions/i.test(data.error.message) ) {
|
||||
// data.error.message = '\n\n\t' + data.error.message + '\n\n';
|
||||
// throw data.error;
|
||||
// }
|
||||
// return origLog.call(Cypress, ...arguments);
|
||||
// };
|
||||
|
||||
// // monkey-patch `it` callback so we insert `cy.then()` as a last command
|
||||
// // to each test case where we'll assert if there are any soft assertion errors
|
||||
// function itCallback ( func ) {
|
||||
// func();
|
||||
// cy.then(() => {
|
||||
// if ( errors.length ) {
|
||||
// const _ = Cypress._;
|
||||
// let msg = '';
|
||||
|
||||
// if ( Cypress.browser.isHeaded ) {
|
||||
|
||||
// msg = 'Failed soft assertions... check log above ↑';
|
||||
// } else {
|
||||
|
||||
// _.each( errors, error => {
|
||||
// msg += '\n' + error;
|
||||
// });
|
||||
|
||||
// msg = msg.replace(/^/gm, '\t');
|
||||
// }
|
||||
|
||||
// throw new Error(msg);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// const origIt = window.it;
|
||||
// window.it = (title, func) => {
|
||||
// origIt(title, func && (() => itCallback(func)));
|
||||
// };
|
||||
// window.it.only = (title, func) => {
|
||||
// origIt.only(title, func && (() => itCallback(func)));
|
||||
// };
|
||||
// window.it.skip = (title, func) => {
|
||||
// origIt.skip(title, func);
|
||||
// };
|
||||
|
||||
// beforeEach(() => {
|
||||
// errors = [];
|
||||
// });
|
||||
// afterEach(() => {
|
||||
// errors = [];
|
||||
// isSoftAssertion = false;
|
||||
// });
|
Loading…
Reference in a new issue