fix test for sales (#1214)

* fix test for sales

* fix assingElements function

* change name of the function

* add wait to channels in shipping

* add missing imports
This commit is contained in:
Karolina Rakoczy 2021-07-15 12:20:59 +03:00 committed by GitHub
parent bba8c75d31
commit 2412911a9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 103 additions and 85 deletions

View file

@ -14,8 +14,8 @@ import { CHANNELS_SELECTORS } from "../../../elements/channels/channels-selector
import { SELECT_CHANNELS_TO_ASSIGN } from "../../../elements/channels/select-channels-to-assign";
import { HEADER_SELECTORS } from "../../../elements/header/header-selectors";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import { createChannelByView } from "../../../steps/channelsSteps";
import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar";
import { urlList } from "../../../url/urlList";
import { deleteChannelsStartsWith } from "../../../utils/channelsUtils";
import { deleteShippingStartsWith } from "../../../utils/shippingUtils";
@ -70,7 +70,7 @@ describe("Channels", () => {
cy.addAliasToGraphRequest("InitialProductFilterAttributes");
cy.visit(urlList.products);
cy.wait("@InitialProductFilterAttributes");
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
waitForProgressBarToNotExist();
cy.get(PRODUCTS_LIST.emptyProductRow).should("not.exist");
cy.get(PRODUCTS_LIST.productsList)
.first()

View file

@ -10,6 +10,7 @@ import { PERMISSION_GROUP_DETAILS } from "../../../elements/permissionGroup/perm
import { PERMISSION_GROUP_LIST } from "../../../elements/permissionGroup/permissionGroupsList";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import { waitForProgressBarToNotExist } from "../../../steps/shared/progressBar.js";
import {
permissionGroupDetails,
staffMemberDetailsUrl,
@ -48,9 +49,8 @@ describe("Permissions groups", () => {
.get(PERMISSION_GROUP_DETAILS.assignMemberButton)
.should("be.visible")
.get(BUTTON_SELECTORS.back)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist");
.click();
waitForProgressBarToNotExist();
cy.contains(
PERMISSION_GROUP_LIST.permissionGroupRow,
permissionName

View file

@ -6,10 +6,10 @@ import {
getProductType
} from "../../../apiRequests/productType";
import { PRODUCT_TYPE_DETAILS } from "../../../elements/productTypes/productTypeDetails";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import { createProductType } from "../../../steps/productTypeSteps";
import { assignElements } from "../../../steps/shared/assignElements";
import { confirmationMessageShouldDisappear } from "../../../steps/shared/confirmationMessage";
import { visitAndWaitForProgressBarToDisappear } from "../../../steps/shared/progressBar";
import { productTypeDetailsUrl, urlList } from "../../../url/urlList";
import { deleteProductsStartsWith } from "../../../utils/products/productsUtils";
@ -62,9 +62,9 @@ describe("Tests for product types", () => {
createTypeProduct({ name })
.then(productType => {
cy.visit(productTypeDetailsUrl(productType.id))
.get(SHARED_ELEMENTS.progressBar)
.should("be.not.visible")
visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id)
)
.get(PRODUCT_TYPE_DETAILS.assignProductAttributeButton)
.click();
cy.addAliasToGraphRequest("AssignProductAttribute");
@ -83,9 +83,9 @@ describe("Tests for product types", () => {
createTypeProduct({ name, hasVariants: false })
.then(productType => {
cy.visit(productTypeDetailsUrl(productType.id))
.get(SHARED_ELEMENTS.progressBar)
.should("be.not.visible")
visitAndWaitForProgressBarToDisappear(
productTypeDetailsUrl(productType.id)
)
.get(PRODUCT_TYPE_DETAILS.hasVariantsButton)
.click()
.get(PRODUCT_TYPE_DETAILS.assignVariantAttributeButton)

View file

@ -11,6 +11,7 @@ import { BUTTON_SELECTORS } from "../../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import { SHIPPING_ZONE_DETAILS } from "../../../../elements/shipping/shipping-zone-details";
import { selectChannelInHeader } from "../../../../steps/channelsSteps";
import { waitForProgressBarToNotExist } from "../../../../steps/shared/progressBar";
import { getFormattedCurrencyAmount } from "../../../../support/format/formatCurrencyAmount";
import { urlList } from "../../../../url/urlList";
import * as channelsUtils from "../../../../utils/channelsUtils";
@ -84,9 +85,8 @@ describe("Channels in shippingMethod", () => {
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.shipping)
.visit(urlList.shippingMethods)
.get(SHARED_ELEMENTS.header)
.should("be.visible")
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist");
.should("be.visible");
waitForProgressBarToNotExist();
cy.addAliasToGraphRequest("ShippingZone");
cy.getTextFromElement(SHARED_ELEMENTS.table);
})

View file

@ -88,6 +88,11 @@ describe("Sales discounts", () => {
price: productPrice
})
.then(({ product: productResp }) => {
/* Uncomment after fixing SALEOR-3367 bug
cy.clearSessionData()
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
*/
cy.visit(urlList.sales);
cy.softExpectSkeletonIsVisible();
const product = productResp;
@ -122,6 +127,11 @@ describe("Sales discounts", () => {
price: productPrice
})
.then(({ product: productResp }) => {
/* Uncomment after fixing SALEOR-3367 bug
cy.clearSessionData()
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
*/
cy.visit(urlList.sales);
cy.softExpectSkeletonIsVisible();
const product = productResp;
@ -168,6 +178,11 @@ describe("Sales discounts", () => {
});
})
.then(() => {
/* Uncomment after fixing SALEOR-3367 bug
cy.clearSessionData()
.loginUserViaRequest("auth", ONE_PERMISSION_USERS.discount)
*/
cy.visit(urlList.sales);
cy.softExpectSkeletonIsVisible();
createSale({

View file

@ -23,6 +23,7 @@ describe("Vouchers discounts", () => {
const shippingPrice = 100;
let defaultChannel;
let createdChannel;
let productType;
let attribute;
let category;
@ -79,7 +80,13 @@ describe("Vouchers discounts", () => {
price: productPrice
});
})
.then(({ variantsList: variantsResp }) => (variants = variantsResp));
.then(({ variantsList: variantsResp }) => {
variants = variantsResp;
createChannel({ name });
})
.then(channel => {
createdChannel = channel;
});
});
it("should create percentage voucher", () => {
@ -124,20 +131,16 @@ describe("Vouchers discounts", () => {
.loginUserViaRequest()
.visit(urlList.vouchers);
cy.softExpectSkeletonIsVisible();
createChannel({ name: randomName })
.then(channel => {
createVoucher({
voucherCode: randomName,
voucherValue,
discountOption: discountOptions.PERCENTAGE,
channelName: channel.name
});
createCheckoutForCreatedVoucher(randomName);
})
.then(resp => {
const errorField = resp.checkoutErrors[0].field;
expect(errorField).to.be.eq("promoCode");
});
createVoucher({
voucherCode: randomName,
voucherValue,
discountOption: discountOptions.PERCENTAGE,
channelName: createdChannel.name
});
createCheckoutForCreatedVoucher(randomName).then(resp => {
const errorField = resp.checkoutErrors[0].field;
expect(errorField).to.be.eq("promoCode");
});
});
function createCheckoutForCreatedVoucher(voucherCode) {

View file

@ -3,15 +3,12 @@ import faker from "faker";
import { createCollection } from "../../../../apiRequests/Collections";
import { updateProduct } from "../../../../apiRequests/Product";
import { PRODUCTS_LIST } from "../../../../elements/catalog/products/products-list";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import {
checkFilterOption,
selectChannel,
selectFilterBy,
selectFilterOption,
selectProductsOutOfStock
} from "../../../../steps/catalog/products/productsListSteps";
import { selectChannelInHeader } from "../../../../steps/channelsSteps";
import { waitForProgressBarToNotExist } from "../../../../steps/shared/progressBar";
import { urlList } from "../../../../url/urlList";
import { getDefaultChannel } from "../../../../utils/channelsUtils";
import {
@ -92,7 +89,7 @@ describe("Filtering products", () => {
filterProductsBy.forEach(filterBy => {
it(`should filter products by ${filterBy}`, () => {
cy.softExpectSkeletonIsVisible();
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
waitForProgressBarToNotExist();
selectFilterOption(filterBy, name);
cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => {
expect(product).to.includes(name);
@ -113,7 +110,7 @@ describe("Filtering products", () => {
categoryId: category.id,
price
});
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
waitForProgressBarToNotExist();
selectChannel(channel.slug);
selectProductsOutOfStock();
cy.getTextFromElement(PRODUCTS_LIST.productsNames).then(product => {

View file

@ -1,10 +1,10 @@
import { PRODUCTS_LIST } from "../../../../elements/catalog/products/products-list";
import { BUTTON_SELECTORS } from "../../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import {
getDisplayedColumnArray,
isNumberOfProductsSameAsInSelectResultsOnPage
} from "../../../../steps/catalog/products/productsListSteps";
import { waitForProgressBarToNotExist } from "../../../../steps/shared/progressBar";
import { urlList } from "../../../../url/urlList";
describe("Products", () => {
@ -25,10 +25,8 @@ describe("Products", () => {
productsList => (firstPageProducts = productsList)
);
cy.addAliasToGraphRequest("ProductList");
cy.get(PRODUCTS_LIST.nextPageButton)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist");
cy.get(PRODUCTS_LIST.nextPageButton).click();
waitForProgressBarToNotExist();
cy.wait("@ProductList");
getDisplayedColumnArray("name").then(productList => {
expect(productList).to.not.equal(firstPageProducts);
@ -50,9 +48,8 @@ describe("Products", () => {
`${PRODUCTS_LIST.rowNumberOption}${BUTTON_SELECTORS.notSelectedOption}`
)
.first()
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist");
.click();
waitForProgressBarToNotExist();
isNumberOfProductsSameAsInSelectResultsOnPage().then(
isTheSame =>
expect(

View file

@ -1,5 +1,6 @@
import { PRODUCTS_LIST } from "../../../../elements/catalog/products/products-list";
import { SHARED_ELEMENTS } from "../../../../elements/shared/sharedElements";
import { waitForProgressBarToNotExist } from "../../../../steps/shared/progressBar";
import { urlList } from "../../../../url/urlList";
import { expectProductsSortedBy } from "../../../../utils/products/productsListUtils";
@ -14,15 +15,13 @@ describe("Sorting products", () => {
cy.get(SHARED_ELEMENTS.header).should("be.visible");
if (sortBy !== "name") {
cy.get(PRODUCTS_LIST.tableHeaders[sortBy]).click();
cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
waitForProgressBarToNotExist();
}
expectProductsSortedBy(sortBy);
cy.addAliasToGraphRequest("ProductList")
.get(PRODUCTS_LIST.tableHeaders[sortBy])
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist")
.wait("@ProductList");
.click();
waitForProgressBarToNotExist().wait("@ProductList");
expectProductsSortedBy(sortBy, false);
});
});

View file

@ -3,8 +3,8 @@ import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-deta
import { VARIANTS_SELECTORS } from "../../../elements/catalog/products/variants-selectors";
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../../../elements/shared/sharedElements";
import { selectChannelVariantInDetailsPage } from "../../channelsSteps";
import { waitForProgressBarToNotBeVisible } from "../../shared/progressBar";
import { fillUpPriceList } from "./priceList";
export function variantsShouldBeVisible({ name, price }) {
@ -32,8 +32,7 @@ export function createFirstVariant({ sku, warehouseId, price, attribute }) {
cy.addAliasToGraphRequest("ProductVariantBulkCreate");
cy.get(VARIANTS_SELECTORS.nextButton).click();
cy.wait("@ProductVariantBulkCreate");
cy.get(SHARED_ELEMENTS.progressBar)
.should("not.be.visible")
waitForProgressBarToNotBeVisible()
.get(AVAILABLE_CHANNELS_FORM.menageChannelsButton)
.should("be.visible");
}
@ -71,10 +70,8 @@ export function createVariant({
cy.addAliasToGraphRequest("ProductVariantChannelListingUpdate");
cy.get(VARIANTS_SELECTORS.saveButton).click();
cy.wait("@ProductVariantChannelListingUpdate");
cy.get(BUTTON_SELECTORS.back)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.be.visible")
cy.get(BUTTON_SELECTORS.back).click();
waitForProgressBarToNotBeVisible()
.get(AVAILABLE_CHANNELS_FORM.menageChannelsButton)
.should("be.visible");
}

View file

@ -1,9 +1,7 @@
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import {
getElementByDataTestId,
SHARED_ELEMENTS
} from "../../../elements/shared/sharedElements";
import { getElementByDataTestId } from "../../../elements/shared/sharedElements";
import { waitForProgressBarToNotExist } from "../../shared/progressBar";
export function isNumberOfProductsSameAsInSelectResultsOnPage() {
let numberOfResults;
@ -68,10 +66,8 @@ export function selectChannel(channelSlug) {
}
function submitFilters() {
cy.get(BUTTON_SELECTORS.submit)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.exist")
cy.get(BUTTON_SELECTORS.submit).click();
waitForProgressBarToNotExist()
.get(PRODUCTS_LIST.emptyProductRow)
.should("not.exist");
}

View file

@ -3,6 +3,8 @@ import { ASSIGN_ELEMENTS_SELECTORS } from "../../elements/shared/assign-elements
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { formatDate } from "../../support/format/formatDate";
import { selectChannelInDetailsPages } from "../channelsSteps";
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage";
import { waitForProgressBarToNotBeVisible } from "../shared/progressBar";
export const discountOptions = {
PERCENTAGE: SALES_SELECTORS.percentageOption,
@ -17,8 +19,8 @@ export function createSale({
}) {
const todaysDate = formatDate(new Date());
cy.get(SALES_SELECTORS.createSaleButton)
.click()
cy.get(SALES_SELECTORS.createSaleButton).click();
waitForProgressBarToNotBeVisible()
.get(SALES_SELECTORS.nameInput)
.type(saleName)
.get(discountOption)
@ -30,11 +32,13 @@ export function createSale({
.type(todaysDate);
cy.addAliasToGraphRequest("SaleCreate");
cy.get(SALES_SELECTORS.saveButton).click();
confirmationMessageShouldDisappear();
cy.wait("@SaleCreate");
}
export function assignProducts(productName) {
cy.get(SALES_SELECTORS.productsTab)
waitForProgressBarToNotBeVisible()
.get(SALES_SELECTORS.productsTab)
.click()
.get(SALES_SELECTORS.assignProducts)
.click()

View file

@ -1,6 +1,7 @@
import { VOUCHERS_SELECTORS } from "../../elements/discounts/vouchers";
import { BUTTON_SELECTORS } from "../../elements/shared/button-selectors";
import { selectChannelInDetailsPages } from "../channelsSteps";
import { confirmationMessageShouldDisappear } from "../shared/confirmationMessage";
export const discountOptions = {
PERCENTAGE: VOUCHERS_SELECTORS.percentageDiscountRadioButton,
@ -24,4 +25,5 @@ export function createVoucher({
cy.get(VOUCHERS_SELECTORS.discountValueInputs).type(voucherValue);
}
cy.get(BUTTON_SELECTORS.confirm).click();
confirmationMessageShouldDisappear();
}

View file

@ -1,13 +1,11 @@
import { PRODUCT_TYPE_DETAILS } from "../elements/productTypes/productTypeDetails";
import { PRODUCT_TYPES_LIST } from "../elements/productTypes/productTypesList";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
import { waitForProgressBarToNotBeVisible } from "./shared/progressBar";
export function createProductType(name, shippingWeight) {
cy.get(PRODUCT_TYPES_LIST.addProductTypeButton)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("be.not.visible")
cy.get(PRODUCT_TYPES_LIST.addProductTypeButton).click();
waitForProgressBarToNotBeVisible()
.get(PRODUCT_TYPE_DETAILS.nameInput)
.type(name);
if (shippingWeight) {

View file

@ -1,12 +1,11 @@
import { ASSIGN_ELEMENTS_SELECTORS } from "../../elements/shared/assign-elements-selectors";
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
import { waitForProgressBarToNotBeVisible } from "./progressBar";
export function assignElements(name, withLoader = true) {
cy.get(ASSIGN_ELEMENTS_SELECTORS.searchInput).type(name);
if (withLoader) {
cy.get(ASSIGN_ELEMENTS_SELECTORS.dialogContent)
.find(SHARED_ELEMENTS.progressBar)
.should("not.exist");
cy.get(ASSIGN_ELEMENTS_SELECTORS.dialogContent);
waitForProgressBarToNotBeVisible();
}
cy.contains(ASSIGN_ELEMENTS_SELECTORS.tableRow, name)
.find(ASSIGN_ELEMENTS_SELECTORS.checkbox)

View file

@ -0,0 +1,14 @@
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
export function visitAndWaitForProgressBarToDisappear(url) {
cy.visit(url);
return waitForProgressBarToNotBeVisible();
}
export function waitForProgressBarToNotBeVisible() {
return cy.get(SHARED_ELEMENTS.progressBar).should("be.not.visible");
}
export function waitForProgressBarToNotExist() {
return cy.get(SHARED_ELEMENTS.progressBar).should("not.exist");
}

View file

@ -4,6 +4,7 @@ import { SHIPPING_RATE_DETAILS } from "../elements/shipping/shipping-rate-detail
import { SHIPPING_ZONE_DETAILS } from "../elements/shipping/shipping-zone-details";
import { SHIPPING_ZONES_LIST } from "../elements/shipping/shipping-zones-list";
import { confirmationMessageShouldDisappear } from "./shared/confirmationMessage";
import { waitForProgressBarToNotBeVisible } from "./shared/progressBar";
import { fillBaseSelect } from "./shared/selects";
export function createShippingZone(
@ -88,11 +89,9 @@ export function enterAndFillUpShippingRate({
weightLimits,
deliveryTime
}) {
cy.get(rateOption)
.click()
.get(SHARED_ELEMENTS.progressBar)
.should("not.be.visible")
.get(SHARED_ELEMENTS.richTextEditor.empty)
cy.get(rateOption).click();
waitForProgressBarToNotBeVisible();
cy.get(SHARED_ELEMENTS.richTextEditor.empty)
.should("exist")
.get(SHIPPING_RATE_DETAILS.inputName)
.type(rateName);

View file

@ -1,9 +1,9 @@
import { SET_PASSWORD } from "../elements/account/setPassword";
import { BUTTON_SELECTORS } from "../elements/shared/button-selectors";
import { SHARED_ELEMENTS } from "../elements/shared/sharedElements";
import { INVITE_STAFF_MEMBER_FORM } from "../elements/staffMembers/inviteStaffMemberForm";
import { STAFF_MEMBER_DETAILS } from "../elements/staffMembers/staffMemberDetails";
import { userDetailsUrl } from "../url/urlList";
import { visitAndWaitForProgressBarToDisappear } from "./shared/progressBar";
import { fillAutocompleteSelect } from "./shared/selects";
export function fillUpSetPassword(password) {
@ -34,9 +34,7 @@ export function fillUpUserDetails(firstName, lastName, email) {
}
export function updateUserActiveFlag(userId) {
cy.visit(userDetailsUrl(userId))
.get(SHARED_ELEMENTS.progressBar)
.should("not.be.visible")
visitAndWaitForProgressBarToDisappear(userDetailsUrl(userId))
.get(STAFF_MEMBER_DETAILS.isActiveCheckBox)
.click()
.addAliasToGraphRequest("StaffMemberUpdate");