2021-02-15 09:44:50 +00:00
|
|
|
import faker from "faker";
|
|
|
|
|
2021-03-15 13:16:02 +00:00
|
|
|
import {
|
|
|
|
createCustomer,
|
|
|
|
deleteCustomersStartsWith
|
2021-05-16 11:38:53 +00:00
|
|
|
} from "../../../apiRequests/Customer";
|
|
|
|
import { HOMEPAGE_SELECTORS } from "../../../elements/homePage/homePage-selectors";
|
|
|
|
import { changeChannel } from "../../../steps/homePageSteps";
|
|
|
|
import { urlList } from "../../../url/urlList";
|
|
|
|
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
|
|
|
import * as homePageUtils from "../../../utils/homePageUtils";
|
2021-03-12 12:14:18 +00:00
|
|
|
import {
|
|
|
|
createReadyToFulfillOrder,
|
|
|
|
createWaitingForCaptureOrder
|
2021-05-16 11:38:53 +00:00
|
|
|
} from "../../../utils/ordersUtils";
|
|
|
|
import * as productsUtils from "../../../utils/products/productsUtils";
|
|
|
|
import * as shippingUtils from "../../../utils/shippingUtils";
|
2021-02-15 09:44:50 +00:00
|
|
|
|
|
|
|
// <reference types="cypress" />
|
2021-02-18 19:50:12 +00:00
|
|
|
describe("Homepage analytics", () => {
|
2021-04-16 11:36:24 +00:00
|
|
|
const startsWith = "CyHomeAnalytics-";
|
2021-02-15 09:44:50 +00:00
|
|
|
|
|
|
|
let customerId;
|
|
|
|
let defaultChannel;
|
2021-03-12 12:14:18 +00:00
|
|
|
let createdVariants;
|
|
|
|
let productType;
|
|
|
|
let attribute;
|
|
|
|
let category;
|
|
|
|
let warehouse;
|
|
|
|
let shippingMethod;
|
2021-04-16 11:36:24 +00:00
|
|
|
let addresses;
|
2021-03-12 12:14:18 +00:00
|
|
|
|
2021-02-15 09:44:50 +00:00
|
|
|
const productPrice = 22;
|
|
|
|
const shippingPrice = 12;
|
2021-04-21 13:14:38 +00:00
|
|
|
const randomName = startsWith + faker.datatype.number();
|
2021-02-15 09:44:50 +00:00
|
|
|
const randomEmail = randomName + "@example.com";
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
2021-03-12 12:14:18 +00:00
|
|
|
productsUtils.deleteProductsStartsWith(startsWith);
|
2021-03-15 13:16:02 +00:00
|
|
|
deleteCustomersStartsWith(startsWith);
|
2021-03-12 12:14:18 +00:00
|
|
|
shippingUtils.deleteShippingStartsWith(startsWith);
|
2021-02-15 09:44:50 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
getDefaultChannel()
|
2021-02-16 20:48:37 +00:00
|
|
|
.then(channel => {
|
|
|
|
defaultChannel = channel;
|
|
|
|
cy.fixture("addresses");
|
|
|
|
})
|
|
|
|
.then(addressesFixture => (addresses = addressesFixture))
|
2021-03-12 12:14:18 +00:00
|
|
|
.then(() => createCustomer(randomEmail, randomName, addresses.plAddress))
|
2021-02-16 20:48:37 +00:00
|
|
|
.then(resp => {
|
|
|
|
customerId = resp.body.data.customerCreate.user.id;
|
2021-02-23 12:09:58 +00:00
|
|
|
shippingUtils.createShipping({
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
name: randomName,
|
|
|
|
address: addresses.plAddress,
|
|
|
|
price: shippingPrice
|
|
|
|
});
|
2021-02-16 20:48:37 +00:00
|
|
|
})
|
2021-03-12 12:14:18 +00:00
|
|
|
.then(
|
|
|
|
({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
|
|
|
|
warehouse = warehouseResp;
|
|
|
|
shippingMethod = shippingMethodResp;
|
|
|
|
productsUtils.createTypeAttributeAndCategoryForProduct(randomName);
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.then(
|
|
|
|
({
|
|
|
|
productType: productTypeResp,
|
|
|
|
attribute: attributeResp,
|
|
|
|
category: categoryResp
|
|
|
|
}) => {
|
|
|
|
productType = productTypeResp;
|
|
|
|
attribute = attributeResp;
|
|
|
|
category = categoryResp;
|
|
|
|
productsUtils.createProductInChannel({
|
|
|
|
name: randomName,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
warehouseId: warehouse.id,
|
|
|
|
quantityInWarehouse: 20,
|
|
|
|
productTypeId: productType.id,
|
|
|
|
attributeId: attribute.id,
|
|
|
|
categoryId: category.id,
|
|
|
|
price: productPrice
|
|
|
|
});
|
|
|
|
}
|
|
|
|
)
|
2021-04-28 13:10:47 +00:00
|
|
|
.then(({ variantsList: variantsResp }) => {
|
2021-03-12 12:14:18 +00:00
|
|
|
createdVariants = variantsResp;
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.clearSessionData().loginUserViaRequest();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should all elements be visible on the dashboard", () => {
|
|
|
|
cy.visit(urlList.homePage)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.sales)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.orders)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.activity)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.topProducts)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.ordersReadyToFulfill)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.paymentsWaitingForCapture)
|
|
|
|
.softAssertVisibility(HOMEPAGE_SELECTORS.productsOutOfStock);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should correct amount of ready to fullfil orders be displayed", () => {
|
|
|
|
homePageUtils
|
|
|
|
.getOrdersReadyToFulfill(defaultChannel.slug)
|
|
|
|
.as("ordersReadyToFulfill");
|
2021-03-12 12:14:18 +00:00
|
|
|
createReadyToFulfillOrder(
|
2021-02-15 09:44:50 +00:00
|
|
|
customerId,
|
2021-03-12 12:14:18 +00:00
|
|
|
shippingMethod.id,
|
2021-02-15 09:44:50 +00:00
|
|
|
defaultChannel.id,
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
createdVariants,
|
|
|
|
addresses.plAddress
|
2021-02-15 09:44:50 +00:00
|
|
|
);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.get("@ordersReadyToFulfill").then(ordersReadyToFulfillBefore => {
|
|
|
|
const allOrdersReadyToFulfill = ordersReadyToFulfillBefore + 1;
|
|
|
|
const notANumberRegex = "\\D*";
|
|
|
|
const ordersReadyToFulfillRegexp = new RegExp(
|
|
|
|
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2021-03-12 12:14:18 +00:00
|
|
|
changeChannel(defaultChannel.name);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.contains(
|
|
|
|
HOMEPAGE_SELECTORS.ordersReadyToFulfill,
|
|
|
|
ordersReadyToFulfillRegexp
|
|
|
|
).should("be.visible");
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
it("should correct amount of payments waiting for capture be displayed", () => {
|
|
|
|
homePageUtils
|
|
|
|
.getOrdersReadyForCapture(defaultChannel.slug)
|
|
|
|
.as("ordersReadyForCapture");
|
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
createWaitingForCaptureOrder(
|
2021-02-15 09:44:50 +00:00
|
|
|
defaultChannel.slug,
|
|
|
|
randomEmail,
|
2021-03-12 12:14:18 +00:00
|
|
|
createdVariants,
|
2021-04-16 11:36:24 +00:00
|
|
|
shippingMethod.id,
|
|
|
|
addresses.plAddress
|
2021-02-15 09:44:50 +00:00
|
|
|
);
|
|
|
|
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.get("@ordersReadyForCapture").then(ordersReadyForCaptureBefore => {
|
|
|
|
const allOrdersReadyForCapture = ordersReadyForCaptureBefore + 1;
|
|
|
|
const notANumberRegex = "\\D*";
|
|
|
|
const ordersReadyForCaptureRegexp = new RegExp(
|
|
|
|
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2021-03-12 12:14:18 +00:00
|
|
|
changeChannel(defaultChannel.name);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.contains(
|
|
|
|
HOMEPAGE_SELECTORS.ordersReadyForCapture,
|
|
|
|
ordersReadyForCaptureRegexp
|
|
|
|
).should("be.visible");
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
it("should correct amount of products out of stock be displayed", () => {
|
|
|
|
homePageUtils
|
|
|
|
.getProductsOutOfStock(defaultChannel.slug)
|
|
|
|
.as("productsOutOfStock");
|
2021-04-21 13:14:38 +00:00
|
|
|
const productOutOfStockRandomName = startsWith + faker.datatype.number();
|
2021-02-15 09:44:50 +00:00
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
productsUtils.createProductInChannel({
|
2021-02-23 12:09:58 +00:00
|
|
|
name: productOutOfStockRandomName,
|
|
|
|
channelId: defaultChannel.id,
|
|
|
|
warehouseId: warehouse.id,
|
|
|
|
quantityInWarehouse: 0,
|
|
|
|
productTypeId: productType.id,
|
|
|
|
attributeId: attribute.id,
|
|
|
|
categoryId: category.id,
|
|
|
|
price: productPrice
|
|
|
|
});
|
2021-02-15 09:44:50 +00:00
|
|
|
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.get("@productsOutOfStock").then(productsOutOfStockBefore => {
|
|
|
|
const allProductsOutOfStock = productsOutOfStockBefore + 1;
|
|
|
|
const notANumberRegex = "\\D*";
|
|
|
|
const productsOutOfStockRegexp = new RegExp(
|
|
|
|
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2021-03-12 12:14:18 +00:00
|
|
|
changeChannel(defaultChannel.name);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.contains(
|
|
|
|
HOMEPAGE_SELECTORS.productsOutOfStock,
|
|
|
|
productsOutOfStockRegexp
|
|
|
|
).should("be.visible");
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
it("should correct amount of sales be displayed", () => {
|
|
|
|
homePageUtils.getSalesAmount(defaultChannel.slug).as("salesAmount");
|
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
createReadyToFulfillOrder(
|
2021-02-15 09:44:50 +00:00
|
|
|
customerId,
|
2021-03-12 12:14:18 +00:00
|
|
|
shippingMethod.id,
|
2021-02-15 09:44:50 +00:00
|
|
|
defaultChannel.id,
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
createdVariants,
|
|
|
|
addresses.plAddress
|
2021-02-15 09:44:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
cy.get("@salesAmount").then(salesAmount => {
|
2021-02-17 11:22:24 +00:00
|
|
|
const totalAmount = salesAmount + productPrice;
|
|
|
|
const totalAmountString = totalAmount.toFixed(2);
|
|
|
|
const totalAmountIntegerValue = totalAmountString.split(".")[0];
|
|
|
|
const totalAmountDecimalValue = totalAmountString.split(".")[1];
|
|
|
|
const decimalSeparator = "[,.]";
|
|
|
|
const totalAmountIntegerWithThousandsSeparator = totalAmountIntegerValue.replace(
|
2021-02-16 23:11:46 +00:00
|
|
|
/(\d)(?=(\d{3})+(?!\d))/g,
|
2021-02-17 11:22:24 +00:00
|
|
|
"1[,.]*"
|
|
|
|
);
|
|
|
|
const totalAmountWithSeparators = `${totalAmountIntegerWithThousandsSeparator}${decimalSeparator}${totalAmountDecimalValue}`;
|
|
|
|
const notANumberRegex = "\\D*";
|
|
|
|
const salesAmountRegexp = new RegExp(
|
|
|
|
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2021-03-12 12:14:18 +00:00
|
|
|
changeChannel(defaultChannel.name);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.contains(HOMEPAGE_SELECTORS.sales, salesAmountRegexp).should(
|
|
|
|
"be.visible"
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
it("should correct amount of orders be displayed", () => {
|
|
|
|
homePageUtils.getTodaysOrders(defaultChannel.slug).as("todaysOrders");
|
|
|
|
|
2021-03-12 12:14:18 +00:00
|
|
|
createReadyToFulfillOrder(
|
2021-02-15 09:44:50 +00:00
|
|
|
customerId,
|
2021-03-12 12:14:18 +00:00
|
|
|
shippingMethod.id,
|
2021-02-15 09:44:50 +00:00
|
|
|
defaultChannel.id,
|
Feature - channels per plugin (#1093)
* Update schema
* Update queries, mutations, and types
* Add render with dividers util function
* Add plugin details channels card component
* Update plugin details to use channels
* Update stories
* Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match"
* Update schema
* Update types
* Update plugins list to show channels and global statuses, add plugin channel status, update status label component
* Add render with dividers util function
* Comment out some stuff for types to match - temporary
* Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more
* Change filters logic to be able to display multiple fields in a field section and add it to plugins view
* Add scroll option to plugin availability popup on plugin list
* Fix plugin list page story
* Temporarily comment some stuff out, fix some types
* Add filters errors WIP
* Fix filters not updating list
* Add error handling to plugins list filters and filters in general
* Rename some components according to review
* Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly
* Fix imports
* Move render collection with dividers to a component, fix usages
* Replace channels with load more and search query to base channels query
* Change render with dividers function to take in a component instead of render function
* Update tests
* Extract messages
* Remove unnecessary imports
* Fix filters - autocomplete messing items order sometimes & some fields not working
* Update plugin update mutation variables - change channelId to channel
* fix failing tests
* Add test ids
* fix failing tests
* fix failing tests
* Rename misc.tsx to ts
* Remove usage of render collection with diviers, change it to CollectionWithDividers component
* Remove unnecessary imports
* Update messages ids
* Update snapshots
Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
2021-05-11 13:58:09 +00:00
|
|
|
createdVariants,
|
|
|
|
addresses.plAddress
|
2021-02-15 09:44:50 +00:00
|
|
|
);
|
|
|
|
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.get("@todaysOrders").then(ordersBefore => {
|
|
|
|
const allOrders = ordersBefore + 1;
|
|
|
|
const notANumberRegex = "\\D*";
|
|
|
|
const ordersRegexp = new RegExp(
|
|
|
|
`${notANumberRegex}${allOrders}${notANumberRegex}`
|
|
|
|
);
|
2021-02-15 09:44:50 +00:00
|
|
|
cy.visit(urlList.homePage);
|
2021-03-12 12:14:18 +00:00
|
|
|
changeChannel(defaultChannel.name);
|
2021-02-17 11:22:24 +00:00
|
|
|
cy.contains(HOMEPAGE_SELECTORS.orders, ordersRegexp).should("be.visible");
|
2021-02-15 09:44:50 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|