saleor-dashboard/cypress/steps/discounts/salesSteps.js
Karolina 588175df30
Saleor 1737 tests for shipping methods (#1013)
* remove classes in shipping & products utils

* remove classes

* add tests plans

* add const

* tests for shipping methods

* test for shipping

* test for shipping

* tests for shipping

* install eslint-plugin-chai-friendly

* update stories

* add missing imports
2021-04-02 13:01:38 +02:00

49 lines
1.5 KiB
JavaScript

import { ASSIGN_PRODUCTS_SELECTORS } from "../../elements/catalog/products/assign-products";
import { SALES_SELECTORS } from "../../elements/discounts/sales";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { formatDate } from "../../support/format/formatDate";
import { selectChannelInDetailsPages } from "../channelsSteps";
export const discountOptions = {
PERCENTAGE: SALES_SELECTORS.percentageOption,
FIXED: SALES_SELECTORS.fixedOption
};
export function createSale({
saleName,
channelName,
discountValue = 10,
discountOption = discountOptions.PERCENTAGE
}) {
const todaysDate = formatDate(new Date());
cy.get(SALES_SELECTORS.createSaleButton)
.click()
.get(SALES_SELECTORS.nameInput)
.type(saleName)
.get(discountOption)
.click();
selectChannelInDetailsPages(channelName);
cy.get(SALES_SELECTORS.discountValue)
.type(discountValue)
.get(SALES_SELECTORS.startDateInput)
.type(todaysDate);
cy.addAliasToGraphRequest("SaleCreate");
cy.get(SALES_SELECTORS.saveButton).click();
cy.wait("@SaleCreate");
}
export function assignProducts(productName) {
cy.get(SALES_SELECTORS.productsTab)
.click()
.get(SALES_SELECTORS.assignProducts)
.click()
.get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
.type(productName);
cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, productName)
.find(BUTTON_SELECTORS.checkbox)
.click();
cy.addAliasToGraphRequest("SaleCataloguesAdd");
cy.get(BUTTON_SELECTORS.submit).click();
cy.wait("@SaleCataloguesAdd");
}