Test for creating order with product without sku (#1559)
This commit is contained in:
parent
2eb7193ce9
commit
56b48b87ea
5 changed files with 70 additions and 24 deletions
|
@ -76,12 +76,6 @@ export const weightRateUrl = (shippingZoneId, weightRateId) =>
|
||||||
export const warehouseDetailsUrl = warehouseId =>
|
export const warehouseDetailsUrl = warehouseId =>
|
||||||
`${urlList.warehouses}${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 saleDetailsUrl = saleId => `${urlList.sales}${saleId}`;
|
||||||
|
|
||||||
export const voucherDetailsUrl = voucherId => `${urlList.vouchers}${voucherId}`;
|
export const voucherDetailsUrl = voucherId => `${urlList.vouchers}${voucherId}`;
|
||||||
|
|
|
@ -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;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -83,8 +83,9 @@ export function completeOrder(orderId) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
orderErrors{
|
errors{
|
||||||
message
|
message
|
||||||
|
field
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
|
@ -43,23 +43,6 @@ export function createTypeProduct({
|
||||||
.its("body.data.productTypeCreate.productType");
|
.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) {
|
export function getProductTypes(first, search) {
|
||||||
const query = `query{
|
const query = `query{
|
||||||
productTypes(first:${first}, filter:{
|
productTypes(first:${first}, filter:{
|
||||||
|
|
|
@ -116,6 +116,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({
|
||||||
name,
|
name,
|
||||||
description = name,
|
description = name,
|
||||||
warehouseId,
|
warehouseId,
|
||||||
|
sku = name,
|
||||||
productPrice = 10
|
productPrice = 10
|
||||||
}) {
|
}) {
|
||||||
let defaultChannel;
|
let defaultChannel;
|
||||||
|
@ -144,6 +145,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
description,
|
description,
|
||||||
warehouseId,
|
warehouseId,
|
||||||
|
sku,
|
||||||
price: productPrice
|
price: productPrice
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -152,6 +154,7 @@ export function deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({
|
||||||
|
|
||||||
export function createProductWithShipping({
|
export function createProductWithShipping({
|
||||||
name,
|
name,
|
||||||
|
sku = name,
|
||||||
productPrice = 10,
|
productPrice = 10,
|
||||||
shippingPrice = 10
|
shippingPrice = 10
|
||||||
}) {
|
}) {
|
||||||
|
@ -188,6 +191,7 @@ export function createProductWithShipping({
|
||||||
deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({
|
deleteProductsAndCreateNewOneWithNewDataAndDefaultChannel({
|
||||||
name,
|
name,
|
||||||
warehouseId: warehouse.id,
|
warehouseId: warehouse.id,
|
||||||
|
sku,
|
||||||
productPrice
|
productPrice
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue