add tests for shipping for 3.1 (#1859)
This commit is contained in:
parent
74508ed93b
commit
7c47566995
16 changed files with 263 additions and 71 deletions
18
cypress/elements/giftCard/giftCardDialog.js
Normal file
18
cypress/elements/giftCard/giftCardDialog.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
export const GIFT_CARD_DIALOG = {
|
||||
amountInput: '[name="balanceAmount"]',
|
||||
currencySelectButton: '[id="mui-component-select-balanceCurrency"]',
|
||||
currenciesOptions: '[data-test-id="select-field-option"]',
|
||||
expirationOptions: {
|
||||
setExpiryDateCheckbox: '[name="expirySelected"]',
|
||||
neverExpireRadioButton: '[value="NEVER_EXPIRE"]',
|
||||
expiryPeriodRadioButton: '[value="EXPIRY_PERIOD"]',
|
||||
expiryDateRadioButton: '[value="EXPIRY_DATE"]',
|
||||
expiryPeriodAmount: '[name="expiryPeriodAmount"]',
|
||||
expiryPeriodTypeButton: '[id*="select-expiryPeriodType"]',
|
||||
expiryPeriodMonthType: '[data-test-id="MONTH"]',
|
||||
expiryDateInput: '[name="expiryDate"]'
|
||||
},
|
||||
noteInput: '[name="note"]',
|
||||
cardCodeText: '[data-test-id="cardCode"]',
|
||||
tagInput: '[data-test-id="gift-card-tag-select-field"]'
|
||||
};
|
|
@ -13,5 +13,7 @@ export const BUTTON_SELECTORS = {
|
|||
deleteIcon: '[data-test-id="delete-icon"]',
|
||||
showMoreButton: '[data-test-id="show-more-button"]',
|
||||
button: "button",
|
||||
deleteAssignedItemsConsentCheckbox: '[name="delete-assigned-items-consent"]'
|
||||
deleteAssignedItemsConsentCheckbox: '[name="delete-assigned-items-consent"]',
|
||||
deleteSelectedElementsButton:
|
||||
'[data-test-id = "delete-selected-elements-icon"]'
|
||||
};
|
||||
|
|
|
@ -8,8 +8,8 @@ export const SHIPPING_RATE_DETAILS = {
|
|||
min: '[name="min"]',
|
||||
max: '[name="max"]'
|
||||
},
|
||||
maxWeightInput: '[name*="maxValue"]',
|
||||
minWeightInput: '[name*="minValue"]',
|
||||
maxValueInput: '[name*="maxValue"]',
|
||||
minValueInput: '[name*="minValue"]',
|
||||
minDeliveryTimeInput: '[name="minDays"]',
|
||||
maxDeliveryTimeInput: '[name="maxDays"]',
|
||||
restrictWeightLimitCheckbox: '[name="orderValueRestricted"]'
|
||||
|
|
|
@ -3,3 +3,9 @@ export const SHIPPING_ZONES_LIST = {
|
|||
unitSelect: "[id='mui-component-select-unit']",
|
||||
saveUnit: '[data-test-id="save-unit"]'
|
||||
};
|
||||
|
||||
export const SHIPPING_ZONE_CHECKBOX = shippingId =>
|
||||
`[data-test-id="${shippingId}-checkbox"]`;
|
||||
|
||||
export const SHIPPING_ZONE_NAME = shippingId =>
|
||||
`[data-test-id="${shippingId}-name"]`;
|
||||
|
|
|
@ -5,7 +5,6 @@ import faker from "faker";
|
|||
|
||||
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
|
||||
import { SHIPPING_ZONE_DETAILS } from "../../../elements/shipping/shipping-zone-details";
|
||||
import { urlList } from "../../../fixtures/urlList";
|
||||
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
|
||||
import { createChannel } from "../../../support/api/requests/Channels";
|
||||
import {
|
||||
|
@ -18,9 +17,13 @@ import filterTests from "../../../support/filterTests";
|
|||
import { getCurrencyAndAmountInString } from "../../../support/formatData/formatCurrencyAmount";
|
||||
import { getFormattedCurrencyAmount } from "../../../support/formatData/formatCurrencyAmount";
|
||||
import { enterHomePageChangeChannelAndReturn } from "../../../support/pages/channelsPage";
|
||||
import {
|
||||
enterAndSelectShippings,
|
||||
enterShippingZone
|
||||
} from "../../../support/pages/shippingZones";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Channels in shippingMethod", () => {
|
||||
describe("As a staff user I want have different shipping method prices for each channel", () => {
|
||||
const startsWith = "ChannelShippingMethod";
|
||||
let defaultChannel;
|
||||
let plAddress;
|
||||
|
@ -41,7 +44,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should display different price for each channel", () => {
|
||||
it("should be able to display different price for each channel. TC: SALEOR_0805", () => {
|
||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||
const defaultChannelPrice = 11;
|
||||
const createdChannelPrice = 7;
|
||||
|
@ -84,15 +87,11 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
}
|
||||
)
|
||||
.then(() => {
|
||||
cy.clearSessionData()
|
||||
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
|
||||
.visit(urlList.shippingMethods)
|
||||
.get(SHARED_ELEMENTS.header)
|
||||
.should("be.visible")
|
||||
.waitForProgressBarToNotExist()
|
||||
.addAliasToGraphRequest("ShippingZone")
|
||||
.findElementOnTable(shippingZone.name, "ShippingZones")
|
||||
.waitForRequestAndCheckIfNoErrors("@ShippingZone");
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
ONE_PERMISSION_USERS.shipping
|
||||
);
|
||||
enterAndSelectShippings(shippingZone.id, enterShippingZone);
|
||||
enterHomePageChangeChannelAndReturn(defaultChannel.name);
|
||||
cy.waitForProgressBarToNotBeVisible()
|
||||
.get(SHARED_ELEMENTS.skeleton)
|
||||
|
|
|
@ -6,8 +6,10 @@ import faker from "faker";
|
|||
import { urlList } from "../../../fixtures/urlList";
|
||||
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
|
||||
import { createCheckout } from "../../../support/api/requests/Checkout";
|
||||
import { createVariant } from "../../../support/api/requests/Product";
|
||||
import { createWarehouse } from "../../../support/api/requests/Warehouse";
|
||||
import * as channelsUtils from "../../../support/api/utils/channelsUtils";
|
||||
import { createWaitingForCaptureOrder } from "../../../support/api/utils/ordersUtils";
|
||||
import * as productsUtils from "../../../support/api/utils/products/productsUtils";
|
||||
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
|
||||
import { isShippingAvailableInCheckout } from "../../../support/api/utils/storeFront/checkoutUtils";
|
||||
|
@ -19,15 +21,21 @@ import {
|
|||
} from "../../../support/pages/shippingMethodPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Create shipping method", () => {
|
||||
describe("As a staff user I want to create shipping zone and rate", () => {
|
||||
const startsWith = "CreateShippingMethods-";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const secondName = `${startsWith}${faker.datatype.number()}`;
|
||||
const price = 8;
|
||||
const secondVariantPrice = 2;
|
||||
const deliveryTime = { min: 2, max: 5 };
|
||||
let defaultChannel;
|
||||
let plAddress;
|
||||
let address;
|
||||
let variantsList;
|
||||
let secondVariantsList;
|
||||
let warehouse;
|
||||
let attribute;
|
||||
let category;
|
||||
let productType;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
|
@ -41,8 +49,8 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
cy.fixture("addresses");
|
||||
})
|
||||
.then(addresses => {
|
||||
plAddress = addresses.plAddress;
|
||||
createWarehouse({ name, address: plAddress });
|
||||
address = addresses.usAddress;
|
||||
createWarehouse({ name, address });
|
||||
})
|
||||
.then(warehouseResp => {
|
||||
warehouse = warehouseResp;
|
||||
|
@ -56,6 +64,10 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
category: categoryResp,
|
||||
attribute: attributeResp
|
||||
}) => {
|
||||
attribute = attributeResp;
|
||||
category = categoryResp;
|
||||
productType = productTypeResp;
|
||||
|
||||
productsUtils.createProductInChannel({
|
||||
name,
|
||||
channelId: defaultChannel.id,
|
||||
|
@ -63,12 +75,27 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
attributeId: attributeResp.id,
|
||||
categoryId: categoryResp.id,
|
||||
warehouseId: warehouse.id,
|
||||
quantityInWarehouse: 10
|
||||
quantityInWarehouse: 10,
|
||||
price
|
||||
});
|
||||
}
|
||||
)
|
||||
.then(({ variantsList: variantsListResp }) => {
|
||||
.then(({ variantsList: variantsListResp, product }) => {
|
||||
variantsList = variantsListResp;
|
||||
createVariant({
|
||||
productId: product.id,
|
||||
sku: secondName,
|
||||
attributeId: attribute.id,
|
||||
attributeName: "value2",
|
||||
warehouseId: warehouse.id,
|
||||
quantityInWarehouse: 10,
|
||||
channelId: defaultChannel.id,
|
||||
price: secondVariantPrice,
|
||||
weight: 10
|
||||
});
|
||||
})
|
||||
.then(variantsListResp => {
|
||||
secondVariantsList = variantsListResp;
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -76,7 +103,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
cy.clearSessionData().loginUserViaRequest();
|
||||
});
|
||||
|
||||
it("should create price based shipping method", () => {
|
||||
it("should be able to create price based shipping method. TC: SALEOR_0803", () => {
|
||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
|
@ -86,32 +113,43 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
createShippingZone(
|
||||
shippingName,
|
||||
warehouse.name,
|
||||
plAddress.countryFullName,
|
||||
address.countryFullName,
|
||||
defaultChannel.name
|
||||
);
|
||||
createShippingRate({
|
||||
rateName: shippingName,
|
||||
price,
|
||||
priceLimits: { min: price, max: 100 },
|
||||
rateOption: rateOptions.PRICE_OPTION,
|
||||
deliveryTime
|
||||
});
|
||||
|
||||
createCheckout({
|
||||
createWaitingForCaptureOrder({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "test@example.com",
|
||||
variantsList,
|
||||
address: plAddress,
|
||||
auth: "token"
|
||||
}).then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
);
|
||||
expect(isShippingAvailable).to.be.true;
|
||||
});
|
||||
address,
|
||||
shippingMethodName: shippingName
|
||||
})
|
||||
.then(({ order }) => {
|
||||
expect(order.id).to.be.ok;
|
||||
createCheckout({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "test@example.com",
|
||||
variantsList: secondVariantsList,
|
||||
address,
|
||||
auth: "token"
|
||||
});
|
||||
})
|
||||
.then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
);
|
||||
expect(isShippingAvailable).to.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
it("should create weight based shipping method", () => {
|
||||
it("should be able to create weight based shipping method. TC: SALEOR_0804", () => {
|
||||
const shippingName = `${startsWith}${faker.datatype.number()}`;
|
||||
cy.clearSessionData().loginUserViaRequest(
|
||||
"auth",
|
||||
|
@ -121,28 +159,40 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
createShippingZone(
|
||||
shippingName,
|
||||
warehouse.name,
|
||||
plAddress.countryFullName,
|
||||
address.countryFullName,
|
||||
defaultChannel.name
|
||||
);
|
||||
createShippingRate({
|
||||
rateName: shippingName,
|
||||
price,
|
||||
rateOption: rateOptions.WEIGHT_OPTION,
|
||||
deliveryTime
|
||||
deliveryTime,
|
||||
weightLimits: { min: 5, max: 10 }
|
||||
});
|
||||
createCheckout({
|
||||
createWaitingForCaptureOrder({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "test@example.com",
|
||||
variantsList,
|
||||
address: plAddress,
|
||||
auth: "token"
|
||||
}).then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
);
|
||||
expect(isShippingAvailable).to.be.true;
|
||||
});
|
||||
variantsList: secondVariantsList,
|
||||
address,
|
||||
shippingMethodName: shippingName
|
||||
})
|
||||
.then(({ order }) => {
|
||||
expect(order.id).to.be.ok;
|
||||
createCheckout({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "test@example.com",
|
||||
variantsList,
|
||||
address,
|
||||
auth: "token"
|
||||
});
|
||||
})
|
||||
.then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
);
|
||||
expect(isShippingAvailable).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
} from "../../../support/pages/shippingMethodPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Edit shipping method", () => {
|
||||
describe("As a user I should be able to update and delete shipping method", () => {
|
||||
const startsWith = "EditShipping-";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const price = 10;
|
||||
|
@ -55,7 +55,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("Update shipping rate", () => {
|
||||
it("should be able to update shipping rate. TC: SALEOR_0806", () => {
|
||||
const updatedRateName = `${startsWith}Updated`;
|
||||
const deliveryTime = { min: 1, max: 7 };
|
||||
|
||||
|
@ -80,7 +80,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("Delete shipping rate", () => {
|
||||
it("should be able to delete shipping rate. TC: SALEOR_0807", () => {
|
||||
cy.visit(
|
||||
priceRateUrl(shippingZone.id, shippingMethod.id)
|
||||
).deleteElementWithReqAlias("DeleteShippingRate");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
|
||||
import { shippingZoneDetailsUrl } from "../../../fixtures/urlList";
|
||||
import {
|
||||
createShippingZone,
|
||||
|
@ -13,9 +14,10 @@ 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";
|
||||
import { enterAndSelectShippings } from "../../../support/pages/shippingZones";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Edit shipping zone", () => {
|
||||
describe("As a user I should be able to update and delete shipping zone", () => {
|
||||
const startsWith = "EditShipping-";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
|
@ -49,7 +51,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("Update shipping zone", () => {
|
||||
it("should be able to update shipping zone. TC: SALEOR_0808", () => {
|
||||
const updatedName = `${startsWith}Updated`;
|
||||
|
||||
cy.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||
|
@ -68,11 +70,30 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("Delete shipping zone", () => {
|
||||
it("should be able to delete shipping zone. TC: SALEOR_0809", () => {
|
||||
cy.visit(
|
||||
shippingZoneDetailsUrl(shippingZone.id)
|
||||
).deleteElementWithReqAlias("DeleteShippingZone");
|
||||
getShippingZone(shippingZone.id).should("be.null");
|
||||
});
|
||||
|
||||
it("should be able to delete several shipping zones on shipping zones list page. TC: SALEOR_0810", () => {
|
||||
let secondShippingZone;
|
||||
|
||||
createShippingZone(`${startsWith}Second`, "US", defaultChannel.id).then(
|
||||
shippingZoneResp => {
|
||||
secondShippingZone = shippingZoneResp;
|
||||
enterAndSelectShippings([shippingZone.id, secondShippingZone.id]);
|
||||
cy.get(BUTTON_SELECTORS.deleteSelectedElementsButton)
|
||||
.click()
|
||||
.addAliasToGraphRequest("BulkDeleteShippingZone")
|
||||
.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.wait("@BulkDeleteShippingZone");
|
||||
getShippingZone(shippingZone.id).should("be.null");
|
||||
getShippingZone(secondShippingZone.id).should("be.null");
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
} from "../../../support/pages/shippingMethodPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Postal codes in shipping", () => {
|
||||
describe("As a user I want to create shipping method with postal codes", () => {
|
||||
const startsWith = "CyShippingMethods-";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
|
@ -89,7 +89,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||
});
|
||||
|
||||
it("Create shipping method with included postal codes", () => {
|
||||
it("should be able to create shipping method with included postal codes. TC: SALEOR_0801", () => {
|
||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createRateWithPostalCode({
|
||||
|
@ -107,7 +107,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("Create shipping method with excluded postal codes", () => {
|
||||
it("should be able to create shipping method with excluded postal codes. TC: SALEOR_0802", () => {
|
||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createRateWithPostalCode({
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
} from "../../../../support/pages/shippingMethodPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Shipping weight limits", () => {
|
||||
describe("As a staff user I want to manage shipping weights", () => {
|
||||
const startsWith = "CyWeightRates-";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
|
@ -83,7 +83,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
.visit(shippingZoneDetailsUrl(shippingZone.id));
|
||||
});
|
||||
|
||||
it("should be possible to buy product in a shipping weight limits", () => {
|
||||
it("should be possible to buy product in a shipping weight limits. TC: SALEOR_0902", () => {
|
||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createShippingRate({
|
||||
|
@ -108,7 +108,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("should not be possible to buy product not in a shipping weight limits", () => {
|
||||
it("should not be possible to buy product not in a shipping weight limits. TC: SALEOR_0903", () => {
|
||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
createShippingRate({
|
||||
|
|
|
@ -18,7 +18,7 @@ import filterTests from "../../../../support/filterTests";
|
|||
import { changeWeightUnit } from "../../../../support/pages/shippingMethodPage";
|
||||
|
||||
filterTests({ definedTags: ["all"] }, () => {
|
||||
describe("Recalculate weights", () => {
|
||||
describe("As a staff user I want to change shop default weight unit", () => {
|
||||
const startsWith = "RecalculateWeight";
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
|
||||
|
@ -48,7 +48,7 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
});
|
||||
|
||||
// Log in as user with shipping permissions after resolving SALEOR-3407 bug
|
||||
it("should recalculate weight after changing shipping weight unit", () => {
|
||||
it("should recalculate weight after changing shipping weight unit. TC: SALEOR_0901", () => {
|
||||
const rateName = `${startsWith}${faker.datatype.number()}`;
|
||||
const minWeightInKg = 1;
|
||||
const maxWeightInKg = 10;
|
||||
|
@ -88,12 +88,12 @@ filterTests({ definedTags: ["all"] }, () => {
|
|||
expect(rate.minimumOrderWeight.unit).to.eq("G");
|
||||
cy.get(SHIPPING_RATE_DETAILS.restrictWeightLimitCheckbox)
|
||||
.click()
|
||||
.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
||||
.get(SHIPPING_RATE_DETAILS.minValueInput)
|
||||
.invoke("val");
|
||||
})
|
||||
.then(actualMinWeight => {
|
||||
expect(parseInt(actualMinWeight, 10)).to.eq(minWeightInG);
|
||||
cy.get(SHIPPING_RATE_DETAILS.maxWeightInput).invoke("val");
|
||||
cy.get(SHIPPING_RATE_DETAILS.maxValueInput).invoke("val");
|
||||
})
|
||||
.then(actualMaxWeight => {
|
||||
expect(parseInt(actualMaxWeight, 10)).to.eq(maxWeightInG);
|
||||
|
|
|
@ -80,14 +80,16 @@ export function createShippingRate({
|
|||
price,
|
||||
rateOption,
|
||||
weightLimits,
|
||||
deliveryTime
|
||||
deliveryTime,
|
||||
priceLimits
|
||||
}) {
|
||||
enterAndFillUpShippingRate({
|
||||
rateName,
|
||||
price,
|
||||
rateOption,
|
||||
weightLimits,
|
||||
deliveryTime
|
||||
deliveryTime,
|
||||
priceLimits
|
||||
});
|
||||
return saveRate();
|
||||
}
|
||||
|
@ -97,6 +99,7 @@ export function enterAndFillUpShippingRate({
|
|||
price,
|
||||
rateOption,
|
||||
weightLimits,
|
||||
priceLimits,
|
||||
deliveryTime
|
||||
}) {
|
||||
cy.get(rateOption).click();
|
||||
|
@ -104,6 +107,7 @@ export function enterAndFillUpShippingRate({
|
|||
rateName,
|
||||
price,
|
||||
weightLimits,
|
||||
priceLimits,
|
||||
deliveryTime
|
||||
});
|
||||
}
|
||||
|
@ -112,6 +116,7 @@ export function fillUpShippingRate({
|
|||
rateName,
|
||||
price,
|
||||
weightLimits,
|
||||
priceLimits,
|
||||
deliveryTime
|
||||
}) {
|
||||
cy.waitForProgressBarToNotBeVisible()
|
||||
|
@ -123,7 +128,10 @@ export function fillUpShippingRate({
|
|||
fillUpDeliveryTime(deliveryTime);
|
||||
}
|
||||
if (weightLimits) {
|
||||
fillUpWeightLimits(weightLimits);
|
||||
fillUpLimits(weightLimits);
|
||||
}
|
||||
if (priceLimits) {
|
||||
fillUpLimits(priceLimits);
|
||||
}
|
||||
cy.get(SHIPPING_RATE_DETAILS.priceInput).each($priceInput => {
|
||||
cy.wrap($priceInput).clearAndType(price);
|
||||
|
@ -173,10 +181,10 @@ export function saveRateAfterUpdate() {
|
|||
.waitForRequestAndCheckIfNoErrors(`@ShippingMethodChannelListingUpdate`);
|
||||
}
|
||||
|
||||
export function fillUpWeightLimits({ max, min }) {
|
||||
cy.get(SHIPPING_RATE_DETAILS.minWeightInput)
|
||||
export function fillUpLimits({ max, min }) {
|
||||
cy.get(SHIPPING_RATE_DETAILS.minValueInput)
|
||||
.type(min)
|
||||
.get(SHIPPING_RATE_DETAILS.maxWeightInput)
|
||||
.get(SHIPPING_RATE_DETAILS.maxValueInput)
|
||||
.type(max);
|
||||
}
|
||||
|
||||
|
|
63
cypress/support/pages/shippingZones.js
Normal file
63
cypress/support/pages/shippingZones.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
|
||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||
import {
|
||||
SHIPPING_ZONE_CHECKBOX,
|
||||
SHIPPING_ZONE_NAME
|
||||
} from "../../elements/shipping/shipping-zones-list";
|
||||
import { urlList } from "../../fixtures/urlList";
|
||||
|
||||
export function enterAndSelectShippings(
|
||||
shippingIds,
|
||||
actionFunction = selectShippingZone
|
||||
) {
|
||||
cy.addAliasToGraphRequest("ShippingZones").visit(urlList.shippingMethods);
|
||||
selectShippingsOnTable(shippingIds, actionFunction);
|
||||
}
|
||||
|
||||
export function selectShippingsOnTable(
|
||||
shippingIds,
|
||||
actionFunction = selectShippingZone,
|
||||
counter = 0
|
||||
) {
|
||||
cy.get(SHARED_ELEMENTS.skeleton)
|
||||
.should("not.exist")
|
||||
.wait("@ShippingZones")
|
||||
.its("response.body")
|
||||
.then(body => {
|
||||
const shippingResults = body.find(element => {
|
||||
if (element.data.shippingZones) {
|
||||
return element;
|
||||
}
|
||||
});
|
||||
const shippingList = shippingResults.data.shippingZones.edges;
|
||||
const notSelectedShippings = [];
|
||||
shippingIds = Array.isArray(shippingIds) ? shippingIds : [shippingIds];
|
||||
shippingIds.forEach(id => {
|
||||
const isShippingOnList = shippingList.find(
|
||||
element => element.node.id === id
|
||||
);
|
||||
if (isShippingOnList) {
|
||||
actionFunction(id);
|
||||
counter += 1;
|
||||
} else {
|
||||
notSelectedShippings.push(id);
|
||||
}
|
||||
if (counter === shippingIds.length) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (counter === shippingIds.length) {
|
||||
return;
|
||||
}
|
||||
cy.get(BUTTON_SELECTORS.nextPaginationButton).click();
|
||||
selectShippingsOnTable(notSelectedShippings, actionFunction, counter);
|
||||
});
|
||||
}
|
||||
|
||||
export function selectShippingZone(id) {
|
||||
cy.get(SHIPPING_ZONE_CHECKBOX(id)).click();
|
||||
}
|
||||
|
||||
export function enterShippingZone(id) {
|
||||
cy.get(SHIPPING_ZONE_NAME(id)).click();
|
||||
}
|
|
@ -149,9 +149,13 @@ const ShippingZonesList: React.FC<ShippingZonesListProps> = props => {
|
|||
disabled={disabled}
|
||||
disableClickPropagation
|
||||
onChange={() => toggle(shippingZone.id)}
|
||||
data-test-id={maybe(() => shippingZone.id + "-checkbox")}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className={classes.colName}>
|
||||
<TableCell
|
||||
className={classes.colName}
|
||||
data-test-id={maybe(() => shippingZone.id + "-name")}
|
||||
>
|
||||
{maybe<React.ReactNode>(
|
||||
() => shippingZone.name,
|
||||
<Skeleton />
|
||||
|
|
|
@ -168,6 +168,7 @@ export const ShippingZonesList: React.FC<ShippingZonesListProps> = ({
|
|||
toggleAll={toggleAll}
|
||||
toolbar={
|
||||
<IconButton
|
||||
data-test-id="delete-selected-elements-icon"
|
||||
variant="secondary"
|
||||
color="primary"
|
||||
onClick={() =>
|
||||
|
|
|
@ -236783,6 +236783,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjE=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -236816,6 +236817,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjE=-name"
|
||||
>
|
||||
Europe
|
||||
</td>
|
||||
|
@ -236858,6 +236860,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjI=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -236891,6 +236894,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjI=-name"
|
||||
>
|
||||
Oceania
|
||||
</td>
|
||||
|
@ -236933,6 +236937,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjM=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -236966,6 +236971,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjM=-name"
|
||||
>
|
||||
Asia
|
||||
</td>
|
||||
|
@ -237008,6 +237014,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjQ=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -237041,6 +237048,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjQ=-name"
|
||||
>
|
||||
Americas
|
||||
</td>
|
||||
|
@ -237083,6 +237091,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjU=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -237116,6 +237125,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list default 1`] = `
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjU=-name"
|
||||
>
|
||||
Africa
|
||||
</td>
|
||||
|
@ -238211,6 +238221,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjE=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -238244,6 +238255,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjE=-name"
|
||||
>
|
||||
Europe
|
||||
</td>
|
||||
|
@ -238286,6 +238298,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjI=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -238319,6 +238332,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjI=-name"
|
||||
>
|
||||
Oceania
|
||||
</td>
|
||||
|
@ -238361,6 +238375,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjM=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -238394,6 +238409,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjM=-name"
|
||||
>
|
||||
Asia
|
||||
</td>
|
||||
|
@ -238436,6 +238452,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjQ=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -238469,6 +238486,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjQ=-name"
|
||||
>
|
||||
Americas
|
||||
</td>
|
||||
|
@ -238511,6 +238529,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id MuiIconButton-colorPrimary-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjU=-checkbox"
|
||||
>
|
||||
<span
|
||||
class="MuiIconButton-label-id"
|
||||
|
@ -238544,6 +238563,7 @@ exports[`Storyshots Views / Shipping / Shipping zones list no site settings perm
|
|||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root-id MuiTableCell-body-id ShippingZonesList-colName-id"
|
||||
data-test-id="U2hpcHBpbmdab25lOjU=-name"
|
||||
>
|
||||
Africa
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue