tests for shipping (#1173)
* tests for shipping * fix typo Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com> * add data-test-id Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
This commit is contained in:
parent
ab54fc6d68
commit
e76c78a23b
35 changed files with 960 additions and 353 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { stringify } from "../support/format/formatJson";
|
import { stringify } from "../support/format/formatJson";
|
||||||
import { getValueWithDefault } from "./utils/Utils";
|
import { getValueWithDefault, getVariantsListIds } from "./utils/Utils";
|
||||||
|
|
||||||
export function getFirstProducts(first, search) {
|
export function getFirstProducts(first, search) {
|
||||||
const filter = search
|
const filter = search
|
||||||
|
@ -143,7 +143,8 @@ export function createVariant({
|
||||||
attributeId,
|
attributeId,
|
||||||
price = 1,
|
price = 1,
|
||||||
costPrice = 1,
|
costPrice = 1,
|
||||||
trackInventory = true
|
trackInventory = true,
|
||||||
|
weight = 1
|
||||||
}) {
|
}) {
|
||||||
const channelListings = getValueWithDefault(
|
const channelListings = getValueWithDefault(
|
||||||
channelId,
|
channelId,
|
||||||
|
@ -168,6 +169,7 @@ export function createVariant({
|
||||||
id:"${attributeId}"
|
id:"${attributeId}"
|
||||||
values: ["value"]
|
values: ["value"]
|
||||||
}]
|
}]
|
||||||
|
weight: ${weight}
|
||||||
sku: "${sku}"
|
sku: "${sku}"
|
||||||
${channelListings}
|
${channelListings}
|
||||||
trackInventory:${trackInventory}
|
trackInventory:${trackInventory}
|
||||||
|
@ -199,3 +201,23 @@ export function deleteProduct(productId) {
|
||||||
} `;
|
} `;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getVariants(variantsList) {
|
||||||
|
const variantsIds = getVariantsListIds(variantsList);
|
||||||
|
const query = `query{
|
||||||
|
productVariants(first:100 ids:[${variantsIds}]){
|
||||||
|
edges{
|
||||||
|
node{
|
||||||
|
stocks{
|
||||||
|
warehouse{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
quantity
|
||||||
|
quantityAllocated
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(query).its("body.data.productVariants");
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,28 @@
|
||||||
import { getValueWithDefault } from "./utils/Utils";
|
import { getValueWithDefault } from "./utils/Utils";
|
||||||
|
|
||||||
export function createShippingRate({ name, shippingZoneId }) {
|
export function createShippingRate({
|
||||||
|
name,
|
||||||
|
shippingZone,
|
||||||
|
type = "PRICE",
|
||||||
|
maxWeight,
|
||||||
|
minWeight
|
||||||
|
}) {
|
||||||
|
const maxOrderWeight = getValueWithDefault(
|
||||||
|
maxWeight,
|
||||||
|
`maximumOrderWeight: ${maxWeight}`
|
||||||
|
);
|
||||||
|
const minOrderWeight = getValueWithDefault(
|
||||||
|
minWeight,
|
||||||
|
`minimumOrderWeight: ${minWeight}`
|
||||||
|
);
|
||||||
|
|
||||||
const mutation = `mutation{
|
const mutation = `mutation{
|
||||||
shippingPriceCreate(input:{
|
shippingPriceCreate(input:{
|
||||||
name: "${name}"
|
name: "${name}"
|
||||||
shippingZone: "${shippingZoneId}"
|
shippingZone: "${shippingZone}"
|
||||||
type: PRICE
|
type: ${type}
|
||||||
|
${minOrderWeight}
|
||||||
|
${maxOrderWeight}
|
||||||
}){
|
}){
|
||||||
shippingMethod{
|
shippingMethod{
|
||||||
id
|
id
|
||||||
|
@ -16,7 +33,7 @@ export function createShippingRate({ name, shippingZoneId }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation).its("body.data.shippingPriceCreate");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createShippingZone(name, country, channelId) {
|
export function createShippingZone(name, country, channelId) {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { urlList } from "../url/urlList";
|
||||||
|
|
||||||
export function getStaffMembersStartsWith(startsWith) {
|
export function getStaffMembersStartsWith(startsWith) {
|
||||||
const query = `query{
|
const query = `query{
|
||||||
staffUsers(first:100 filter:{
|
staffUsers(first:100 filter:{
|
||||||
|
@ -13,3 +15,74 @@ export function getStaffMembersStartsWith(startsWith) {
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(query);
|
return cy.sendRequestWithQuery(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function inviteStaffMember({
|
||||||
|
email,
|
||||||
|
isActive = true,
|
||||||
|
firstName = "",
|
||||||
|
lastName = "",
|
||||||
|
permissionId
|
||||||
|
}) {
|
||||||
|
const mutation = `mutation createStaff{
|
||||||
|
staffCreate(input:{
|
||||||
|
firstName: "${firstName}"
|
||||||
|
lastName: "${lastName}"
|
||||||
|
email: "${email}",
|
||||||
|
isActive: ${isActive},
|
||||||
|
addGroups:"${permissionId}"
|
||||||
|
redirectUrl: "${Cypress.config().baseUrl}${urlList.newPassword}"
|
||||||
|
}){
|
||||||
|
user{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
return cy.sendRequestWithQuery(mutation).its("body.data.staffCreate");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateStaffMember({ userId, isActive }) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
staffUpdate(id:"${userId}", input:{
|
||||||
|
isActive:${isActive}
|
||||||
|
}){
|
||||||
|
user{
|
||||||
|
id
|
||||||
|
}
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation).its("body.data.staffUpdate");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteStaffMember(staffId) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
staffDelete(id:"${staffId}"){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation).its("body.data.staffDelete");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteStaffMembersStartsWith(startsWith) {
|
||||||
|
getStaffMembersStartsWith(startsWith).then(resp => {
|
||||||
|
if (resp.body.data.staffUsers) {
|
||||||
|
const staffMembers = resp.body.data.staffUsers.edges;
|
||||||
|
staffMembers.forEach(element => {
|
||||||
|
if (element.node.email.includes(startsWith)) {
|
||||||
|
deleteStaffMember(element.node.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
16
cypress/apiRequests/shopSettings.js
Normal file
16
cypress/apiRequests/shopSettings.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
export function updateShopWeightUnit(weightUnit) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
shopSettingsUpdate(input:{
|
||||||
|
defaultWeightUnit: ${weightUnit}
|
||||||
|
}){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
shop{
|
||||||
|
defaultWeightUnit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation).its("body.data.shopSettingsUpdate");
|
||||||
|
}
|
|
@ -1,88 +0,0 @@
|
||||||
import { urlList } from "../url/urlList";
|
|
||||||
|
|
||||||
export function getStaffMembersStartsWith(startsWith) {
|
|
||||||
const query = `query{
|
|
||||||
staffUsers(first:100 filter:{
|
|
||||||
search:"${startsWith}"
|
|
||||||
}){
|
|
||||||
edges{
|
|
||||||
node{
|
|
||||||
id
|
|
||||||
email
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
return cy.sendRequestWithQuery(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inviteStaffMember({
|
|
||||||
email,
|
|
||||||
isActive = true,
|
|
||||||
firstName = "",
|
|
||||||
lastName = "",
|
|
||||||
permissionId
|
|
||||||
}) {
|
|
||||||
const mutation = `mutation createStaff{
|
|
||||||
staffCreate(input:{
|
|
||||||
firstName: "${firstName}"
|
|
||||||
lastName: "${lastName}"
|
|
||||||
email: "${email}",
|
|
||||||
isActive: ${isActive},
|
|
||||||
addGroups:"${permissionId}"
|
|
||||||
redirectUrl: "${Cypress.config().baseUrl}${urlList.newPassword}"
|
|
||||||
}){
|
|
||||||
user{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
errors{
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
return cy.sendRequestWithQuery(mutation).its("body.data.staffCreate");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateStaffMember({ userId, isActive }) {
|
|
||||||
const mutation = `mutation{
|
|
||||||
staffUpdate(id:"${userId}", input:{
|
|
||||||
isActive:${isActive}
|
|
||||||
}){
|
|
||||||
user{
|
|
||||||
id
|
|
||||||
}
|
|
||||||
errors{
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
return cy.sendRequestWithQuery(mutation).its("body.data.staffUpdate");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteStaffMember(staffId) {
|
|
||||||
const mutation = `mutation{
|
|
||||||
staffDelete(id:"${staffId}"){
|
|
||||||
errors{
|
|
||||||
field
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`;
|
|
||||||
return cy.sendRequestWithQuery(mutation).its("body.data.staffDelete");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteStaffMembersStartsWith(startsWith) {
|
|
||||||
getStaffMembersStartsWith(startsWith).then(resp => {
|
|
||||||
if (resp.body.data.staffUsers) {
|
|
||||||
const staffMembers = resp.body.data.staffUsers.edges;
|
|
||||||
staffMembers.forEach(element => {
|
|
||||||
if (element.node.email.includes(startsWith)) {
|
|
||||||
deleteStaffMember(element.node.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -19,12 +19,18 @@ export function getDefaultAddress(address, addressType, withName = true) {
|
||||||
}
|
}
|
||||||
return `${addressType}:{${defaultAddress}}`;
|
return `${addressType}:{${defaultAddress}}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVariantsLines(variantsList, quantity) {
|
export function getVariantsLines(variantsList, quantity) {
|
||||||
return variantsList.map(
|
return variantsList.map(
|
||||||
variant => `{quantity:${quantity}
|
variant => `{quantity:${quantity}
|
||||||
variantId:"${variant.id}"}`
|
variantId:"${variant.id}"}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getVariantsListIds(variantsList) {
|
||||||
|
return variantsList.map(variant => `"${variant.id}"`).join();
|
||||||
|
}
|
||||||
|
|
||||||
export const getPaymentDataLine = paymentData =>
|
export const getPaymentDataLine = paymentData =>
|
||||||
paymentData
|
paymentData
|
||||||
? `, paymentData:"{\\"riskData\\":{\\"clientData\\":\\"${paymentData.clientData}\\"}, \\"paymentMethod\\":{\\"type\\":\\"scheme\\", \\"encryptedCardNumber\\":\\"${paymentData.encryptedCardNumber}\\", \\"encryptedExpiryMonth\\":\\"${paymentData.encryptedExpiryMonth}\\", \\"encryptedExpiryYear\\":\\"${paymentData.encryptedExpiryYear}\\", \\"encryptedSecurityCode\\":\\"${paymentData.encryptedSecurityCode}\\", \\"brand\\":\\"${paymentData.brand}\\"}}"`
|
? `, paymentData:"{\\"riskData\\":{\\"clientData\\":\\"${paymentData.clientData}\\"}, \\"paymentMethod\\":{\\"type\\":\\"scheme\\", \\"encryptedCardNumber\\":\\"${paymentData.encryptedCardNumber}\\", \\"encryptedExpiryMonth\\":\\"${paymentData.encryptedExpiryMonth}\\", \\"encryptedExpiryYear\\":\\"${paymentData.encryptedExpiryYear}\\", \\"encryptedSecurityCode\\":\\"${paymentData.encryptedSecurityCode}\\", \\"brand\\":\\"${paymentData.brand}\\"}}"`
|
||||||
|
|
|
@ -3,8 +3,14 @@ export const SHARED_ELEMENTS = {
|
||||||
progressBar: '[role="progressbar"]',
|
progressBar: '[role="progressbar"]',
|
||||||
skeleton: '[data-test-id="skeleton"]',
|
skeleton: '[data-test-id="skeleton"]',
|
||||||
table: 'table[class*="Table"]',
|
table: 'table[class*="Table"]',
|
||||||
confirmationMsg: "[data-test='notification-success']"
|
notificationSuccess: '[data-test="notification-success"]',
|
||||||
|
confirmationMsg: "[data-test='notification-success']",
|
||||||
|
richTextEditor: {
|
||||||
|
empty: '[class*="codex-editor--empty"]'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const selectorWithDataValue = value => `[data-value="${value}"]`;
|
||||||
|
|
||||||
export const getElementByDataTestId = dataTestId =>
|
export const getElementByDataTestId = dataTestId =>
|
||||||
`[data-test-id=${dataTestId}]`;
|
`[data-test-id=${dataTestId}]`;
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
export const SHIPPING_RATE_DETAILS = {
|
export const SHIPPING_RATE_DETAILS = {
|
||||||
inputName: "[name='name']",
|
inputName: "[name='name']",
|
||||||
priceInput: "[name='price']"
|
priceInput: "[name='price']",
|
||||||
|
includePostalCodesCheckbox: '[value="INCLUDE"]',
|
||||||
|
excludePostalCodesCheckbox: '[value="EXCLUDE"]',
|
||||||
|
addPostalCodesButton: '[data-test="add-postal-code-range"]',
|
||||||
|
postalCodesForm: {
|
||||||
|
min: '[name="min"]',
|
||||||
|
max: '[name="max"]'
|
||||||
|
},
|
||||||
|
maxWeightInput: '[name="maxValue"]',
|
||||||
|
minWeightInput: '[name="minValue"]',
|
||||||
|
minDeliveryTimeInput: '[name="minDays"]',
|
||||||
|
maxDeliveryTimeInput: '[name="maxDays"]'
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,8 @@ export const SHIPPING_ZONE_DETAILS = {
|
||||||
addWeightRateButton: "[data-test-id='add-weight-rate']",
|
addWeightRateButton: "[data-test-id='add-weight-rate']",
|
||||||
nameInput: "[name='name']",
|
nameInput: "[name='name']",
|
||||||
shippingRatePriceTableCell: "[data-test-id='shipping-rate-price']",
|
shippingRatePriceTableCell: "[data-test-id='shipping-rate-price']",
|
||||||
|
autocompleteContentDialog:
|
||||||
|
"[data-test-id='multiautocomplete-select-content']",
|
||||||
option: "[data-test='multiautocomplete-select-option']",
|
option: "[data-test='multiautocomplete-select-option']",
|
||||||
warehouseSelector: "[placeholder*='Warehouse']",
|
warehouseSelector: "[placeholder*='Warehouse']",
|
||||||
channelSelector: "[placeholder*='Channel']"
|
channelSelector: "[placeholder*='Channel']"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
export const SHIPPING_ZONES_LIST = {
|
export const SHIPPING_ZONES_LIST = {
|
||||||
addShippingZone: "[data-test-id='add-shipping-zone']"
|
addShippingZone: "[data-test-id='add-shipping-zone']",
|
||||||
|
unitSelect: "[id='mui-component-select-unit']",
|
||||||
|
saveUnit: '[data-test-id="saveUnit"]'
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,5 +26,19 @@
|
||||||
"phone": "+12025550189",
|
"phone": "+12025550189",
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"countryFullName": "United States of America"
|
"countryFullName": "United States of America"
|
||||||
|
},
|
||||||
|
"secondUsAddress": {
|
||||||
|
"firstName": "test",
|
||||||
|
"lastName": "test",
|
||||||
|
"companyName": "Test2",
|
||||||
|
"streetAddress1": "Antonio Ridge",
|
||||||
|
"streetAddress2": "34930",
|
||||||
|
"city": "North Patrickfort",
|
||||||
|
"postalCode": "70958",
|
||||||
|
"country": "US",
|
||||||
|
"countryArea": "LA",
|
||||||
|
"phone": "2025550189",
|
||||||
|
"currency": "USD",
|
||||||
|
"countryFullName": "United States of America"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import {
|
||||||
addProductsToCheckout,
|
addProductsToCheckout,
|
||||||
createCheckout
|
createCheckout
|
||||||
} from "../../../apiRequests/Checkout";
|
} from "../../../apiRequests/Checkout";
|
||||||
|
import { getVariants } from "../../../apiRequests/Product";
|
||||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
||||||
import { createOrderWithNewProduct } from "../../../utils/ordersUtils";
|
import { createOrderWithNewProduct } from "../../../utils/ordersUtils";
|
||||||
import {
|
import {
|
||||||
|
@ -80,6 +81,7 @@ describe("Products stocks in checkout", () => {
|
||||||
expect(order, "order should be created").to.be.ok;
|
expect(order, "order should be created").to.be.ok;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not be possible to add product with quantity greater than stock", () => {
|
it("should not be possible to add product with quantity greater than stock", () => {
|
||||||
const productName = `${startsWith}${faker.datatype.number()}`;
|
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||||
let variants;
|
let variants;
|
||||||
|
@ -133,4 +135,28 @@ describe("Products stocks in checkout", () => {
|
||||||
expect(order, "order should be created").to.be.ok;
|
expect(order, "order should be created").to.be.ok;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should change product stock after purchase", () => {
|
||||||
|
const productName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
createOrderWithNewProduct({
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
channel: defaultChannel,
|
||||||
|
name: productName,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
quantityInWarehouse: 10,
|
||||||
|
trackInventory: true,
|
||||||
|
shippingMethodId: shippingMethod.id,
|
||||||
|
address
|
||||||
|
})
|
||||||
|
.then(({ variantsList }) => {
|
||||||
|
getVariants(variantsList);
|
||||||
|
})
|
||||||
|
.then(variantsList => {
|
||||||
|
const variant = variantsList.edges[0];
|
||||||
|
expect(variant.node.stocks[0].quantityAllocated).to.eq(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,224 +0,0 @@
|
||||||
// <reference types="cypress" />
|
|
||||||
import faker from "faker";
|
|
||||||
|
|
||||||
import { createChannel } from "../../../apiRequests/Channels";
|
|
||||||
import { createCheckout } from "../../../apiRequests/Checkout";
|
|
||||||
import {
|
|
||||||
addChannelToShippingMethod,
|
|
||||||
addChannelToShippingZone
|
|
||||||
} from "../../../apiRequests/ShippingMethod";
|
|
||||||
import { createWarehouse } from "../../../apiRequests/Warehouse";
|
|
||||||
import { ONE_PERMISSION_USERS } from "../../../Data/users";
|
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
|
||||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
|
||||||
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
|
|
||||||
import { selectChannelInHeader } from "../../../steps/channelsSteps";
|
|
||||||
import {
|
|
||||||
createShippingRate,
|
|
||||||
createShippingZone,
|
|
||||||
rateOptions
|
|
||||||
} from "../../../steps/shippingMethodSteps";
|
|
||||||
import { getFormattedCurrencyAmount } from "../../../support/format/formatCurrencyAmount";
|
|
||||||
import { urlList } from "../../../url/urlList";
|
|
||||||
import * as channelsUtils from "../../../utils/channelsUtils";
|
|
||||||
import * as productsUtils from "../../../utils/products/productsUtils";
|
|
||||||
import * as shippingUtils from "../../../utils/shippingUtils";
|
|
||||||
import { isShippingAvailableInCheckout } from "../../../utils/storeFront/checkoutUtils";
|
|
||||||
|
|
||||||
describe("Shipping methods", () => {
|
|
||||||
const startsWith = "CyShippingMethods-";
|
|
||||||
const name = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
const price = 8;
|
|
||||||
let defaultChannel;
|
|
||||||
let plAddress;
|
|
||||||
let variantsList;
|
|
||||||
let warehouse;
|
|
||||||
|
|
||||||
before(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
productsUtils.deleteProductsStartsWith(startsWith);
|
|
||||||
shippingUtils.deleteShippingStartsWith(startsWith);
|
|
||||||
channelsUtils.deleteChannelsStartsWith(startsWith);
|
|
||||||
|
|
||||||
channelsUtils
|
|
||||||
.getDefaultChannel()
|
|
||||||
.then(channel => {
|
|
||||||
defaultChannel = channel;
|
|
||||||
cy.fixture("addresses");
|
|
||||||
})
|
|
||||||
.then(addresses => {
|
|
||||||
plAddress = addresses.plAddress;
|
|
||||||
createWarehouse({ name, address: plAddress });
|
|
||||||
})
|
|
||||||
.then(warehouseResp => {
|
|
||||||
warehouse = warehouseResp;
|
|
||||||
productsUtils.createTypeAttributeAndCategoryForProduct(startsWith);
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
({
|
|
||||||
productType: productTypeResp,
|
|
||||||
category: categoryResp,
|
|
||||||
attribute: attributeResp
|
|
||||||
}) => {
|
|
||||||
productsUtils.createProductInChannel({
|
|
||||||
name,
|
|
||||||
channelId: defaultChannel.id,
|
|
||||||
productTypeId: productTypeResp.id,
|
|
||||||
attributeId: attributeResp.id,
|
|
||||||
categoryId: categoryResp.id,
|
|
||||||
warehouseId: warehouse.id,
|
|
||||||
quantityInWarehouse: 10
|
|
||||||
});
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(({ variantsList: variantsListResp }) => {
|
|
||||||
variantsList = variantsListResp;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.clearSessionData().loginUserViaRequest();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should display different price for each channel", () => {
|
|
||||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
const defaultChannelPrice = 11;
|
|
||||||
const createdChannelPrice = 7;
|
|
||||||
const createdChannelCurrency = "PLN";
|
|
||||||
|
|
||||||
let shippingMethod;
|
|
||||||
let shippingZone;
|
|
||||||
let createdChannel;
|
|
||||||
|
|
||||||
createChannel({
|
|
||||||
name: shippingName,
|
|
||||||
currencyCode: createdChannelCurrency
|
|
||||||
})
|
|
||||||
.then(channel => {
|
|
||||||
createdChannel = channel;
|
|
||||||
shippingUtils.createShipping({
|
|
||||||
channelId: defaultChannel.id,
|
|
||||||
name: shippingName,
|
|
||||||
address: plAddress,
|
|
||||||
price: defaultChannelPrice
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(
|
|
||||||
({
|
|
||||||
shippingMethod: shippingMethodResp,
|
|
||||||
shippingZone: shippingZoneResp
|
|
||||||
}) => {
|
|
||||||
shippingZone = shippingZoneResp;
|
|
||||||
shippingMethod = shippingMethodResp;
|
|
||||||
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
|
|
||||||
() => {
|
|
||||||
addChannelToShippingMethod(
|
|
||||||
shippingMethod.id,
|
|
||||||
createdChannel.id,
|
|
||||||
createdChannelPrice
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.then(() => {
|
|
||||||
cy.clearSessionData()
|
|
||||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
|
||||||
.visit(urlList.shippingMethods)
|
|
||||||
.get(SHARED_ELEMENTS.header)
|
|
||||||
.should("be.visible")
|
|
||||||
.get(SHARED_ELEMENTS.progressBar)
|
|
||||||
.should("not.exist");
|
|
||||||
cy.addAliasToGraphRequest("ShippingZone");
|
|
||||||
cy.getTextFromElement(SHARED_ELEMENTS.table);
|
|
||||||
})
|
|
||||||
.then(tableText => {
|
|
||||||
if (!tableText.includes(shippingZone.name)) {
|
|
||||||
cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
|
|
||||||
}
|
|
||||||
cy.contains(shippingZone.name).click();
|
|
||||||
cy.wait("@ShippingZone");
|
|
||||||
selectChannelInHeader(defaultChannel.name);
|
|
||||||
cy.getTextFromElement(SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell)
|
|
||||||
.then(text => {
|
|
||||||
const expectedValue = getFormattedCurrencyAmount(
|
|
||||||
defaultChannelPrice,
|
|
||||||
defaultChannel.currencyCode
|
|
||||||
);
|
|
||||||
expect(text).to.be.eq(expectedValue);
|
|
||||||
|
|
||||||
selectChannelInHeader(createdChannel.name);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
cy.getTextFromElement(
|
|
||||||
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.then(text => {
|
|
||||||
const expectedValue = getFormattedCurrencyAmount(
|
|
||||||
createdChannelPrice,
|
|
||||||
createdChannelCurrency
|
|
||||||
);
|
|
||||||
expect(text).to.be.eq(expectedValue);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it("should create price based shipping method", () => {
|
|
||||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
cy.clearSessionData().loginUserViaRequest(
|
|
||||||
"auth",
|
|
||||||
ONE_PERMISSION_USERS.shipping
|
|
||||||
);
|
|
||||||
cy.visit(urlList.shippingMethods);
|
|
||||||
createShippingZone(
|
|
||||||
shippingName,
|
|
||||||
warehouse.name,
|
|
||||||
plAddress.countryFullName,
|
|
||||||
defaultChannel.name
|
|
||||||
);
|
|
||||||
createShippingRate(shippingName, price, rateOptions.PRICE_OPTION);
|
|
||||||
|
|
||||||
createCheckout({
|
|
||||||
channelSlug: defaultChannel.slug,
|
|
||||||
email: "test@example.com",
|
|
||||||
variantsList,
|
|
||||||
address: plAddress,
|
|
||||||
auth: "token"
|
|
||||||
}).then(({ checkout }) => {
|
|
||||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
|
||||||
checkout,
|
|
||||||
shippingName
|
|
||||||
);
|
|
||||||
expect(isShippingAvailable).to.be.true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should create weight based shipping method", () => {
|
|
||||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
|
||||||
cy.clearSessionData().loginUserViaRequest(
|
|
||||||
"auth",
|
|
||||||
ONE_PERMISSION_USERS.shipping
|
|
||||||
);
|
|
||||||
cy.visit(urlList.shippingMethods);
|
|
||||||
createShippingZone(
|
|
||||||
shippingName,
|
|
||||||
warehouse.name,
|
|
||||||
plAddress.countryFullName,
|
|
||||||
defaultChannel.name
|
|
||||||
);
|
|
||||||
createShippingRate(shippingName, price, rateOptions.WEIGHT_OPTION);
|
|
||||||
createCheckout({
|
|
||||||
channelSlug: defaultChannel.slug,
|
|
||||||
email: "test@example.com",
|
|
||||||
variantsList,
|
|
||||||
address: plAddress,
|
|
||||||
auth: "token"
|
|
||||||
}).then(({ checkout }) => {
|
|
||||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
|
||||||
checkout,
|
|
||||||
shippingName
|
|
||||||
);
|
|
||||||
expect(isShippingAvailable).to.be.true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createChannel } from "../../../../apiRequests/Channels";
|
||||||
|
import {
|
||||||
|
addChannelToShippingMethod,
|
||||||
|
addChannelToShippingZone
|
||||||
|
} from "../../../../apiRequests/ShippingMethod";
|
||||||
|
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||||
|
import { BUTTON_SELECTORS } from "../../../../elements/shared/button-selectors";
|
||||||
|
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
|
||||||
|
import { SHIPPING_ZONE_DETAILS } from "../../../../elements/shipping/shipping-zone-details";
|
||||||
|
import { selectChannelInHeader } from "../../../../steps/channelsSteps";
|
||||||
|
import { getFormattedCurrencyAmount } from "../../../../support/format/formatCurrencyAmount";
|
||||||
|
import { urlList } from "../../../../url/urlList";
|
||||||
|
import * as channelsUtils from "../../../../utils/channelsUtils";
|
||||||
|
import * as shippingUtils from "../../../../utils/shippingUtils";
|
||||||
|
|
||||||
|
describe("Channels in shippingMethod", () => {
|
||||||
|
const startsWith = "ChannelShippingMethod";
|
||||||
|
let defaultChannel;
|
||||||
|
let plAddress;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
shippingUtils.deleteShippingStartsWith(startsWith);
|
||||||
|
channelsUtils.deleteChannelsStartsWith(startsWith);
|
||||||
|
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
plAddress = addresses.plAddress;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should display different price for each channel", () => {
|
||||||
|
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const defaultChannelPrice = 11;
|
||||||
|
const createdChannelPrice = 7;
|
||||||
|
const createdChannelCurrency = "PLN";
|
||||||
|
|
||||||
|
let shippingMethod;
|
||||||
|
let shippingZone;
|
||||||
|
let createdChannel;
|
||||||
|
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
createChannel({
|
||||||
|
name: shippingName,
|
||||||
|
currencyCode: createdChannelCurrency
|
||||||
|
})
|
||||||
|
.then(channel => {
|
||||||
|
createdChannel = channel;
|
||||||
|
shippingUtils.createShipping({
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
name: shippingName,
|
||||||
|
address: plAddress,
|
||||||
|
price: defaultChannelPrice
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
shippingMethod: shippingMethodResp,
|
||||||
|
shippingZone: shippingZoneResp
|
||||||
|
}) => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
addChannelToShippingZone(shippingZone.id, createdChannel.id).then(
|
||||||
|
() => {
|
||||||
|
addChannelToShippingMethod(
|
||||||
|
shippingMethod.id,
|
||||||
|
createdChannel.id,
|
||||||
|
createdChannelPrice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
cy.clearSessionData()
|
||||||
|
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||||
|
.visit(urlList.shippingMethods)
|
||||||
|
.get(SHARED_ELEMENTS.header)
|
||||||
|
.should("be.visible")
|
||||||
|
.get(SHARED_ELEMENTS.progressBar)
|
||||||
|
.should("not.exist");
|
||||||
|
cy.addAliasToGraphRequest("ShippingZone");
|
||||||
|
cy.getTextFromElement(SHARED_ELEMENTS.table);
|
||||||
|
})
|
||||||
|
.then(tableText => {
|
||||||
|
if (!tableText.includes(shippingZone.name)) {
|
||||||
|
cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
|
||||||
|
}
|
||||||
|
cy.contains(shippingZone.name).click();
|
||||||
|
cy.wait("@ShippingZone");
|
||||||
|
selectChannelInHeader(defaultChannel.name);
|
||||||
|
cy.getTextFromElement(SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell)
|
||||||
|
.then(text => {
|
||||||
|
const expectedValue = getFormattedCurrencyAmount(
|
||||||
|
defaultChannelPrice,
|
||||||
|
defaultChannel.currencyCode
|
||||||
|
);
|
||||||
|
expect(text).to.be.eq(expectedValue);
|
||||||
|
|
||||||
|
selectChannelInHeader(createdChannel.name);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
cy.getTextFromElement(
|
||||||
|
SHIPPING_ZONE_DETAILS.shippingRatePriceTableCell
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(text => {
|
||||||
|
const expectedValue = getFormattedCurrencyAmount(
|
||||||
|
createdChannelPrice,
|
||||||
|
createdChannelCurrency
|
||||||
|
);
|
||||||
|
expect(text).to.be.eq(expectedValue);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,141 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createCheckout } from "../../../../apiRequests/Checkout";
|
||||||
|
import { createWarehouse } from "../../../../apiRequests/Warehouse";
|
||||||
|
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||||
|
import {
|
||||||
|
createShippingRate,
|
||||||
|
createShippingZone,
|
||||||
|
rateOptions
|
||||||
|
} from "../../../../steps/shippingMethodSteps";
|
||||||
|
import { urlList } from "../../../../url/urlList";
|
||||||
|
import * as channelsUtils from "../../../../utils/channelsUtils";
|
||||||
|
import * as productsUtils from "../../../../utils/products/productsUtils";
|
||||||
|
import * as shippingUtils from "../../../../utils/shippingUtils";
|
||||||
|
import { isShippingAvailableInCheckout } from "../../../../utils/storeFront/checkoutUtils";
|
||||||
|
|
||||||
|
describe("Create shipping method", () => {
|
||||||
|
const startsWith = "CreateShippingMethods-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const price = 8;
|
||||||
|
const deliveryTime = { min: 2, max: 5 };
|
||||||
|
let defaultChannel;
|
||||||
|
let plAddress;
|
||||||
|
let variantsList;
|
||||||
|
let warehouse;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
|
shippingUtils.deleteShippingStartsWith(startsWith);
|
||||||
|
|
||||||
|
channelsUtils
|
||||||
|
.getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
plAddress = addresses.plAddress;
|
||||||
|
createWarehouse({ name, address: plAddress });
|
||||||
|
})
|
||||||
|
.then(warehouseResp => {
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct(startsWith);
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
productType: productTypeResp,
|
||||||
|
category: categoryResp,
|
||||||
|
attribute: attributeResp
|
||||||
|
}) => {
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
productTypeId: productTypeResp.id,
|
||||||
|
attributeId: attributeResp.id,
|
||||||
|
categoryId: categoryResp.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
quantityInWarehouse: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(({ variantsList: variantsListResp }) => {
|
||||||
|
variantsList = variantsListResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create price based shipping method", () => {
|
||||||
|
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
cy.clearSessionData().loginUserViaRequest(
|
||||||
|
"auth",
|
||||||
|
ONE_PERMISSION_USERS.shipping
|
||||||
|
);
|
||||||
|
cy.visit(urlList.shippingMethods);
|
||||||
|
createShippingZone(
|
||||||
|
shippingName,
|
||||||
|
warehouse.name,
|
||||||
|
plAddress.countryFullName,
|
||||||
|
defaultChannel.name
|
||||||
|
);
|
||||||
|
createShippingRate({
|
||||||
|
rateName: shippingName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.PRICE_OPTION,
|
||||||
|
deliveryTime
|
||||||
|
});
|
||||||
|
|
||||||
|
createCheckout({
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "test@example.com",
|
||||||
|
variantsList,
|
||||||
|
address: plAddress,
|
||||||
|
auth: "token"
|
||||||
|
}).then(({ checkout }) => {
|
||||||
|
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||||
|
checkout,
|
||||||
|
shippingName
|
||||||
|
);
|
||||||
|
expect(isShippingAvailable).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should create weight based shipping method", () => {
|
||||||
|
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
cy.clearSessionData().loginUserViaRequest(
|
||||||
|
"auth",
|
||||||
|
ONE_PERMISSION_USERS.shipping
|
||||||
|
);
|
||||||
|
cy.visit(urlList.shippingMethods);
|
||||||
|
createShippingZone(
|
||||||
|
shippingName,
|
||||||
|
warehouse.name,
|
||||||
|
plAddress.countryFullName,
|
||||||
|
defaultChannel.name
|
||||||
|
);
|
||||||
|
createShippingRate({
|
||||||
|
rateName: shippingName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.WEIGHT_OPTION,
|
||||||
|
deliveryTime
|
||||||
|
});
|
||||||
|
createCheckout({
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "test@example.com",
|
||||||
|
variantsList,
|
||||||
|
address: plAddress,
|
||||||
|
auth: "token"
|
||||||
|
}).then(({ checkout }) => {
|
||||||
|
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||||
|
checkout,
|
||||||
|
shippingName
|
||||||
|
);
|
||||||
|
expect(isShippingAvailable).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,134 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createCheckout } from "../../../../apiRequests/Checkout";
|
||||||
|
import { createShippingZone } from "../../../../apiRequests/ShippingMethod";
|
||||||
|
import { createWarehouse } from "../../../../apiRequests/Warehouse";
|
||||||
|
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||||
|
import {
|
||||||
|
createRateWithPostalCode,
|
||||||
|
postalCodesOptions
|
||||||
|
} from "../../../../steps/shippingMethodSteps";
|
||||||
|
import { shippingZoneDetailsUrl } from "../../../../url/urlList";
|
||||||
|
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||||
|
import {
|
||||||
|
createProductInChannel,
|
||||||
|
createTypeAttributeAndCategoryForProduct,
|
||||||
|
deleteProductsStartsWith
|
||||||
|
} from "../../../../utils/products/productsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../../utils/shippingUtils";
|
||||||
|
import { isShippingAvailableInCheckout } from "../../../../utils/storeFront/checkoutUtils";
|
||||||
|
|
||||||
|
describe("Postal codes in shipping", () => {
|
||||||
|
const startsWith = "CyShippingMethods-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
const price = 10;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let usAddress;
|
||||||
|
let secondUsAddress;
|
||||||
|
let shippingZone;
|
||||||
|
let warehouse;
|
||||||
|
let variantsList;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
usAddress: usAddressResp,
|
||||||
|
secondUsAddress: secondUsAddressResp
|
||||||
|
}) => {
|
||||||
|
usAddress = usAddressResp;
|
||||||
|
secondUsAddress = secondUsAddressResp;
|
||||||
|
createShippingZone(name, "US", defaultChannel.id);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
createWarehouse({
|
||||||
|
name,
|
||||||
|
shippingZone: shippingZone.id,
|
||||||
|
address: usAddress
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(warehouseResp => {
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
createTypeAttributeAndCategoryForProduct(name);
|
||||||
|
})
|
||||||
|
.then(({ attribute, productType, category }) => {
|
||||||
|
createProductInChannel({
|
||||||
|
name,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
productTypeId: productType.id
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ variantsList: variantsListResp }) => {
|
||||||
|
variantsList = variantsListResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData()
|
||||||
|
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||||
|
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Create shipping method with included postal codes", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
createRateWithPostalCode({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
postalCodeOption: postalCodesOptions.INCLUDE_OPTION,
|
||||||
|
maxPostalCode: usAddress.postalCode,
|
||||||
|
minPostalCode: usAddress.postalCode
|
||||||
|
});
|
||||||
|
isShippingAvailableForAddress(usAddress, rateName).then(
|
||||||
|
isAvailable => expect(isAvailable).to.be.true
|
||||||
|
);
|
||||||
|
isShippingAvailableForAddress(secondUsAddress, rateName).then(
|
||||||
|
isAvailable => expect(isAvailable).to.be.false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Create shipping method with excluded postal codes", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
createRateWithPostalCode({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
postalCodeOption: postalCodesOptions.EXCLUDE_OPTION,
|
||||||
|
maxPostalCode: usAddress.postalCode,
|
||||||
|
minPostalCode: usAddress.postalCode
|
||||||
|
});
|
||||||
|
isShippingAvailableForAddress(usAddress, rateName).then(
|
||||||
|
isAvailable => expect(isAvailable).to.be.false
|
||||||
|
);
|
||||||
|
isShippingAvailableForAddress(secondUsAddress, rateName).then(
|
||||||
|
isAvailable => expect(isAvailable).to.be.true
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function isShippingAvailableForAddress(address, rateName) {
|
||||||
|
return createCheckout({
|
||||||
|
address,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "example@example.com",
|
||||||
|
variantsList
|
||||||
|
}).then(({ checkout }) =>
|
||||||
|
isShippingAvailableInCheckout(checkout, rateName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,187 @@
|
||||||
|
// <reference types="cypress" />
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { createCheckout } from "../../../../apiRequests/Checkout";
|
||||||
|
import {
|
||||||
|
createShippingRate as createShippingRateViaApi,
|
||||||
|
createShippingZone
|
||||||
|
} from "../../../../apiRequests/ShippingMethod";
|
||||||
|
import { updateShopWeightUnit } from "../../../../apiRequests/shopSettings";
|
||||||
|
import { createWarehouse } from "../../../../apiRequests/Warehouse";
|
||||||
|
import { ONE_PERMISSION_USERS } from "../../../../Data/users";
|
||||||
|
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
|
||||||
|
import { SHIPPING_RATE_DETAILS } from "../../../../elements/shipping/shipping-rate-details";
|
||||||
|
import {
|
||||||
|
changeWeightUnit,
|
||||||
|
createShippingRate,
|
||||||
|
rateOptions
|
||||||
|
} from "../../../../steps/shippingMethodSteps";
|
||||||
|
import {
|
||||||
|
shippingZoneDetailsUrl,
|
||||||
|
urlList,
|
||||||
|
weightRateUrl
|
||||||
|
} from "../../../../url/urlList";
|
||||||
|
import { getDefaultChannel } from "../../../../utils/channelsUtils";
|
||||||
|
import {
|
||||||
|
createProductInChannel,
|
||||||
|
createTypeAttributeAndCategoryForProduct,
|
||||||
|
deleteProductsStartsWith
|
||||||
|
} from "../../../../utils/products/productsUtils";
|
||||||
|
import { deleteShippingStartsWith } from "../../../../utils/shippingUtils";
|
||||||
|
import { isShippingAvailableInCheckout } from "../../../../utils/storeFront/checkoutUtils";
|
||||||
|
|
||||||
|
describe("Shipping weight limits", () => {
|
||||||
|
const startsWith = "CyWeightRates-";
|
||||||
|
const name = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
|
||||||
|
const price = 10;
|
||||||
|
|
||||||
|
let defaultChannel;
|
||||||
|
let usAddress;
|
||||||
|
let shippingZone;
|
||||||
|
let warehouse;
|
||||||
|
let variantsList;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
updateShopWeightUnit("KG");
|
||||||
|
getDefaultChannel()
|
||||||
|
.then(channel => {
|
||||||
|
defaultChannel = channel;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(({ usAddress: usAddressResp }) => {
|
||||||
|
usAddress = usAddressResp;
|
||||||
|
createShippingZone(name, "US", defaultChannel.id);
|
||||||
|
})
|
||||||
|
.then(shippingZoneResp => {
|
||||||
|
shippingZone = shippingZoneResp;
|
||||||
|
createWarehouse({
|
||||||
|
name,
|
||||||
|
shippingZone: shippingZone.id,
|
||||||
|
address: usAddress
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(warehouseResp => {
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
createTypeAttributeAndCategoryForProduct(name);
|
||||||
|
})
|
||||||
|
.then(({ attribute, productType, category }) => {
|
||||||
|
createProductInChannel({
|
||||||
|
name,
|
||||||
|
channelId: defaultChannel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
attributeId: attribute.id,
|
||||||
|
categoryId: category.id,
|
||||||
|
productTypeId: productType.id,
|
||||||
|
weight: 10
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(({ variantsList: variantsListResp }) => {
|
||||||
|
variantsList = variantsListResp;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData()
|
||||||
|
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||||
|
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should be possible to buy product in a shipping weight limits", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
createShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.WEIGHT_OPTION,
|
||||||
|
weightLimits: {
|
||||||
|
max: 11,
|
||||||
|
min: 10
|
||||||
|
}
|
||||||
|
});
|
||||||
|
createCheckout({
|
||||||
|
address: usAddress,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "example@example.com",
|
||||||
|
variantsList
|
||||||
|
}).then(({ checkout }) => {
|
||||||
|
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not be possible to buy product not in a shipping weight limits", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
createShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption: rateOptions.WEIGHT_OPTION,
|
||||||
|
weightLimits: {
|
||||||
|
max: 101,
|
||||||
|
min: 100
|
||||||
|
}
|
||||||
|
});
|
||||||
|
createCheckout({
|
||||||
|
address: usAddress,
|
||||||
|
channelSlug: defaultChannel.slug,
|
||||||
|
email: "example@example.com",
|
||||||
|
variantsList
|
||||||
|
}).then(({ checkout }) => {
|
||||||
|
expect(isShippingAvailableInCheckout(checkout, rateName)).to.be.false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Log in as user with shipping permissions after resolving SALEOR-3407 bug
|
||||||
|
it("should recalculate weight after changing shipping weight unit", () => {
|
||||||
|
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||||
|
const minWeightInKg = 1;
|
||||||
|
const maxWeightInKg = 10;
|
||||||
|
const minWeightInG = minWeightInKg * 1000;
|
||||||
|
const maxWeightInG = maxWeightInKg * 1000;
|
||||||
|
let shippingMethod;
|
||||||
|
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
|
||||||
|
createShippingRateViaApi({
|
||||||
|
name: rateName,
|
||||||
|
shippingZone: shippingZone.id,
|
||||||
|
type: "WEIGHT",
|
||||||
|
maxWeight: maxWeightInKg,
|
||||||
|
minWeight: minWeightInKg
|
||||||
|
})
|
||||||
|
.then(({ shippingMethod: shippingMethodResp }) => {
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
cy.visit(urlList.shippingMethods)
|
||||||
|
.get(SHARED_ELEMENTS.progressBar)
|
||||||
|
.should("not.exist");
|
||||||
|
changeWeightUnit("G");
|
||||||
|
|
||||||
|
cy.addAliasToGraphRequest("ShippingZone");
|
||||||
|
cy.visit(weightRateUrl(shippingZone.id, shippingMethod.id))
|
||||||
|
.wait("@ShippingZone")
|
||||||
|
.its("response.body");
|
||||||
|
})
|
||||||
|
.then(responseArray => {
|
||||||
|
const shippingMethods = responseArray.find(
|
||||||
|
element => element.data.shippingZone
|
||||||
|
).data.shippingZone.shippingMethods;
|
||||||
|
const rate = shippingMethods.find(
|
||||||
|
element => element.id === shippingMethod.id
|
||||||
|
);
|
||||||
|
expect(rate.minimumOrderWeight.unit).to.eq("G");
|
||||||
|
cy.get(SHARED_ELEMENTS.progressBar)
|
||||||
|
.should("not.be.visible")
|
||||||
|
.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
||||||
|
.invoke("val");
|
||||||
|
})
|
||||||
|
.then(actualMinWeight => {
|
||||||
|
expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG);
|
||||||
|
cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val");
|
||||||
|
})
|
||||||
|
.then(actualMaxWeight => {
|
||||||
|
expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -8,7 +8,7 @@ import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-
|
||||||
import { WAREHOUSES_DETAILS } from "../../../elements/warehouses/warehouse-details";
|
import { WAREHOUSES_DETAILS } from "../../../elements/warehouses/warehouse-details";
|
||||||
import { WAREHOUSES_LIST } from "../../../elements/warehouses/warehouses-list";
|
import { WAREHOUSES_LIST } from "../../../elements/warehouses/warehouses-list";
|
||||||
import { fillUpBasicAddress } from "../../../steps/shared/addressForm";
|
import { fillUpBasicAddress } from "../../../steps/shared/addressForm";
|
||||||
import { fillAutocompleteSelect } from "../../../steps/shared/autocompleteSelect";
|
import { fillAutocompleteSelect } from "../../../steps/shared/selects";
|
||||||
import {
|
import {
|
||||||
shippingZoneDetailsUrl,
|
shippingZoneDetailsUrl,
|
||||||
urlList,
|
urlList,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
||||||
import { selectChannelInPicker } from "../../../steps/channelsSteps";
|
import { selectChannelInPicker } from "../../../steps/channelsSteps";
|
||||||
import { finalizeDraftOrder } from "../../../steps/draftOrderSteps";
|
import { finalizeDraftOrder } from "../../../steps/draftOrderSteps";
|
||||||
import { fillAutocompleteSelect } from "../../../steps/shared/autocompleteSelect";
|
import { fillAutocompleteSelect } from "../../../steps/shared/selects";
|
||||||
import { urlList } from "../../../url/urlList";
|
import { urlList } from "../../../url/urlList";
|
||||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import faker from "faker";
|
||||||
import {
|
import {
|
||||||
deleteStaffMembersStartsWith,
|
deleteStaffMembersStartsWith,
|
||||||
updateStaffMember
|
updateStaffMember
|
||||||
} from "../../apiRequests/staffMember";
|
} from "../../apiRequests/StaffMembers";
|
||||||
import { LEFT_MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
|
import { LEFT_MENU_SELECTORS } from "../../elements/account/left-menu/left-menu-selectors";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { STAFF_MEMBER_DETAILS } from "../../elements/staffMembers/staffMemberDetails";
|
import { STAFF_MEMBER_DETAILS } from "../../elements/staffMembers/staffMemberDetails";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
|
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
|
||||||
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
|
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
|
||||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||||
import { fillAutocompleteSelect } from "../../shared/autocompleteSelect";
|
import { fillAutocompleteSelect } from "../../shared/selects";
|
||||||
import { addMetadataField } from "../metadataSteps";
|
import { addMetadataField } from "../metadataSteps";
|
||||||
import { editSeoSettings } from "../seoSteps";
|
import { editSeoSettings } from "../seoSteps";
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { CHANNELS_SELECTORS } from "../elements/channels/channels-selectors";
|
||||||
import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-to-assign";
|
import { SELECT_CHANNELS_TO_ASSIGN } from "../elements/channels/select-channels-to-assign";
|
||||||
import { HEADER_SELECTORS } from "../elements/header/header-selectors";
|
import { HEADER_SELECTORS } from "../elements/header/header-selectors";
|
||||||
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
|
||||||
import { fillAutocompleteSelect } from "./shared/autocompleteSelect";
|
import { fillAutocompleteSelect } from "./shared/selects";
|
||||||
|
|
||||||
export function createChannelByView({
|
export function createChannelByView({
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ADDRESS_SELECTORS } from "../../elements/shared/addressForm";
|
import { ADDRESS_SELECTORS } from "../../elements/shared/addressForm";
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
import { fillAutocompleteSelect } from "./autocompleteSelect";
|
import { fillAutocompleteSelect } from "./selects";
|
||||||
|
|
||||||
export function fillUpAddressForm(address) {
|
export function fillUpAddressForm(address) {
|
||||||
cy.get(ADDRESS_SELECTORS.firstName)
|
cy.get(ADDRESS_SELECTORS.firstName)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||||
|
import { selectorWithDataValue } from "../../elements/shared/sharedElements";
|
||||||
|
|
||||||
export function fillAutocompleteSelect(selectSelector, option) {
|
export function fillAutocompleteSelect(selectSelector, option) {
|
||||||
cy.get(selectSelector)
|
cy.get(selectSelector)
|
||||||
|
@ -20,3 +21,10 @@ export function fillAutocompleteSelect(selectSelector, option) {
|
||||||
}
|
}
|
||||||
return cy.get("@option");
|
return cy.get("@option");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fillBaseSelect(selectSelector, value) {
|
||||||
|
cy.get(selectSelector)
|
||||||
|
.click()
|
||||||
|
.get(selectorWithDataValue(value))
|
||||||
|
.click();
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
||||||
import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-details";
|
import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-details";
|
||||||
import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details";
|
import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details";
|
||||||
import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list";
|
import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list";
|
||||||
|
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage";
|
||||||
|
import { fillBaseSelect } from "./shared/selects";
|
||||||
|
|
||||||
export function createShippingZone(
|
export function createShippingZone(
|
||||||
shippingName,
|
shippingName,
|
||||||
|
@ -24,12 +26,21 @@ export function createShippingZone(
|
||||||
.get(SHIPPING_ZONE_DETAILS.submitAssignCountry)
|
.get(SHIPPING_ZONE_DETAILS.submitAssignCountry)
|
||||||
.click()
|
.click()
|
||||||
.get(BUTTON_SELECTORS.confirm)
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
.click();
|
||||||
|
confirmationMessageShouldDisappear();
|
||||||
|
cy.get(SHIPPING_ZONE_DETAILS.warehouseSelector)
|
||||||
.click()
|
.click()
|
||||||
|
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
|
||||||
|
.scrollTo("bottom")
|
||||||
|
// Remove this code between comments after fixing bug: SALEOR-3611
|
||||||
|
.get(SHIPPING_ZONE_DETAILS.autocompleteContentDialog)
|
||||||
|
.should("not.exist")
|
||||||
.get(SHIPPING_ZONE_DETAILS.warehouseSelector)
|
.get(SHIPPING_ZONE_DETAILS.warehouseSelector)
|
||||||
.click()
|
.click()
|
||||||
|
// Remove this code between comments after fixing bug: SALEOR-3611
|
||||||
.get(SHIPPING_ZONE_DETAILS.option)
|
.get(SHIPPING_ZONE_DETAILS.option)
|
||||||
.contains(warehouseName)
|
.contains(warehouseName)
|
||||||
.click()
|
.click({ force: true })
|
||||||
.get(SHIPPING_ZONE_DETAILS.channelSelector)
|
.get(SHIPPING_ZONE_DETAILS.channelSelector)
|
||||||
.click()
|
.click()
|
||||||
.get(SHIPPING_ZONE_DETAILS.option)
|
.get(SHIPPING_ZONE_DETAILS.option)
|
||||||
|
@ -37,26 +48,120 @@ export function createShippingZone(
|
||||||
.click();
|
.click();
|
||||||
cy.addAliasToGraphRequest("UpdateShippingZone");
|
cy.addAliasToGraphRequest("UpdateShippingZone");
|
||||||
cy.get(BUTTON_SELECTORS.confirm).click();
|
cy.get(BUTTON_SELECTORS.confirm).click();
|
||||||
|
confirmationMessageShouldDisappear();
|
||||||
cy.wait("@UpdateShippingZone");
|
cy.wait("@UpdateShippingZone");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createShippingRate(rateName, price, rateOption) {
|
export function changeWeightUnit(weightUnit) {
|
||||||
|
fillBaseSelect(SHIPPING_ZONES_LIST.unitSelect, weightUnit);
|
||||||
|
cy.addAliasToGraphRequest("UpdateDefaultWeightUnit");
|
||||||
|
cy.get(SHIPPING_ZONES_LIST.saveUnit)
|
||||||
|
.click()
|
||||||
|
.get(SHARED_ELEMENTS.notificationSuccess)
|
||||||
|
.should("be.visible")
|
||||||
|
.wait("@UpdateDefaultWeightUnit")
|
||||||
|
.get(SHARED_ELEMENTS.notificationSuccess)
|
||||||
|
.should("not.exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption,
|
||||||
|
weightLimits,
|
||||||
|
deliveryTime
|
||||||
|
}) {
|
||||||
|
enterAndFillUpShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption,
|
||||||
|
weightLimits,
|
||||||
|
deliveryTime
|
||||||
|
});
|
||||||
|
saveRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function enterAndFillUpShippingRate({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption,
|
||||||
|
weightLimits,
|
||||||
|
deliveryTime
|
||||||
|
}) {
|
||||||
cy.get(rateOption)
|
cy.get(rateOption)
|
||||||
.click()
|
.click()
|
||||||
.get(SHARED_ELEMENTS.progressBar)
|
.get(SHARED_ELEMENTS.progressBar)
|
||||||
.should("not.be.visible")
|
.should("not.be.visible")
|
||||||
|
.get(SHARED_ELEMENTS.richTextEditor.empty)
|
||||||
|
.should("exist")
|
||||||
.get(SHIPPING_RATE_DETAILS.inputName)
|
.get(SHIPPING_RATE_DETAILS.inputName)
|
||||||
.type(rateName)
|
.type(rateName);
|
||||||
.get(SHIPPING_RATE_DETAILS.priceInput)
|
if (deliveryTime) {
|
||||||
.each($priceInput => {
|
fillUpDeliveryTime(deliveryTime);
|
||||||
cy.wrap($priceInput).type(price);
|
}
|
||||||
});
|
if (weightLimits) {
|
||||||
cy.addAliasToGraphRequest("ShippingZone");
|
fillUpWeightLimits(weightLimits);
|
||||||
cy.get(BUTTON_SELECTORS.confirm).click();
|
}
|
||||||
cy.wait("@ShippingZone");
|
cy.get(SHIPPING_RATE_DETAILS.priceInput).each($priceInput => {
|
||||||
|
cy.wrap($priceInput).type(price);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createRateWithPostalCode({
|
||||||
|
rateName,
|
||||||
|
price,
|
||||||
|
rateOption = rateOptions.PRICE_OPTION,
|
||||||
|
minPostalCode,
|
||||||
|
maxPostalCode,
|
||||||
|
postalCodeOption
|
||||||
|
}) {
|
||||||
|
enterAndFillUpShippingRate({ rateName, price, rateOption });
|
||||||
|
cy.get(postalCodeOption)
|
||||||
|
.click()
|
||||||
|
.get(SHIPPING_RATE_DETAILS.addPostalCodesButton)
|
||||||
|
.click()
|
||||||
|
.get(SHIPPING_RATE_DETAILS.postalCodesForm.min)
|
||||||
|
.type(minPostalCode)
|
||||||
|
.get(SHIPPING_RATE_DETAILS.postalCodesForm.max)
|
||||||
|
.type(maxPostalCode)
|
||||||
|
.get(BUTTON_SELECTORS.submit)
|
||||||
|
.click();
|
||||||
|
saveRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveRate() {
|
||||||
|
cy.addAliasToGraphRequest("ShippingMethodChannelListingUpdate")
|
||||||
|
.addAliasToGraphRequest("ShippingZone")
|
||||||
|
.get(BUTTON_SELECTORS.confirm)
|
||||||
|
.click()
|
||||||
|
.get(SHARED_ELEMENTS.notificationSuccess)
|
||||||
|
.should("be.visible")
|
||||||
|
.wait(`@ShippingMethodChannelListingUpdate`)
|
||||||
|
.wait(`@ShippingZone`)
|
||||||
|
.get(SHARED_ELEMENTS.notificationSuccess)
|
||||||
|
.should("not.exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fillUpWeightLimits({ max, min }) {
|
||||||
|
cy.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
||||||
|
.type(min)
|
||||||
|
.get(SHIPPING_RATE_DETAILS.maxWeightInput)
|
||||||
|
.type(max);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fillUpDeliveryTime({ min, max }) {
|
||||||
|
cy.get(SHIPPING_RATE_DETAILS.minDeliveryTimeInput)
|
||||||
|
.type(min)
|
||||||
|
.get(SHIPPING_RATE_DETAILS.maxDeliveryTimeInput)
|
||||||
|
.type(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const rateOptions = {
|
export const rateOptions = {
|
||||||
PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton,
|
PRICE_OPTION: SHIPPING_ZONE_DETAILS.addPriceRateButton,
|
||||||
WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton
|
WEIGHT_OPTION: SHIPPING_ZONE_DETAILS.addWeightRateButton
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const postalCodesOptions = {
|
||||||
|
INCLUDE_OPTION: SHIPPING_RATE_DETAILS.includePostalCodesCheckbox,
|
||||||
|
EXCLUDE_OPTION: SHIPPING_RATE_DETAILS.excludePostalCodesCheckbox
|
||||||
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
|
||||||
import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm";
|
import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm";
|
||||||
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
|
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
|
||||||
import { userDetailsUrl } from "../url/urlList";
|
import { userDetailsUrl } from "../url/urlList";
|
||||||
import { fillAutocompleteSelect } from "./shared/autocompleteSelect";
|
import { fillAutocompleteSelect } from "./shared/selects";
|
||||||
|
|
||||||
export function fillUpSetPassword(password) {
|
export function fillUpSetPassword(password) {
|
||||||
cy.get(SET_PASSWORD.confirmPasswordInput)
|
cy.get(SET_PASSWORD.confirmPasswordInput)
|
||||||
|
|
|
@ -14,9 +14,11 @@ export const urlList = {
|
||||||
staffMembers: "staff/",
|
staffMembers: "staff/",
|
||||||
newPassword: "new-password/",
|
newPassword: "new-password/",
|
||||||
permissionsGroups: "permission-groups/",
|
permissionsGroups: "permission-groups/",
|
||||||
|
weightRete: "weight/",
|
||||||
attributes: "attributes/",
|
attributes: "attributes/",
|
||||||
productTypes: "product-types/"
|
productTypes: "product-types/"
|
||||||
};
|
};
|
||||||
|
|
||||||
export const productDetailsUrl = productId => `${urlList.products}${productId}`;
|
export const productDetailsUrl = productId => `${urlList.products}${productId}`;
|
||||||
|
|
||||||
export const userDetailsUrl = userId => `${urlList.staffMembers}${userId}`;
|
export const userDetailsUrl = userId => `${urlList.staffMembers}${userId}`;
|
||||||
|
@ -30,6 +32,9 @@ export const permissionGroupDetails = permissionGroupId =>
|
||||||
export const shippingZoneDetailsUrl = shippingZoneId =>
|
export const shippingZoneDetailsUrl = shippingZoneId =>
|
||||||
`${urlList.shippingMethods}${shippingZoneId}`;
|
`${urlList.shippingMethods}${shippingZoneId}`;
|
||||||
|
|
||||||
|
export const weightRateUrl = (shippingZoneId, weightRateId) =>
|
||||||
|
`${urlList.shippingMethods}${shippingZoneId}/${urlList.weightRete}${weightRateId}`;
|
||||||
|
|
||||||
export const warehouseDetailsUrl = warehouseId =>
|
export const warehouseDetailsUrl = warehouseId =>
|
||||||
`${urlList.warehouses}${warehouseId}`;
|
`${urlList.warehouses}${warehouseId}`;
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ export function createOrderWithNewProduct({
|
||||||
shippingMethodId,
|
shippingMethodId,
|
||||||
address
|
address
|
||||||
}) {
|
}) {
|
||||||
|
let variantsList;
|
||||||
return createProductInChannel({
|
return createProductInChannel({
|
||||||
attributeId,
|
attributeId,
|
||||||
categoryId,
|
categoryId,
|
||||||
|
@ -174,13 +175,16 @@ export function createOrderWithNewProduct({
|
||||||
warehouseId,
|
warehouseId,
|
||||||
quantityInWarehouse,
|
quantityInWarehouse,
|
||||||
trackInventory
|
trackInventory
|
||||||
}).then(({ variantsList }) =>
|
})
|
||||||
createWaitingForCaptureOrder({
|
.then(({ variantsList: variantsListResp }) => {
|
||||||
channelSlug: channel.slug,
|
variantsList = variantsListResp;
|
||||||
email: "email@example.com",
|
createWaitingForCaptureOrder({
|
||||||
variantsList,
|
channelSlug: channel.slug,
|
||||||
shippingMethodId,
|
email: "email@example.com",
|
||||||
address
|
variantsList,
|
||||||
|
shippingMethodId,
|
||||||
|
address
|
||||||
|
});
|
||||||
})
|
})
|
||||||
);
|
.then(({ order, checkout }) => ({ order, checkout, variantsList }));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@ export function createProductInChannel({
|
||||||
visibleInListings = true,
|
visibleInListings = true,
|
||||||
collectionId = null,
|
collectionId = null,
|
||||||
description = null,
|
description = null,
|
||||||
trackInventory = true
|
trackInventory = true,
|
||||||
|
weight = 1
|
||||||
}) {
|
}) {
|
||||||
let product;
|
let product;
|
||||||
let variantsList;
|
let variantsList;
|
||||||
|
@ -54,7 +55,8 @@ export function createProductInChannel({
|
||||||
quantityInWarehouse,
|
quantityInWarehouse,
|
||||||
channelId,
|
channelId,
|
||||||
price,
|
price,
|
||||||
trackInventory
|
trackInventory,
|
||||||
|
weight
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(variantsResp => {
|
.then(variantsResp => {
|
||||||
|
|
|
@ -24,9 +24,12 @@ export function createShipping({
|
||||||
})
|
})
|
||||||
.then(warehouseResp => {
|
.then(warehouseResp => {
|
||||||
warehouse = warehouseResp;
|
warehouse = warehouseResp;
|
||||||
createShippingRate({ name, shippingZoneId: shippingZone.id });
|
shippingMethodRequest.createShippingRate({
|
||||||
|
name,
|
||||||
|
shippingZone: shippingZone.id
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.then(sippingMethodResp => {
|
.then(({ shippingMethod: sippingMethodResp }) => {
|
||||||
shippingMethod = sippingMethodResp;
|
shippingMethod = sippingMethodResp;
|
||||||
shippingMethodRequest.addChannelToShippingMethod(
|
shippingMethodRequest.addChannelToShippingMethod(
|
||||||
shippingMethod.id,
|
shippingMethod.id,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getPermissionsArray } from "../apiRequests/permissions";
|
import { getPermissionsArray } from "../apiRequests/permissions";
|
||||||
import { inviteStaffMember } from "../apiRequests/staffMember";
|
import { inviteStaffMember } from "../apiRequests/StaffMembers";
|
||||||
|
|
||||||
export function inviteStaffMemberWithFirstPermission({
|
export function inviteStaffMemberWithFirstPermission({
|
||||||
email,
|
email,
|
||||||
|
|
|
@ -203,7 +203,11 @@ const MultiAutocompleteSelectFieldContent: React.FC<MultiAutocompleteSelectField
|
||||||
return (
|
return (
|
||||||
<Paper className={classes.root}>
|
<Paper className={classes.root}>
|
||||||
{hasValuesToDisplay && (
|
{hasValuesToDisplay && (
|
||||||
<div className={classes.content} ref={anchor}>
|
<div
|
||||||
|
className={classes.content}
|
||||||
|
ref={anchor}
|
||||||
|
data-test-id="multiautocomplete-select-content"
|
||||||
|
>
|
||||||
<>
|
<>
|
||||||
{add && (
|
{add && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|
|
@ -54,7 +54,7 @@ const ShippingWeightUnitForm: React.FC<ShippingWeightUnitFormProps> = ({
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<Hr />
|
<Hr />
|
||||||
<CardActions>
|
<CardActions>
|
||||||
<Button color="primary" onClick={submit}>
|
<Button color="primary" onClick={submit} data-test-id="saveUnit">
|
||||||
<FormattedMessage {...buttonMessages.save} />
|
<FormattedMessage {...buttonMessages.save} />
|
||||||
</Button>
|
</Button>
|
||||||
</CardActions>
|
</CardActions>
|
||||||
|
|
|
@ -93,6 +93,7 @@ const ShippingZonePostalCodeRangeDialog: React.FC<ShippingZonePostalCodeRangeDia
|
||||||
disabled={!hasChanged || !data.min}
|
disabled={!hasChanged || !data.min}
|
||||||
transitionState={confirmButtonState}
|
transitionState={confirmButtonState}
|
||||||
type="submit"
|
type="submit"
|
||||||
|
data-test="submit"
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Add"
|
defaultMessage="Add"
|
||||||
|
|
|
@ -9805,6 +9805,7 @@ exports[`Storyshots Generics / Multiple select with autocomplete can load more 1
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MultiAutocompleteSelectFieldContent-content-id"
|
class="MultiAutocompleteSelectFieldContent-content-id"
|
||||||
|
data-test-id="multiautocomplete-select-content"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-disabled="false"
|
aria-disabled="false"
|
||||||
|
@ -10333,6 +10334,7 @@ exports[`Storyshots Generics / Multiple select with autocomplete default 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MultiAutocompleteSelectFieldContent-content-id"
|
class="MultiAutocompleteSelectFieldContent-content-id"
|
||||||
|
data-test-id="multiautocomplete-select-content"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-disabled="false"
|
aria-disabled="false"
|
||||||
|
@ -11299,6 +11301,7 @@ exports[`Storyshots Generics / Multiple select with autocomplete no data 1`] = `
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="MultiAutocompleteSelectFieldContent-content-id"
|
class="MultiAutocompleteSelectFieldContent-content-id"
|
||||||
|
data-test-id="multiautocomplete-select-content"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-disabled="false"
|
aria-disabled="false"
|
||||||
|
@ -238070,6 +238073,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="saveUnit"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -238508,6 +238512,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list loading 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="saveUnit"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
@ -238835,6 +238840,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no data 1`] = `
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
|
||||||
|
data-test-id="saveUnit"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue