saleor-dashboard/cypress/integration/homePage/homePageAnalitics.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

171 lines
5.4 KiB
JavaScript

/// <reference types="cypress"/>
/// <reference types="../../support"/>
import faker from "faker";
import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors";
import { urlList } from "../../fixtures/urlList";
import { createCustomer } from "../../support/api/requests/Customer";
import * as homePageUtils from "../../support/api/utils/homePageUtils";
import {
createReadyToFulfillOrder,
createWaitingForCaptureOrder
} from "../../support/api/utils/ordersUtils";
import * as productsUtils from "../../support/api/utils/products/productsUtils";
import filterTests from "../../support/filterTests";
import {
changeChannel,
getOrdersReadyForCaptureRegex,
getOrdersReadyToFulfillRegex,
getProductsOutOfStockRegex,
getSalesAmountRegex,
getTodaysOrdersRegex
} from "../../support/pages/homePage";
filterTests({ definedTags: ["all", "critical", "refactored"] }, () => {
describe("As an admin I want to see correct information on dashboard home page", () => {
const startsWith = "CyHomeAnalytics";
const productPrice = 22;
const shippingPrice = 12;
const randomName = startsWith + faker.datatype.number();
const randomEmail = `${startsWith}${randomName}@example.com`;
let customer;
let defaultChannel;
let createdVariants;
let productType;
let attribute;
let category;
let warehouse;
let shippingMethod;
let address;
let ordersReadyToFulfillRegexp;
let ordersReadyForCaptureRegexp;
let productsOutOfStockRegexp;
let salesAmountRegexp;
let ordersRegexp;
before(() => {
cy.clearSessionData().loginUserViaRequest();
productsUtils
.createProductWithShipping({
name: randomName,
productPrice,
shippingPrice
})
.then(resp => {
createdVariants = resp.variantsList;
address = resp.address;
warehouse = resp.warehouse;
defaultChannel = resp.defaultChannel;
shippingMethod = resp.shippingMethod;
attribute = resp.attribute;
category = resp.category;
productType = resp.productType;
createCustomer(randomEmail, randomName, address).then(
customerResp => (customer = customerResp)
);
homePageUtils
.getOrdersReadyToFulfill(defaultChannel.slug)
.then(ordersReadyToFulfillBefore => {
ordersReadyToFulfillRegexp = getOrdersReadyToFulfillRegex(
ordersReadyToFulfillBefore,
1
);
});
homePageUtils
.getOrdersReadyForCapture(defaultChannel.slug)
.then(ordersReadyForCaptureBefore => {
ordersReadyForCaptureRegexp = getOrdersReadyForCaptureRegex(
ordersReadyForCaptureBefore,
1
);
});
homePageUtils
.getProductsOutOfStock(defaultChannel.slug)
.then(productsOutOfStockBefore => {
productsOutOfStockRegexp = getProductsOutOfStockRegex(
productsOutOfStockBefore,
1
);
});
homePageUtils
.getSalesAmount(defaultChannel.slug)
.then(salesAmount => {
salesAmountRegexp = getSalesAmountRegex(
salesAmount,
productPrice * 2 + shippingPrice
);
});
homePageUtils
.getTodaysOrders(defaultChannel.slug)
.then(ordersBefore => {
ordersRegexp = getTodaysOrdersRegex(ordersBefore, 2);
});
})
.then(() => {
createReadyToFulfillOrder({
customerId: customer.id,
shippingMethodId: shippingMethod.id,
channelId: defaultChannel.id,
variantsList: createdVariants,
address
});
createWaitingForCaptureOrder({
channelSlug: defaultChannel.slug,
email: randomEmail,
variantsList: createdVariants,
shippingMethodName: shippingMethod.name,
address
});
const productOutOfStockRandomName =
startsWith + faker.datatype.number();
productsUtils.createProductInChannel({
name: productOutOfStockRandomName,
channelId: defaultChannel.id,
warehouseId: warehouse.id,
quantityInWarehouse: 0,
productTypeId: productType.id,
attributeId: attribute.id,
categoryId: category.id,
price: productPrice
});
});
});
beforeEach(() => {
cy.clearSessionData().loginUserViaRequest();
});
it("should display correct information on dashboard home page. SALEOR_2004", () => {
cy.visit(urlList.homePage);
changeChannel(defaultChannel.name);
cy.contains(HOMEPAGE_SELECTORS.orders, ordersRegexp).should("be.visible");
cy.contains(
HOMEPAGE_SELECTORS.ordersReadyToFulfill,
ordersReadyToFulfillRegexp
).should("be.visible");
cy.contains(
HOMEPAGE_SELECTORS.ordersReadyForCapture,
ordersReadyForCaptureRegexp
).should("be.visible");
cy.contains(HOMEPAGE_SELECTORS.sales, salesAmountRegexp).should(
"be.visible"
);
cy.contains(
HOMEPAGE_SELECTORS.productsOutOfStock,
productsOutOfStockRegexp
).should("be.visible");
});
});
});