saleor-dashboard/cypress/support/pages/homePage.js
Karolina Rakoczy f85786f203
Run critical tests after test env deployment (#1902)
* run critical tests after test env deployment

* add cache

* add all branches

* change workflow name

* add run on pull request for testing

* change type

* add run on deployment

* run on copleted

* test critical

* add quote

* change baseUrl

* fix base url

* fix base url

* upload reports

* run in parallel

* save build folder

* remove build from gitignore

* remove build

* update nide version

* last try with parallel

* save build

* save build

* Run critical

* change cypress API url

* run critical in parallel

* check which workflow has lower duration time

* save all reports with container in name

* add reports on failure

* remove reporters

* fix jobs

* merge

* add group name

* run critical

* Refactor critical tests (#1906)

* refactored tag added to purchaseWithProductsTypes, navigation, stocksInCheckout

* homePageAnalitics - refactor

* refactor home page

* refactor creating variants

* refactor adding product without sku to order

* add script to run critical locally

* change tests cases names

* fix names, remove comments, add script to run refactored tests

* remove workflow for parallel

* remove key
2022-03-21 13:17:37 +01:00

78 lines
2.5 KiB
JavaScript

import { HEADER_SELECTORS } from "../../elements/header/header-selectors";
import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors";
export function changeChannel(channelName) {
cy.get(HEADER_SELECTORS.channelSelect)
.click()
.addAliasToGraphRequest("Home")
.get(HEADER_SELECTORS.channelSelectList)
.contains(channelName)
.click()
.wait("@Home");
}
export function expectWelcomeMessageIncludes(name) {
cy.get(HOMEPAGE_SELECTORS.welcomeMessage)
.invoke("text")
.then(text => {
expect(text, `welcome message should contains ${name}`).to.contains(name);
});
}
export function getOrdersReadyToFulfillRegex(
ordersReadyToFulfillBefore,
quantityOfNewOrders
) {
const allOrdersReadyToFulfill =
ordersReadyToFulfillBefore + quantityOfNewOrders;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`
);
}
export function getOrdersReadyForCaptureRegex(
ordersReadyForCaptureBefore,
quantityOfNewOrders
) {
const allOrdersReadyForCapture =
ordersReadyForCaptureBefore + quantityOfNewOrders;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`
);
}
export function getProductsOutOfStockRegex(
productsOutOfStockBefore,
quantityOfNewProducts
) {
const allProductsOutOfStock =
productsOutOfStockBefore + quantityOfNewProducts;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`
);
}
export function getSalesAmountRegex(salesAmountBefore, addedAmount) {
const totalAmount = salesAmountBefore + addedAmount;
const totalAmountString = totalAmount.toFixed(2);
const totalAmountIntegerValue = totalAmountString.split(".")[0];
const totalAmountDecimalValue = totalAmountString.split(".")[1];
const decimalSeparator = "[,.]";
const totalAmountIntegerWithThousandsSeparator = new Intl.NumberFormat("en")
.format(totalAmountIntegerValue)
.replaceAll(",", "[,.]*");
const totalAmountWithSeparators = `${totalAmountIntegerWithThousandsSeparator}${decimalSeparator}${totalAmountDecimalValue}`;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`
);
}
export function getTodaysOrdersRegex(ordersBefore, quantityOfNewOrders) {
const allOrders = ordersBefore + quantityOfNewOrders;
const notANumberRegex = "\\D*";
return new RegExp(`${notANumberRegex}${allOrders}${notANumberRegex}`);
}