fixed flaky draft order and products without sku tests (#3795)
This commit is contained in:
parent
6a2ee1f1d0
commit
e69a62d9bb
5 changed files with 81 additions and 58 deletions
|
@ -3,17 +3,23 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { DRAFT_ORDERS_LIST_SELECTORS } from "../../elements/orders/draft-orders-list-selectors";
|
||||
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
|
||||
import { SHARED_ELEMENTS } from "../../elements/shared/sharedElements";
|
||||
import {
|
||||
BUTTON_SELECTORS,
|
||||
DRAFT_ORDERS_LIST_SELECTORS,
|
||||
ORDERS_SELECTORS,
|
||||
SHARED_ELEMENTS,
|
||||
} from "../../elements/";
|
||||
import { urlList } from "../../fixtures/urlList";
|
||||
import { createCustomer } from "../../support/api/requests/Customer";
|
||||
import { updateOrdersSettings } from "../../support/api/requests/Order";
|
||||
import { getDefaultChannel } from "../../support/api/utils/channelsUtils";
|
||||
import {
|
||||
createCustomer,
|
||||
updateOrdersSettings,
|
||||
} from "../../support/api/requests/";
|
||||
import { createShipping, getDefaultChannel } from "../../support/api/utils/";
|
||||
import * as productsUtils from "../../support/api/utils/products/productsUtils";
|
||||
import { createShipping } from "../../support/api/utils/shippingUtils";
|
||||
import { selectChannelInPicker } from "../../support/pages/channelsPage";
|
||||
import { finalizeDraftOrder } from "../../support/pages/draftOrderPage";
|
||||
import {
|
||||
finalizeDraftOrder,
|
||||
selectChannelInPicker,
|
||||
} from "../../support/pages/";
|
||||
|
||||
describe("Draft orders", () => {
|
||||
const startsWith = "CyDraftOrders-";
|
||||
|
@ -82,6 +88,7 @@ describe("Draft orders", () => {
|
|||
() => {
|
||||
let draftOrderNumber;
|
||||
cy.addAliasToGraphRequest("OrderDraftFinalize");
|
||||
cy.addAliasToGraphRequest("OrderList");
|
||||
|
||||
cy.visit(urlList.orders);
|
||||
cy.get(ORDERS_SELECTORS.createOrderButton).click();
|
||||
|
@ -97,8 +104,7 @@ describe("Draft orders", () => {
|
|||
"contain.text",
|
||||
draftOrderNumber,
|
||||
);
|
||||
cy.addAliasToGraphRequest("OrderList")
|
||||
.get('[data-test-id="app-header-back-button"]')
|
||||
cy.get(BUTTON_SELECTORS.back)
|
||||
.click()
|
||||
.waitForRequestAndCheckIfNoErrors("@OrderList");
|
||||
cy.visit(urlList.draftOrders).then(() => {
|
||||
|
|
|
@ -3,31 +3,29 @@
|
|||
|
||||
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 {
|
||||
fillUpPriceList,
|
||||
priceInputLists,
|
||||
} from "../../../support/pages/catalog/products/priceListComponent";
|
||||
BUTTON_SELECTORS,
|
||||
PRODUCT_DETAILS,
|
||||
PRODUCTS_LIST,
|
||||
} from "../../../elements/";
|
||||
import { ONE_PERMISSION_USERS, urlList } from "../../../fixtures/";
|
||||
import {
|
||||
enterVariantEditPage,
|
||||
fillUpProductTypeDialog,
|
||||
} from "../../../support/pages/catalog/products/productDetailsPage";
|
||||
productsRequests,
|
||||
productsTypeRequests,
|
||||
} from "../../../support/api/requests/";
|
||||
import {
|
||||
createVariant,
|
||||
selectChannelsForVariant,
|
||||
} from "../../../support/pages/catalog/products/VariantsPage";
|
||||
import { selectChannelInDetailsPages } from "../../../support/pages/channelsPage";
|
||||
ordersUtils,
|
||||
productsUtils,
|
||||
shippingUtils,
|
||||
storeFrontProductsUtils,
|
||||
updateTaxConfigurationForChannel,
|
||||
} from "../../../support/api/utils/";
|
||||
import {
|
||||
channelsPage,
|
||||
priceListComponent,
|
||||
productDetailsPage,
|
||||
variantsPage,
|
||||
} from "../../../support/pages";
|
||||
|
||||
describe("Creating variants", () => {
|
||||
const startsWith = "CreateProdSku";
|
||||
|
@ -65,7 +63,7 @@ describe("Creating variants", () => {
|
|||
});
|
||||
});
|
||||
|
||||
productUtils
|
||||
productsUtils
|
||||
.createTypeAttributeAndCategoryForProduct({ name, attributeValues })
|
||||
.then(
|
||||
({
|
||||
|
@ -76,7 +74,7 @@ describe("Creating variants", () => {
|
|||
attribute = attributeResp;
|
||||
productType = productTypeResp;
|
||||
category = categoryResp;
|
||||
createTypeProduct({
|
||||
productsTypeRequests.createTypeProduct({
|
||||
name: simpleProductTypeName,
|
||||
attributeId: attribute.id,
|
||||
hasVariants: false,
|
||||
|
@ -113,7 +111,7 @@ describe("Creating variants", () => {
|
|||
const variants = [{ price: 7 }, { name: attributeValues[1], price: 16 }];
|
||||
let createdProduct;
|
||||
|
||||
productUtils
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name,
|
||||
attributeId: attribute.id,
|
||||
|
@ -126,11 +124,11 @@ describe("Creating variants", () => {
|
|||
.then(({ product: productResp }) => {
|
||||
createdProduct = productResp;
|
||||
cy.visit(`${urlList.products}${createdProduct.id}`);
|
||||
enterVariantEditPage();
|
||||
productDetailsPage.enterVariantEditPage();
|
||||
cy.get(PRODUCT_DETAILS.addVariantButton)
|
||||
.click()
|
||||
.then(() => {
|
||||
createVariant({
|
||||
variantsPage.createVariant({
|
||||
attributeName: variants[1].name,
|
||||
price: variants[1].price,
|
||||
channelName: defaultChannel.name,
|
||||
|
@ -140,13 +138,16 @@ describe("Creating variants", () => {
|
|||
});
|
||||
})
|
||||
.then(() => {
|
||||
getProductVariants(createdProduct.id, defaultChannel.slug);
|
||||
storeFrontProductsUtils.getProductVariants(
|
||||
createdProduct.id,
|
||||
defaultChannel.slug,
|
||||
);
|
||||
})
|
||||
.then(([firstVariant, secondVariant]) => {
|
||||
expect(secondVariant).to.have.property("price", variants[0].price);
|
||||
expect(firstVariant).to.have.property("name", name);
|
||||
expect(firstVariant).to.have.property("price", variants[1].price);
|
||||
createWaitingForCaptureOrder({
|
||||
ordersUtils.createWaitingForCaptureOrder({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
variantsList: [firstVariant],
|
||||
|
@ -166,34 +167,39 @@ describe("Creating variants", () => {
|
|||
() => {
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const prices = { sellingPrice: 10, costPrice: 6 };
|
||||
cy.addAliasToGraphRequest("VariantUpdate");
|
||||
cy.addAliasToGraphRequest("VariantCreate");
|
||||
|
||||
cy.visit(urlList.products).get(PRODUCTS_LIST.createProductBtn).click();
|
||||
fillUpProductTypeDialog({ productType: simpleProductType.name });
|
||||
productDetailsPage.fillUpProductTypeDialog({
|
||||
productType: simpleProductType.name,
|
||||
});
|
||||
cy.get(BUTTON_SELECTORS.submit)
|
||||
.click()
|
||||
.get(PRODUCT_DETAILS.productNameInput)
|
||||
.type(name)
|
||||
.type(name, { force: true })
|
||||
.fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput);
|
||||
selectChannelInDetailsPages(defaultChannel.name);
|
||||
fillUpPriceList(prices.sellingPrice);
|
||||
fillUpPriceList(prices.costPrice, priceInputLists.costPrice);
|
||||
cy.addAliasToGraphRequest("VariantCreate")
|
||||
.get(BUTTON_SELECTORS.confirm)
|
||||
channelsPage.selectChannelInDetailsPages(defaultChannel.name);
|
||||
priceListComponent.fillUpPriceList(prices.sellingPrice);
|
||||
priceListComponent.fillUpPriceList(
|
||||
prices.costPrice,
|
||||
priceListComponent.priceInputLists.costPrice,
|
||||
);
|
||||
cy.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.confirmationMessageShouldDisappear()
|
||||
.wait("@VariantCreate")
|
||||
.then(({ response }) => {
|
||||
const variantId =
|
||||
response.body.data.productVariantCreate.productVariant.id;
|
||||
updateVariantWarehouse({
|
||||
productsRequests.updateVariantWarehouse({
|
||||
variantId,
|
||||
warehouseId: warehouse.id,
|
||||
quantity: 10,
|
||||
});
|
||||
});
|
||||
enterVariantEditPage();
|
||||
cy.addAliasToGraphRequest("VariantUpdate");
|
||||
selectChannelsForVariant();
|
||||
productDetailsPage.enterVariantEditPage();
|
||||
variantsPage.selectChannelsForVariant();
|
||||
cy.get(BUTTON_SELECTORS.confirm)
|
||||
.click()
|
||||
.confirmationMessageShouldDisappear()
|
||||
|
@ -202,13 +208,14 @@ describe("Creating variants", () => {
|
|||
const variants = [
|
||||
response.body.data.productVariantUpdate.productVariant,
|
||||
];
|
||||
createWaitingForCaptureOrder({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
variantsList: variants,
|
||||
shippingMethodName: shippingMethod.name,
|
||||
address,
|
||||
})
|
||||
ordersUtils
|
||||
.createWaitingForCaptureOrder({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
variantsList: variants,
|
||||
shippingMethodName: shippingMethod.name,
|
||||
address,
|
||||
})
|
||||
.its("order.id")
|
||||
.should("be.ok");
|
||||
});
|
||||
|
|
|
@ -8,3 +8,5 @@ export {
|
|||
deleteStaffMembersStartsWith,
|
||||
updateStaffMember,
|
||||
} from "./StaffMembers";
|
||||
export * as productsRequests from "./Product";
|
||||
export * as productsTypeRequests from "./ProductType";
|
||||
|
|
|
@ -5,6 +5,9 @@ export {
|
|||
updateTaxConfigurationForChannel,
|
||||
} from "./taxesUtils";
|
||||
export * as productsUtils from "./products/productsUtils";
|
||||
export * as ordersUtils from "./ordersUtils";
|
||||
export * as shippingUtils from "./shippingUtils";
|
||||
export * as storeFrontProductsUtils from "./storeFront/storeFrontProductUtils";
|
||||
|
||||
export {
|
||||
createFulfilledOrder,
|
||||
|
|
|
@ -32,3 +32,8 @@ export {
|
|||
expectMainMenuAvailableSections,
|
||||
expectMainMenuSectionsToBeVisible,
|
||||
} 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";
|
||||
|
|
Loading…
Reference in a new issue