merge (#1726)
This commit is contained in:
parent
e36da6df28
commit
8d20394518
12 changed files with 272 additions and 22 deletions
|
@ -8,8 +8,8 @@ export const SHIPPING_RATE_DETAILS = {
|
||||||
min: '[name="min"]',
|
min: '[name="min"]',
|
||||||
max: '[name="max"]'
|
max: '[name="max"]'
|
||||||
},
|
},
|
||||||
maxWeightInput: '[name="maxValue"]',
|
maxWeightInput: '[name*="maxValue"]',
|
||||||
minWeightInput: '[name="minValue"]',
|
minWeightInput: '[name*="minValue"]',
|
||||||
minDeliveryTimeInput: '[name="minDays"]',
|
minDeliveryTimeInput: '[name="minDays"]',
|
||||||
maxDeliveryTimeInput: '[name="maxDays"]'
|
maxDeliveryTimeInput: '[name="maxDays"]'
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export const SHIPPING_ZONE_DETAILS = {
|
export const SHIPPING_ZONE_DETAILS = {
|
||||||
assignCountryButton: "[data-test-id='assign-country']",
|
assignCountryButton: "[data-test-id='assign-country']",
|
||||||
|
descriptionInput: "[name='description']",
|
||||||
submitAssignCountry: "[type='submit']",
|
submitAssignCountry: "[type='submit']",
|
||||||
searchInput: "[name='query']",
|
searchInput: "[name='query']",
|
||||||
tableRow: "[class*='MuiTableRow']",
|
tableRow: "[class*='MuiTableRow']",
|
||||||
|
|
|
@ -18,6 +18,7 @@ export const urlList = {
|
||||||
pageTypes: "page-types/",
|
pageTypes: "page-types/",
|
||||||
permissionsGroups: "permission-groups/",
|
permissionsGroups: "permission-groups/",
|
||||||
plugins: "plugins/",
|
plugins: "plugins/",
|
||||||
|
priceRate: "price/",
|
||||||
products: "products/",
|
products: "products/",
|
||||||
productTypes: "product-types/",
|
productTypes: "product-types/",
|
||||||
sales: "discounts/sales/",
|
sales: "discounts/sales/",
|
||||||
|
@ -79,6 +80,9 @@ export const userDetailsUrl = userId => `${urlList.staffMembers}${userId}`;
|
||||||
export const weightRateUrl = (shippingZoneId, weightRateId) =>
|
export const weightRateUrl = (shippingZoneId, weightRateId) =>
|
||||||
`${urlList.shippingMethods}${shippingZoneId}/${urlList.weightRete}${weightRateId}`;
|
`${urlList.shippingMethods}${shippingZoneId}/${urlList.weightRete}${weightRateId}`;
|
||||||
|
|
||||||
|
export const priceRateUrl = (shippingZoneId, priceRateId) =>
|
||||||
|
`${urlList.shippingMethods}${shippingZoneId}/${urlList.priceRate}${priceRateId}`;
|
||||||
|
|
||||||
export const warehouseDetailsUrl = warehouseId =>
|
export const warehouseDetailsUrl = warehouseId =>
|
||||||
`${urlList.warehouses}${warehouseId}`;
|
`${urlList.warehouses}${warehouseId}`;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
// / <reference types="cypress"/>
|
||||||
|
// / <reference types="../../../support"/>
|
||||||
|
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { priceRateUrl } from "../../../fixtures/urlList";
|
||||||
|
import {
|
||||||
|
addChannelToShippingMethod,
|
||||||
|
createShippingRate,
|
||||||
|
createShippingZone,
|
||||||
|
getShippingZone
|
||||||
|
} from "../../../support/api/requests/ShippingMethod";
|
||||||
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
|
||||||
|
import filterTests from "../../../support/filterTests";
|
||||||
|
import {
|
||||||
|
fillUpShippingRate,
|
||||||
|
saveRateAfterUpdate
|
||||||
|
} from "../../../support/pages/shippingMethodPage";
|
||||||
|
|
||||||
|
filterTests({ definedTags: ["all"] }, () => {
|
||||||
|
describe("Edit shipping method", () => {
|
||||||
|
const startsWith = "EditShipping-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const price = 10;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let shippingZone;
|
||||||
|
let shippingMethod;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
createShippingZone(name, "US", defaultChannel.id);
|
||||||
|
})
|
||||||
|
.then(shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
createShippingRate({
|
||||||
|
name: rateName,
|
||||||
|
shippingZone: shippingZone.id
|
||||||
|
}).then(({ shippingMethod: shippingResp }) => {
|
||||||
|
shippingMethod = shippingResp;
|
||||||
|
addChannelToShippingMethod(shippingMethod.id, defaultChannel.id, 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Update shipping rate", () => {
|
||||||
|
const updatedRateName = `${startsWith}Updated`;
|
||||||
|
const deliveryTime = { min: 1, max: 7 };
|
||||||
|
|
||||||
|
cy.visit(priceRateUrl(shippingZone.id, shippingMethod.id));
|
||||||
|
fillUpShippingRate({
|
||||||
|
rateName: updatedRateName,
|
||||||
|
price,
|
||||||
|
deliveryTime
|
||||||
|
});
|
||||||
|
saveRateAfterUpdate();
|
||||||
|
getShippingZone(shippingZone.id).then(({ shippingMethods }) => {
|
||||||
|
expect(shippingMethods).to.have.length(1);
|
||||||
|
chai
|
||||||
|
.softExpect(shippingMethods[0].minimumDeliveryDays)
|
||||||
|
.to.be.eq(deliveryTime.min);
|
||||||
|
chai
|
||||||
|
.softExpect(shippingMethods[0].maximumDeliveryDays)
|
||||||
|
.to.be.eq(deliveryTime.max);
|
||||||
|
chai
|
||||||
|
.softExpect(shippingMethods[0].channelListings[0].price.amount)
|
||||||
|
.to.be.eq(price);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Delete shipping rate", () => {
|
||||||
|
cy.visit(
|
||||||
|
priceRateUrl(shippingZone.id, shippingMethod.id)
|
||||||
|
).deleteElementWithReqAlias("DeleteShippingRate");
|
||||||
|
getShippingZone(shippingZone.id).then(({ shippingMethods }) => {
|
||||||
|
const deletedShipping = shippingMethods.find(
|
||||||
|
element => element.id === shippingMethod.id
|
||||||
|
);
|
||||||
|
expect(deletedShipping).to.be.not.ok;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,79 @@
|
||||||
|
// / <reference types="cypress"/>
|
||||||
|
// / <reference types="../../../support"/>
|
||||||
|
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
|
import { shippingZoneDetailsUrl } from "../../../fixtures/urlList";
|
||||||
|
import {
|
||||||
|
createShippingZone,
|
||||||
|
getShippingZone
|
||||||
|
} from "../../../support/api/requests/ShippingMethod";
|
||||||
|
import { createWarehouse } from "../../../support/api/requests/Warehouse";
|
||||||
|
import { getDefaultChannel } from "../../../support/api/utils/channelsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils";
|
||||||
|
import filterTests from "../../../support/filterTests";
|
||||||
|
import { fillUpShippingZoneData } from "../../../support/pages/shippingMethodPage";
|
||||||
|
|
||||||
|
filterTests({ definedTags: ["all"] }, () => {
|
||||||
|
describe("Edit shipping zone", () => {
|
||||||
|
const startsWith = "EditShipping-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let shippingZone;
|
||||||
|
let plAddress;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
plAddress = addresses.plAddress;
|
||||||
|
createWarehouse({ name, address: plAddress });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
createShippingZone(name, "US", defaultChannel.id).then(
|
||||||
|
shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Update shipping zone", () => {
|
||||||
|
const updatedName = `${startsWith}Updated`;
|
||||||
|
|
||||||
|
cy.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||||
|
fillUpShippingZoneData({
|
||||||
|
channelName: defaultChannel.name,
|
||||||
|
country: "Poland",
|
||||||
|
shippingName: updatedName,
|
||||||
|
warehouseName: name
|
||||||
|
});
|
||||||
|
getShippingZone(shippingZone.id).then(shippingZone => {
|
||||||
|
chai.softExpect(shippingZone.channels).to.have.length(0);
|
||||||
|
chai.softExpect(shippingZone.name).to.eq(updatedName);
|
||||||
|
chai.softExpect(shippingZone.description).to.eq(updatedName);
|
||||||
|
chai.softExpect(shippingZone.warehouses[0].name).to.eq(name);
|
||||||
|
expect(shippingZone.countries.find(el => el.code === "PL")).to.be.ok;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Delete shipping zone", () => {
|
||||||
|
cy.visit(
|
||||||
|
shippingZoneDetailsUrl(shippingZone.id)
|
||||||
|
).deleteElementWithReqAlias("DeleteShippingZone");
|
||||||
|
getShippingZone(shippingZone.id).should("be.null");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -137,6 +137,14 @@ export function getShippingZone(shippingZoneId) {
|
||||||
shippingZone(id:"${shippingZoneId}"){
|
shippingZone(id:"${shippingZoneId}"){
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
description
|
||||||
|
warehouses{
|
||||||
|
name
|
||||||
|
id
|
||||||
|
}
|
||||||
|
countries{
|
||||||
|
code
|
||||||
|
}
|
||||||
channels{
|
channels{
|
||||||
name
|
name
|
||||||
id
|
id
|
||||||
|
@ -144,6 +152,25 @@ export function getShippingZone(shippingZoneId) {
|
||||||
shippingMethods{
|
shippingMethods{
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
minimumDeliveryDays
|
||||||
|
maximumDeliveryDays
|
||||||
|
minimumOrderWeight{
|
||||||
|
value
|
||||||
|
}
|
||||||
|
maximumOrderWeight{
|
||||||
|
value
|
||||||
|
}
|
||||||
|
channelListings{
|
||||||
|
price{
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
minimumOrderPrice{
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
maximumOrderPrice{
|
||||||
|
amount
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
|
@ -42,7 +42,7 @@ export function createShipping({
|
||||||
}
|
}
|
||||||
export function createShippingRate({ name, shippingZoneId }) {
|
export function createShippingRate({ name, shippingZoneId }) {
|
||||||
return shippingMethodRequest
|
return shippingMethodRequest
|
||||||
.createShippingRate({ name, shippingZoneId })
|
.createShippingRate({ name, shippingZone: shippingZoneId })
|
||||||
.its("body.data.shippingPriceCreate.shippingMethod");
|
.its("body.data.shippingPriceCreate.shippingMethod");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
||||||
|
|
||||||
// export function confirmationMessageShouldDisappear() {
|
|
||||||
// cy.get(SHARED_ELEMENTS.notificationSuccess)
|
|
||||||
// .should("be.visible")
|
|
||||||
// .get(SHARED_ELEMENTS.notificationSuccess)
|
|
||||||
// .should("not.exist");
|
|
||||||
// }
|
|
||||||
|
|
||||||
Cypress.Commands.add("confirmationMessageShouldDisappear", () => {
|
Cypress.Commands.add("confirmationMessageShouldDisappear", () => {
|
||||||
cy.get(SHARED_ELEMENTS.notificationSuccess)
|
cy.get(SHARED_ELEMENTS.notificationSuccess)
|
||||||
.should("be.visible")
|
.should("be.visible")
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
|
|
||||||
|
Cypress.Commands.add("deleteElementWithReqAlias", alias =>
|
||||||
|
cy
|
||||||
|
.get(BUTTON_SELECTORS.deleteButton)
|
||||||
|
.click()
|
||||||
|
.addAliasToGraphRequest(alias)
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.click()
|
||||||
|
.waitForRequestAndCheckIfNoErrors(`@${alias}`)
|
||||||
|
);
|
1
cypress/support/index.d.ts
vendored
1
cypress/support/index.d.ts
vendored
|
@ -49,5 +49,6 @@ declare namespace Cypress {
|
||||||
findElementOnTable(elementName: string): Chainable<any>;
|
findElementOnTable(elementName: string): Chainable<any>;
|
||||||
searchInTable(query: string): Chainable<any>;
|
searchInTable(query: string): Chainable<any>;
|
||||||
waitForRequestAndCheckIfNoErrors(alias: string): Chainable<any>;
|
waitForRequestAndCheckIfNoErrors(alias: string): Chainable<any>;
|
||||||
|
deleteElementWithReqAlias(alias: string): Chainable<any>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import "./customCommands/sharedElementsOperations/confirmationMessages.js";
|
||||||
import "./customCommands/sharedElementsOperations/progressBar.js";
|
import "./customCommands/sharedElementsOperations/progressBar.js";
|
||||||
import "./customCommands/sharedElementsOperations/selects.js";
|
import "./customCommands/sharedElementsOperations/selects.js";
|
||||||
import "./customCommands/sharedElementsOperations/tables";
|
import "./customCommands/sharedElementsOperations/tables";
|
||||||
|
import "./customCommands/sharedElementsOperations/deleteElement";
|
||||||
import "cypress-mailhog";
|
import "cypress-mailhog";
|
||||||
import "cypress-file-upload";
|
import "cypress-file-upload";
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,25 @@ export function createShippingZone(
|
||||||
country,
|
country,
|
||||||
channelName
|
channelName
|
||||||
) {
|
) {
|
||||||
cy.get(SHIPPING_ZONES_LIST.addShippingZone)
|
cy.get(SHIPPING_ZONES_LIST.addShippingZone).click();
|
||||||
.click()
|
fillUpShippingZoneData({
|
||||||
.get(SHIPPING_ZONE_DETAILS.nameInput)
|
shippingName,
|
||||||
.type(shippingName)
|
warehouseName,
|
||||||
|
country,
|
||||||
|
channelName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fillUpShippingZoneData({
|
||||||
|
shippingName,
|
||||||
|
warehouseName,
|
||||||
|
country,
|
||||||
|
channelName
|
||||||
|
}) {
|
||||||
|
cy.get(SHIPPING_ZONE_DETAILS.nameInput)
|
||||||
|
.clearAndType(shippingName)
|
||||||
|
.get(SHIPPING_ZONE_DETAILS.descriptionInput)
|
||||||
|
.clearAndType(shippingName)
|
||||||
.get(SHIPPING_ZONE_DETAILS.assignCountryButton)
|
.get(SHIPPING_ZONE_DETAILS.assignCountryButton)
|
||||||
.click()
|
.click()
|
||||||
.get(SHIPPING_ZONE_DETAILS.searchInput)
|
.get(SHIPPING_ZONE_DETAILS.searchInput)
|
||||||
|
@ -32,7 +47,8 @@ export function createShippingZone(
|
||||||
.type(warehouseName)
|
.type(warehouseName)
|
||||||
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
|
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
|
||||||
.scrollTo("bottom");
|
.scrollTo("bottom");
|
||||||
cy.contains(SHIPPING_ZONE_DETAILS.option, warehouseName)
|
return cy
|
||||||
|
.contains(SHIPPING_ZONE_DETAILS.option, warehouseName)
|
||||||
.click({ force: true })
|
.click({ force: true })
|
||||||
.get(SHIPPING_ZONE_DETAILS.channelSelector)
|
.get(SHIPPING_ZONE_DETAILS.channelSelector)
|
||||||
.click()
|
.click()
|
||||||
|
@ -80,13 +96,26 @@ export function enterAndFillUpShippingRate({
|
||||||
weightLimits,
|
weightLimits,
|
||||||
deliveryTime
|
deliveryTime
|
||||||
}) {
|
}) {
|
||||||
cy.get(rateOption)
|
cy.get(rateOption).click();
|
||||||
.click()
|
fillUpShippingRate({
|
||||||
.waitForProgressBarToNotBeVisible()
|
rateName,
|
||||||
|
price,
|
||||||
|
weightLimits,
|
||||||
|
deliveryTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fillUpShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
weightLimits,
|
||||||
|
deliveryTime
|
||||||
|
}) {
|
||||||
|
cy.waitForProgressBarToNotBeVisible()
|
||||||
.get(SHARED_ELEMENTS.richTextEditor.empty)
|
.get(SHARED_ELEMENTS.richTextEditor.empty)
|
||||||
.should("exist")
|
.should("exist")
|
||||||
.get(SHIPPING_RATE_DETAILS.inputName)
|
.get(SHIPPING_RATE_DETAILS.inputName)
|
||||||
.type(rateName);
|
.clearAndType(rateName);
|
||||||
if (deliveryTime) {
|
if (deliveryTime) {
|
||||||
fillUpDeliveryTime(deliveryTime);
|
fillUpDeliveryTime(deliveryTime);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +123,7 @@ export function enterAndFillUpShippingRate({
|
||||||
fillUpWeightLimits(weightLimits);
|
fillUpWeightLimits(weightLimits);
|
||||||
}
|
}
|
||||||
cy.get(SHIPPING_RATE_DETAILS.priceInput).each($priceInput => {
|
cy.get(SHIPPING_RATE_DETAILS.priceInput).each($priceInput => {
|
||||||
cy.wrap($priceInput).type(price);
|
cy.wrap($priceInput).clearAndType(price);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +161,15 @@ export function saveRate() {
|
||||||
.its("response.body.0.data.shippingZone");
|
.its("response.body.0.data.shippingZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function saveRateAfterUpdate() {
|
||||||
|
return cy
|
||||||
|
.addAliasToGraphRequest("ShippingMethodChannelListingUpdate")
|
||||||
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
.click()
|
||||||
|
.confirmationMessageShouldDisappear()
|
||||||
|
.waitForRequestAndCheckIfNoErrors(`@ShippingMethodChannelListingUpdate`);
|
||||||
|
}
|
||||||
|
|
||||||
export function fillUpWeightLimits({ max, min }) {
|
export function fillUpWeightLimits({ max, min }) {
|
||||||
cy.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
cy.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
||||||
.type(min)
|
.type(min)
|
||||||
|
@ -141,9 +179,9 @@ export function fillUpWeightLimits({ max, min }) {
|
||||||
|
|
||||||
export function fillUpDeliveryTime({ min, max }) {
|
export function fillUpDeliveryTime({ min, max }) {
|
||||||
cy.get(SHIPPING_RATE_DETAILS.minDeliveryTimeInput)
|
cy.get(SHIPPING_RATE_DETAILS.minDeliveryTimeInput)
|
||||||
.type(min)
|
.clearAndType(min)
|
||||||
.get(SHIPPING_RATE_DETAILS.maxDeliveryTimeInput)
|
.get(SHIPPING_RATE_DETAILS.maxDeliveryTimeInput)
|
||||||
.type(max);
|
.clearAndType(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rateOptions = {
|
export const rateOptions = {
|
||||||
|
|
Loading…
Reference in a new issue