Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test should create simple product without sku SALEOR_2806 #2497

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import faker from "faker";

import { PRODUCT_DETAILS } from "../../../elements/catalog/products/product-details";
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
import { AVAILABLE_CHANNELS_FORM } from "../../../elements/channels/available-channels-form";
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 {
deleteChannelsStartsWith,
Expand All @@ -17,8 +17,8 @@ import {
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 { createVariant } from "../../../support/pages/catalog/products/VariantsPage";
import { enterVariantEditPage } from "../../../support/pages/catalog/products/productDetailsPage";
import { selectChannelsForVariant } from "../../../support/pages/catalog/products/VariantsPage";
import { selectChannelInDetailsPages } from "../../../support/pages/channelsPage";

describe("Creating variants", () => {
Expand Down Expand Up @@ -149,12 +149,13 @@ describe("Creating variants", () => {
cy.visit(urlList.products)
.get(PRODUCTS_LIST.createProductBtn)
.click()
.get(PRODUCT_DETAILS.productNameInput)
.type(name)
.fillAutocompleteSelect(
PRODUCT_DETAILS.productTypeInput,
PRODUCTS_LIST.dialogProductTypeInput,
simpleProductType.name,
)
);
cy.get(BUTTON_SELECTORS.submit).click();
cy.get(PRODUCT_DETAILS.productNameInput)
.type(name)
.fillAutocompleteSelect(PRODUCT_DETAILS.categoryInput);
selectChannelInDetailsPages(defaultChannel.name);
cy.get(PRODUCT_DETAILS.costPriceInput)
Expand All @@ -166,29 +167,28 @@ describe("Creating variants", () => {
.click()
.confirmationMessageShouldDisappear()
.wait("@VariantCreate")
.get(PRODUCT_DETAILS.addWarehouseButton)
.click();
cy.contains(PRODUCT_DETAILS.warehouseOption, warehouse.name)
.click()
.then(({ response }) => {
const variantId =
response.body.data.productVariantCreate.productVariant.id;

updateVariantWarehouse({ variantId, warehouseId: warehouse.id });
});
enterVariantEditPage();
cy.addAliasToGraphRequest("ProductVariantDetails");
selectChannelsForVariant();
cy.get(PRODUCT_DETAILS.stockInput)
.parents()
.contains(warehouse.name)
.get(PRODUCT_DETAILS.stockInput)
.clearAndType(10)
.get(AVAILABLE_CHANNELS_FORM.assignedChannels)
.click()
.get(
`${AVAILABLE_CHANNELS_FORM.availableForPurchaseRadioButtons}${AVAILABLE_CHANNELS_FORM.radioButtonsValueTrue}`,
)
.click()
.get(
`${AVAILABLE_CHANNELS_FORM.publishedRadioButtons}${AVAILABLE_CHANNELS_FORM.radioButtonsValueTrue}`,
)
.click()
.addAliasToGraphRequest("ProductDetails")
.get(BUTTON_SELECTORS.confirm)
.click()
.confirmationMessageShouldDisappear()
.wait("@ProductDetails")
.wait("@ProductVariantDetails")
.then(({ response }) => {
const variants = [response.body.data.product.variants[0]];
const variants = [
response.body.data.productVariant.product.variants[0],
];
createWaitingForCaptureOrder({
channelSlug: defaultChannel.slug,
email: "example@example.com",
Expand Down
19 changes: 19 additions & 0 deletions cypress/support/api/requests/Product.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,22 @@ export function updateVariantPrice({ variantId, channelId, price }) {
.sendRequestWithQuery(mutation)
.its("body.data.productVariantChannelListingUpdate");
}

export function updateVariantWarehouse({ variantId, warehouseId }) {
const mutation = `mutation{
productVariantStocksCreate(variantId: "${variantId}",
stocks:
{
quantity: 0,
warehouse: "${warehouseId}"
}
){
errors{
field
message
}
}
}
`;
return cy.sendRequestWithQuery(mutation);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Cypress.Commands.add("fillAutocompleteSelect", (selectSelector, option) => {
cy.wrap(detachedOption).should(det => {
Cypress.dom.isDetached(det);
});
cy.contains(BUTTON_SELECTORS.selectOption, option).click();
cy.contains(BUTTON_SELECTORS.selectOption, option)
.should("be.visible")
.click();
cy.wrap(option).as("option");
});
} else {
Expand Down