rename regex
This commit is contained in:
parent
9bb20551f9
commit
8ecfa78a8b
2 changed files with 71 additions and 45 deletions
|
@ -102,13 +102,18 @@ describe("User authorization", () => {
|
||||||
defaultChannel.id,
|
defaultChannel.id,
|
||||||
productsUtils.getCreatedVariants()
|
productsUtils.getCreatedVariants()
|
||||||
);
|
);
|
||||||
cy.get("@ordersReadyToFulfill").then(ordersReadyToFulfill => {
|
cy.get("@ordersReadyToFulfill").then(ordersReadyToFulfillBefore => {
|
||||||
const regexp = new RegExp(`^${ordersReadyToFulfill + 1}\D*`);
|
const allOrdersReadyToFulfill = ordersReadyToFulfillBefore + 1;
|
||||||
|
const notANumberRegex = "\\D*";
|
||||||
|
const ordersReadyToFulfillRegexp = new RegExp(
|
||||||
|
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`
|
||||||
|
);
|
||||||
cy.visit(urlList.homePage);
|
cy.visit(urlList.homePage);
|
||||||
homePageSteps.changeChannel(defaultChannel.name);
|
homePageSteps.changeChannel(defaultChannel.name);
|
||||||
cy.contains(HOMEPAGE_SELECTORS.ordersReadyToFulfill, regexp).should(
|
cy.contains(
|
||||||
"be.visible"
|
HOMEPAGE_SELECTORS.ordersReadyToFulfill,
|
||||||
);
|
ordersReadyToFulfillRegexp
|
||||||
|
).should("be.visible");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should correct amount of payments waiting for capture be displayed", () => {
|
it("should correct amount of payments waiting for capture be displayed", () => {
|
||||||
|
@ -124,13 +129,18 @@ describe("User authorization", () => {
|
||||||
shippingUtils.getShippingMethod().id
|
shippingUtils.getShippingMethod().id
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get("@ordersReadyForCapture").then(ordersReadyForCapture => {
|
cy.get("@ordersReadyForCapture").then(ordersReadyForCaptureBefore => {
|
||||||
const regexp = new RegExp(`^${ordersReadyForCapture + 1}\D*`);
|
const allOrdersReadyForCapture = ordersReadyForCaptureBefore + 1;
|
||||||
|
const notANumberRegex = "\\D*";
|
||||||
|
const ordersReadyForCaptureRegexp = new RegExp(
|
||||||
|
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`
|
||||||
|
);
|
||||||
cy.visit(urlList.homePage);
|
cy.visit(urlList.homePage);
|
||||||
homePageSteps.changeChannel(defaultChannel.name);
|
homePageSteps.changeChannel(defaultChannel.name);
|
||||||
cy.contains(HOMEPAGE_SELECTORS.ordersReadyForCapture, regexp).should(
|
cy.contains(
|
||||||
"be.visible"
|
HOMEPAGE_SELECTORS.ordersReadyForCapture,
|
||||||
);
|
ordersReadyForCaptureRegexp
|
||||||
|
).should("be.visible");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should correct amount of products out of stock be displayed", () => {
|
it("should correct amount of products out of stock be displayed", () => {
|
||||||
|
@ -155,13 +165,18 @@ describe("User authorization", () => {
|
||||||
productPrice
|
productPrice
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get("@productsOutOfStock").then(productsOutOfStock => {
|
cy.get("@productsOutOfStock").then(productsOutOfStockBefore => {
|
||||||
const regexp = new RegExp(`^${productsOutOfStock + 1}\\D*`);
|
const allProductsOutOfStock = productsOutOfStockBefore + 1;
|
||||||
|
const notANumberRegex = "\\D*";
|
||||||
|
const productsOutOfStockRegexp = new RegExp(
|
||||||
|
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`
|
||||||
|
);
|
||||||
cy.visit(urlList.homePage);
|
cy.visit(urlList.homePage);
|
||||||
homePageSteps.changeChannel(defaultChannel.name);
|
homePageSteps.changeChannel(defaultChannel.name);
|
||||||
cy.contains(HOMEPAGE_SELECTORS.productsOutOfStock, regexp).should(
|
cy.contains(
|
||||||
"be.visible"
|
HOMEPAGE_SELECTORS.productsOutOfStock,
|
||||||
);
|
productsOutOfStockRegexp
|
||||||
|
).should("be.visible");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should correct amount of sales be displayed", () => {
|
it("should correct amount of sales be displayed", () => {
|
||||||
|
@ -175,19 +190,25 @@ describe("User authorization", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get("@salesAmount").then(salesAmount => {
|
cy.get("@salesAmount").then(salesAmount => {
|
||||||
let totalAmount = salesAmount + productPrice;
|
const totalAmount = salesAmount + productPrice;
|
||||||
totalAmount = totalAmount
|
const totalAmountString = totalAmount.toFixed(2);
|
||||||
.toFixed(2)
|
const totalAmountIntegerValue = totalAmountString.split(".")[0];
|
||||||
.toString()
|
const totalAmountDecimalValue = totalAmountString.split(".")[1];
|
||||||
.split(".");
|
const decimalSeparator = "[,.]";
|
||||||
totalAmount = `\\D*${totalAmount[0].replace(
|
const totalAmountIntegerWithThousandsSeparator = totalAmountIntegerValue.replace(
|
||||||
/(\d)(?=(\d{3})+(?!\d))/g,
|
/(\d)(?=(\d{3})+(?!\d))/g,
|
||||||
"$1[,.]*"
|
"1[,.]*"
|
||||||
)}[,.]${totalAmount[1]}\\D*`;
|
);
|
||||||
const regexp = new RegExp(totalAmount);
|
const totalAmountWithSeparators = `${totalAmountIntegerWithThousandsSeparator}${decimalSeparator}${totalAmountDecimalValue}`;
|
||||||
|
const notANumberRegex = "\\D*";
|
||||||
|
const salesAmountRegexp = new RegExp(
|
||||||
|
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`
|
||||||
|
);
|
||||||
cy.visit(urlList.homePage);
|
cy.visit(urlList.homePage);
|
||||||
homePageSteps.changeChannel(defaultChannel.name);
|
homePageSteps.changeChannel(defaultChannel.name);
|
||||||
cy.contains(HOMEPAGE_SELECTORS.sales, regexp).should("be.visible");
|
cy.contains(HOMEPAGE_SELECTORS.sales, salesAmountRegexp).should(
|
||||||
|
"be.visible"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should correct amount of orders be displayed", () => {
|
it("should correct amount of orders be displayed", () => {
|
||||||
|
@ -200,11 +221,15 @@ describe("User authorization", () => {
|
||||||
productsUtils.getCreatedVariants()
|
productsUtils.getCreatedVariants()
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get("@todaysOrders").then(todaysOrders => {
|
cy.get("@todaysOrders").then(ordersBefore => {
|
||||||
const regexp = new RegExp(`\\D*${todaysOrders + 1}\\D*`);
|
const allOrders = ordersBefore + 1;
|
||||||
|
const notANumberRegex = "\\D*";
|
||||||
|
const ordersRegexp = new RegExp(
|
||||||
|
`${notANumberRegex}${allOrders}${notANumberRegex}`
|
||||||
|
);
|
||||||
cy.visit(urlList.homePage);
|
cy.visit(urlList.homePage);
|
||||||
homePageSteps.changeChannel(defaultChannel.name);
|
homePageSteps.changeChannel(defaultChannel.name);
|
||||||
cy.contains(HOMEPAGE_SELECTORS.orders, regexp).should("be.visible");
|
cy.contains(HOMEPAGE_SELECTORS.orders, ordersRegexp).should("be.visible");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,24 +6,25 @@ class ChannelsUtils {
|
||||||
deleteChannels(nameStartsWith) {
|
deleteChannels(nameStartsWith) {
|
||||||
this.channels.getChannels().then(resp => {
|
this.channels.getChannels().then(resp => {
|
||||||
const channelsArray = new Set(resp.body.data.channels);
|
const channelsArray = new Set(resp.body.data.channels);
|
||||||
if (channelsArray) {
|
if (!channelsArray) {
|
||||||
channelsArray.forEach(element => {
|
return;
|
||||||
if (element.name.startsWith(nameStartsWith)) {
|
|
||||||
const targetChannels = Array.from(channelsArray).filter(function(
|
|
||||||
channelElement
|
|
||||||
) {
|
|
||||||
return (
|
|
||||||
element.currencyCode === channelElement.currencyCode &&
|
|
||||||
element.id !== channelElement.id
|
|
||||||
);
|
|
||||||
});
|
|
||||||
if (targetChannels[0]) {
|
|
||||||
this.channels.deleteChannel(element.id, targetChannels[0].id);
|
|
||||||
channelsArray.delete(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
channelsArray.forEach(element => {
|
||||||
|
if (element.name.startsWith(nameStartsWith)) {
|
||||||
|
const targetChannels = Array.from(channelsArray).filter(function(
|
||||||
|
channelElement
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
element.currencyCode === channelElement.currencyCode &&
|
||||||
|
element.id !== channelElement.id
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if (targetChannels[0]) {
|
||||||
|
this.channels.deleteChannel(element.id, targetChannels[0].id);
|
||||||
|
channelsArray.delete(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getDefaultChannel() {
|
getDefaultChannel() {
|
||||||
|
|
Loading…
Reference in a new issue