fixed flaky draft order and products without sku tests (#3795)

This commit is contained in:
wojteknowacki 2023-06-23 14:51:59 +02:00 committed by GitHub
parent 6a2ee1f1d0
commit e69a62d9bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 58 deletions

View file

@ -3,17 +3,23 @@
import faker from "faker"; import faker from "faker";
import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors"; import {
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors"; BUTTON_SELECTORS,
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements"; DRAFT_ORDERS_LIST_SELECTORS,
ORDERS_SELECTORS,
SHARED_ELEMENTS,
} from "../../elements/";
import { urlList } from "../../fixtures/urlList"; import { urlList } from "../../fixtures/urlList";
import { createCustomer } from "../../support/api/requests/Customer"; import {
import { updateOrdersSettings } from "../../support/api/requests/Order"; createCustomer,
import { getDefaultChannel } from "../../support/api/utils/channelsUtils"; updateOrdersSettings,
} from "../../support/api/requests/";
import { createShipping, getDefaultChannel } from "../../support/api/utils/";
import * as productsUtils from "../../support/api/utils/products/productsUtils"; import * as productsUtils from "../../support/api/utils/products/productsUtils";
import { createShipping } from "../../support/api/utils/shippingUtils"; import {
import { selectChannelInPicker } from "../../support/pages/channelsPage"; finalizeDraftOrder,
import { finalizeDraftOrder } from "../../support/pages/draftOrderPage"; selectChannelInPicker,
} from "../../support/pages/";
describe("Draft orders", () => { describe("Draft orders", () => {
const startsWith = "CyDraftOrders-"; const startsWith = "CyDraftOrders-";
@ -82,6 +88,7 @@ describe("Draft orders", () => {
() => { () => {
let draftOrderNumber; let draftOrderNumber;
cy.addAliasToGraphRequest("OrderDraftFinalize"); cy.addAliasToGraphRequest("OrderDraftFinalize");
cy.addAliasToGraphRequest("OrderList");
cy.visit(urlList.orders); cy.visit(urlList.orders);
cy.get(ORDERS_SELECTORS.createOrderButton).click(); cy.get(ORDERS_SELECTORS.createOrderButton).click();
@ -97,8 +104,7 @@ describe("Draft orders", () => {
"contain.text", "contain.text",
draftOrderNumber, draftOrderNumber,
); );
cy.addAliasToGraphRequest("OrderList") cy.get(BUTTON_SELECTORS.back)
.get('[data-test-id="app-header-back-button"]')
.click() .click()
.waitForRequestAndCheckIfNoErrors("@OrderList"); .waitForRequestAndCheckIfNoErrors("@OrderList");
cy.visit(urlList.draftOrders).then(() => { cy.visit(urlList.draftOrders).then(() => {

View file

@ -3,31 +3,29 @@
import faker from "faker"; import faker from "faker";
import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
import { BUTTON_SELECTORS } from "../../../elements/shared/button-selectors";
import { urlList } from "../../../fixtures/urlList";
import { ONE_PERMISSION_USERS } from "../../../fixtures/users";
import { updateVariantWarehouse } from "../../../support/api/requests/Product";
import { createTypeProduct } from "../../../support/api/requests/ProductType";
import { createWaitingForCaptureOrder } from "../../../support/api/utils/ordersUtils";
import * as productUtils from "../../../support/api/utils/products/productsUtils";
import * as shippingUtils from "../../../support/api/utils/shippingUtils";
import { getProductVariants } from "../../../support/api/utils/storeFront/storeFrontProductUtils";
import { updateTaxConfigurationForChannel } from "../../../support/api/utils/taxesUtils";
import { import {
fillUpPriceList, BUTTON_SELECTORS,
priceInputLists, PRODUCT_DETAILS,
} from "../../../support/pages/catalog/products/priceListComponent"; PRODUCTS_LIST,
} from "../../../elements/";
import { ONE_PERMISSION_USERS, urlList } from "../../../fixtures/";
import { import {
enterVariantEditPage, productsRequests,
fillUpProductTypeDialog, productsTypeRequests,
} from "../../../support/pages/catalog/products/productDetailsPage"; } from "../../../support/api/requests/";
import { import {
createVariant, ordersUtils,
selectChannelsForVariant, productsUtils,
} from "../../../support/pages/catalog/products/VariantsPage"; shippingUtils,
import { selectChannelInDetailsPages } from "../../../support/pages/channelsPage"; storeFrontProductsUtils,
updateTaxConfigurationForChannel,
} from "../../../support/api/utils/";
import {
channelsPage,
priceListComponent,
productDetailsPage,
variantsPage,
} from "../../../support/pages";
describe("Creating variants", () => { describe("Creating variants", () => {
const startsWith = "CreateProdSku"; const startsWith = "CreateProdSku";
@ -65,7 +63,7 @@ describe("Creating variants", () => {
}); });
}); });
productUtils productsUtils
.createTypeAttributeAndCategoryForProduct({ name, attributeValues }) .createTypeAttributeAndCategoryForProduct({ name, attributeValues })
.then( .then(
({ ({
@ -76,7 +74,7 @@ describe("Creating variants", () => {
attribute = attributeResp; attribute = attributeResp;
productType = productTypeResp; productType = productTypeResp;
category = categoryResp; category = categoryResp;
createTypeProduct({ productsTypeRequests.createTypeProduct({
name: simpleProductTypeName, name: simpleProductTypeName,
attributeId: attribute.id, attributeId: attribute.id,
hasVariants: false, hasVariants: false,
@ -113,7 +111,7 @@ describe("Creating variants", () => {
const variants = [{ price: 7 }, { name: attributeValues[1], price: 16 }]; const variants = [{ price: 7 }, { name: attributeValues[1], price: 16 }];
let createdProduct; let createdProduct;
productUtils productsUtils
.createProductInChannel({ .createProductInChannel({
name, name,
attributeId: attribute.id, attributeId: attribute.id,
@ -126,11 +124,11 @@ describe("Creating variants", () => {
.then(({ product: productResp }) => { .then(({ product: productResp }) => {
createdProduct = productResp; createdProduct = productResp;
cy.visit(`${urlList.products}${createdProduct.id}`); cy.visit(`${urlList.products}${createdProduct.id}`);
enterVariantEditPage(); productDetailsPage.enterVariantEditPage();
cy.get(PRODUCT_DETAILS.addVariantButton) cy.get(PRODUCT_DETAILS.addVariantButton)
.click() .click()
.then(() => { .then(() => {
createVariant({ variantsPage.createVariant({
attributeName: variants[1].name, attributeName: variants[1].name,
price: variants[1].price, price: variants[1].price,
channelName: defaultChannel.name, channelName: defaultChannel.name,
@ -140,13 +138,16 @@ describe("Creating variants", () => {
}); });
}) })
.then(() => { .then(() => {
getProductVariants(createdProduct.id, defaultChannel.slug); storeFrontProductsUtils.getProductVariants(
createdProduct.id,
defaultChannel.slug,
);
}) })
.then(([firstVariant, secondVariant]) => { .then(([firstVariant, secondVariant]) => {
expect(secondVariant).to.have.property("price", variants[0].price); expect(secondVariant).to.have.property("price", variants[0].price);
expect(firstVariant).to.have.property("name", name); expect(firstVariant).to.have.property("name", name);
expect(firstVariant).to.have.property("price", variants[1].price); expect(firstVariant).to.have.property("price", variants[1].price);
createWaitingForCaptureOrder({ ordersUtils.createWaitingForCaptureOrder({
channelSlug: defaultChannel.slug, channelSlug: defaultChannel.slug,
email: "example@example.com", email: "example@example.com",
variantsList: [firstVariant], variantsList: [firstVariant],
@ -166,34 +167,39 @@ describe("Creating variants", () => {
() => { () => {
const name = `${startsWith}${faker.datatype.number()}`; const name = `${startsWith}${faker.datatype.number()}`;
const prices = { sellingPrice: 10, costPrice: 6 }; const prices = { sellingPrice: 10, costPrice: 6 };
cy.addAliasToGraphRequest("VariantUpdate");
cy.addAliasToGraphRequest("VariantCreate");
cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click(); cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click();
fillUpProductTypeDialog({ productType: simpleProductType.name }); productDetailsPage.fillUpProductTypeDialog({
productType: simpleProductType.name,
});
cy.get(BUTTON_SELECTORS.submit) cy.get(BUTTON_SELECTORS.submit)
.click() .click()
.get(PRODUCT_DETAILS.productNameInput) .get(PRODUCT_DETAILS.productNameInput)
.type(name) .type(name, { force: true })
.fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput); .fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput);
selectChannelInDetailsPages(defaultChannel.name); channelsPage.selectChannelInDetailsPages(defaultChannel.name);
fillUpPriceList(prices.sellingPrice); priceListComponent.fillUpPriceList(prices.sellingPrice);
fillUpPriceList(prices.costPrice, priceInputLists.costPrice); priceListComponent.fillUpPriceList(
cy.addAliasToGraphRequest("VariantCreate") prices.costPrice,
.get(BUTTON_SELECTORS.confirm) priceListComponent.priceInputLists.costPrice,
);
cy.get(BUTTON_SELECTORS.confirm)
.click() .click()
.confirmationMessageShouldDisappear() .confirmationMessageShouldDisappear()
.wait("@VariantCreate") .wait("@VariantCreate")
.then(({ response }) => { .then(({ response }) => {
const variantId = const variantId =
response.body.data.productVariantCreate.productVariant.id; response.body.data.productVariantCreate.productVariant.id;
updateVariantWarehouse({ productsRequests.updateVariantWarehouse({
variantId, variantId,
warehouseId: warehouse.id, warehouseId: warehouse.id,
quantity: 10, quantity: 10,
}); });
}); });
enterVariantEditPage(); productDetailsPage.enterVariantEditPage();
cy.addAliasToGraphRequest("VariantUpdate"); variantsPage.selectChannelsForVariant();
selectChannelsForVariant();
cy.get(BUTTON_SELECTORS.confirm) cy.get(BUTTON_SELECTORS.confirm)
.click() .click()
.confirmationMessageShouldDisappear() .confirmationMessageShouldDisappear()
@ -202,7 +208,8 @@ describe("Creating variants", () => {
const variants = [ const variants = [
response.body.data.productVariantUpdate.productVariant, response.body.data.productVariantUpdate.productVariant,
]; ];
createWaitingForCaptureOrder({ ordersUtils
.createWaitingForCaptureOrder({
channelSlug: defaultChannel.slug, channelSlug: defaultChannel.slug,
email: "example@example.com", email: "example@example.com",
variantsList: variants, variantsList: variants,

View file

@ -8,3 +8,5 @@ export {
deleteStaffMembersStartsWith, deleteStaffMembersStartsWith,
updateStaffMember, updateStaffMember,
} from "./StaffMembers"; } from "./StaffMembers";
export * as productsRequests from "./Product";
export * as productsTypeRequests from "./ProductType";

View file

@ -5,6 +5,9 @@ export {
updateTaxConfigurationForChannel, updateTaxConfigurationForChannel,
} from "./taxesUtils"; } from "./taxesUtils";
export * as productsUtils from "./products/productsUtils"; export * as productsUtils from "./products/productsUtils";
export * as ordersUtils from "./ordersUtils";
export * as shippingUtils from "./shippingUtils";
export * as storeFrontProductsUtils from "./storeFront/storeFrontProductUtils";
export { export {
createFulfilledOrder, createFulfilledOrder,

View file

@ -32,3 +32,8 @@ export {
expectMainMenuAvailableSections, expectMainMenuAvailableSections,
expectMainMenuSectionsToBeVisible, expectMainMenuSectionsToBeVisible,
} from "./mainMenuPage"; } from "./mainMenuPage";
export * as productListPage from "./catalog/products/productsListPage";
export * as productDetailsPage from "./catalog/products/productDetailsPage";
export * as priceListComponent from "./catalog/products/priceListComponent";
export * as variantsPage from "./catalog/products/VariantsPage";
export * as channelsPage from "./channelsPage";