diff --git a/cypress/fixtures/urlList.js b/cypress/fixtures/urlList.js index e76e97aea..a45d1e332 100644 --- a/cypress/fixtures/urlList.js +++ b/cypress/fixtures/urlList.js @@ -76,12 +76,6 @@ export const weightRateUrl = (shippingZoneId, weightRateId) => export const warehouseDetailsUrl = warehouseId => `${urlList.warehouses}${warehouseId}`; -export const productTypeDetailsUrl = productTypeId => - `${urlList.productTypes}${productTypeId}`; - -export const giftCardDetailsUrl = giftCardId => - `${urlList.giftCards}${giftCardId}`; - export const saleDetailsUrl = saleId => `${urlList.sales}${saleId}`; export const voucherDetailsUrl = voucherId => `${urlList.vouchers}${voucherId}`; diff --git a/cypress/integration/products/productsWithoutSku/productsWithoutSkuInOrder.js b/cypress/integration/products/productsWithoutSku/productsWithoutSkuInOrder.js new file mode 100644 index 000000000..2f6dd35cb --- /dev/null +++ b/cypress/integration/products/productsWithoutSku/productsWithoutSkuInOrder.js @@ -0,0 +1,64 @@ +/// +/// + +import { + createCustomer, + deleteCustomersStartsWith +} from "../../../support/api/requests/Customer"; +import { createReadyToFulfillOrder } from "../../../support/api/utils/ordersUtils"; +import { + createProductWithShipping, + deleteProductsStartsWith +} from "../../../support/api/utils/products/productsUtils"; +import { deleteShippingStartsWith } from "../../../support/api/utils/shippingUtils"; +import filterTests from "../../../support/filterTests"; + +filterTests({ definedTags: ["all", "critical"] }, () => { + const name = "ProductsWithoutSkuInOrder"; + + describe("Add productWithout SKU to order", () => { + before(() => { + cy.clearSessionData().loginUserViaRequest(); + deleteProductsStartsWith(name); + deleteShippingStartsWith(name); + deleteCustomersStartsWith(name); + }); + + it("should create order with variant product without sku", () => { + let variants; + let channel; + let shippingMethodId; + let address; + + cy.clearSessionData().loginUserViaRequest(); + createProductWithShipping({ name, sku: null }) + .then( + ({ + variantsList, + defaultChannel, + shippingMethod, + address: addressResp + }) => { + variants = variantsList; + channel = defaultChannel; + shippingMethodId = shippingMethod.id; + address = addressResp; + createCustomer(`${name}@example.com`, name, address, true); + } + ) + .then(customerResp => { + const customer = customerResp.body.data.customerCreate.user; + createReadyToFulfillOrder({ + address, + channelId: channel.id, + customerId: customer.id, + shippingMethodId, + variantsList: variants + }); + }) + .then(({ errors }) => { + expect(errors, "check if no errors").to.be.empty; + }); + }); + }); +}); diff --git a/cypress/support/api/requests/Order.js b/cypress/support/api/requests/Order.js index ea4c658cc..7f5db4c59 100644 --- a/cypress/support/api/requests/Order.js +++ b/cypress/support/api/requests/Order.js @@ -83,8 +83,9 @@ export function completeOrder(orderId) { id } } - orderErrors{ + errors{ message + field } } }`; diff --git a/cypress/support/api/requests/ProductType.js b/cypress/support/api/requests/ProductType.js index 6aa56216c..d6e85c604 100644 --- a/cypress/support/api/requests/ProductType.js +++ b/cypress/support/api/requests/ProductType.js @@ -43,23 +43,6 @@ export function createTypeProduct({ .its("body.data.productTypeCreate.productType"); } -export function productAttributeAssignmentUpdate({ - productTypeId, - attributeId, - variantSelection = true -}) { - const mutation = `mutation { - productAttributeAssignmentUpdate( - operations: {id: "${attributeId}", variantSelection: ${variantSelection}} productTypeId:"${productTypeId}") { - errors { - field - message - } - } - }`; - return cy.sendRequestWithQuery(mutation); -} - export function getProductTypes(first, search) { const query = `query{ productTypes(first:${first}, filter:{ diff --git a/cypress/support/api/utils/products/productsUtils.js b/cypress/support/api/utils/products/productsUtils.js index 5cf160a1a..28f689315 100644 --- a/cypress/support/api/utils/products/productsUtils.js +++ b/cypress/support/api/utils/products/productsUtils.js @@ -116,6 +116,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ name, description = name, warehouseId, + sku = name, productPrice = 10 }) { let defaultChannel; @@ -144,6 +145,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ collectionId: collection.id, description, warehouseId, + sku, price: productPrice }); }) @@ -152,6 +154,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ export function createProductWithShipping({ name, + sku = name, productPrice = 10, shippingPrice = 10 }) { @@ -188,6 +191,7 @@ export function createProductWithShipping({ deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({ name, warehouseId: warehouse.id, + sku, productPrice }); }