Test for creating order with product without sku (#1559)

This commit is contained in:
Karolina Rakoczy 2021-11-22 16:34:21 +04:00 committed by GitHub
parent 2eb7193ce9
commit 56b48b87ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 24 deletions

View file

@ -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}`;

View file

@ -0,0 +1,64 @@
/// <reference types="cypress"/>
/// <reference types="../../../support"/>
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;
});
});
});
});

View file

@ -83,8 +83,9 @@ export function completeOrder(orderId) {
id
}
}
orderErrors{
errors{
message
field
}
}
}`;

View file

@ -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:{

View file

@ -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
});
}