Saleor 2960 checkout products without shipment (#1075)
* add tests for puchase by type * add expect for isShippingRequired
This commit is contained in:
parent
d220914085
commit
074c0f7a6c
31 changed files with 537 additions and 235 deletions
|
@ -18,7 +18,9 @@ export function createAttribute(name, attributeValues = ["value"]) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.attributeCreate.attribute");
|
||||
}
|
||||
|
||||
export function getAttributes(first, search) {
|
||||
|
|
|
@ -11,7 +11,9 @@ export function createCategory(name, slug = name) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.categoryCreate.category");
|
||||
}
|
||||
export function getCategories(first, search) {
|
||||
const mutation = `query{
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export function createChannel(isActive, name, slug, currencyCode) {
|
||||
export function createChannel({
|
||||
isActive = true,
|
||||
name,
|
||||
slug = name,
|
||||
currencyCode = "PLN"
|
||||
}) {
|
||||
const createChannelMutation = `mutation{
|
||||
channelCreate(input: {
|
||||
isActive: ${isActive}
|
||||
|
@ -17,7 +22,9 @@ export function createChannel(isActive, name, slug, currencyCode) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(createChannelMutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(createChannelMutation)
|
||||
.its("body.data.channelCreate.channel");
|
||||
}
|
||||
export function getChannels() {
|
||||
const getChannelsInfoQuery = `query{
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import { getDefaultAddress } from "./utils/Utils";
|
||||
import { getDefaultAddress, getVariantsLines } from "./utils/Utils";
|
||||
|
||||
export function createCheckout({
|
||||
channelSlug,
|
||||
email,
|
||||
productQuantity = 1,
|
||||
variantsList,
|
||||
address,
|
||||
billingAddress,
|
||||
auth = "auth"
|
||||
}) {
|
||||
const lines = variantsList.map(
|
||||
variant => `{quantity:${productQuantity}
|
||||
variantId:"${variant.id}"}`
|
||||
);
|
||||
const lines = getVariantsLines(variantsList, productQuantity);
|
||||
const shippingAddress = getDefaultAddress(address, "shippingAddress");
|
||||
const billingAddressLines = getDefaultAddress(
|
||||
billingAddress,
|
||||
"billingAddress"
|
||||
);
|
||||
|
||||
const mutation = `mutation{
|
||||
checkoutCreate(input:{
|
||||
|
@ -19,6 +22,7 @@ export function createCheckout({
|
|||
email:"${email}"
|
||||
lines: [${lines.join()}]
|
||||
${shippingAddress}
|
||||
${billingAddressLines}
|
||||
}){
|
||||
checkoutErrors{
|
||||
field
|
||||
|
@ -33,7 +37,9 @@ export function createCheckout({
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation, auth);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation, auth)
|
||||
.its("body.data.checkoutCreate.checkout");
|
||||
}
|
||||
export function addShippingMethod(checkoutId, shippingMethodId) {
|
||||
const mutation = `mutation{
|
||||
|
@ -47,6 +53,7 @@ export function addShippingMethod(checkoutId, shippingMethodId) {
|
|||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function addPayment(checkoutId, gateway, token) {
|
||||
const mutation = `mutation{
|
||||
checkoutPaymentCreate(checkoutId:"${checkoutId}",
|
||||
|
@ -60,8 +67,11 @@ export function addPayment(checkoutId, gateway, token) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.checkoutPaymentCreate");
|
||||
}
|
||||
|
||||
export function completeCheckout(checkoutId) {
|
||||
const mutation = `mutation{
|
||||
checkoutComplete(checkoutId:"${checkoutId}"){
|
||||
|
@ -76,7 +86,9 @@ export function completeCheckout(checkoutId) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.checkoutComplete.order");
|
||||
}
|
||||
|
||||
export function addVoucher(checkoutId, voucherCode) {
|
||||
|
@ -99,3 +111,46 @@ export function addVoucher(checkoutId, voucherCode) {
|
|||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function checkoutVariantsUpdate(checkoutId, variantsList) {
|
||||
const lines = getVariantsLines(variantsList, 1);
|
||||
const mutation = `mutation{
|
||||
checkoutLinesUpdate(checkoutId:"${checkoutId}",
|
||||
lines: [${lines.join()}]){
|
||||
checkoutErrors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
||||
export function checkoutShippingMethodUpdate(checkoutId, shippingMethodId) {
|
||||
const mutation = `mutation{
|
||||
checkoutShippingMethodUpdate(checkoutId:"${checkoutId}" shippingMethodId:"${shippingMethodId}"){
|
||||
checkoutErrors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.checkoutShippingMethodUpdate");
|
||||
}
|
||||
|
||||
export function checkoutShippingAddressUpdate(checkoutId, address) {
|
||||
const shippingAddress = getDefaultAddress(address, "shippingAddress");
|
||||
const mutation = `mutation{
|
||||
checkoutShippingAddressUpdate(checkoutId:"${checkoutId}",
|
||||
${shippingAddress}
|
||||
){
|
||||
checkoutErrors{
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@ export function createDraftOrder(customerId, shippingMethodId, channelId) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.draftOrderCreate.order");
|
||||
}
|
||||
export function completeOrder(orderId) {
|
||||
const mutation = `mutation{
|
||||
|
@ -54,3 +56,15 @@ export function completeOrder(orderId) {
|
|||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
export function getOrder(orderId) {
|
||||
const query = `query getOrder{
|
||||
order(id:"${orderId}"){
|
||||
status
|
||||
isShippingRequired
|
||||
shippingMethod{
|
||||
id
|
||||
}
|
||||
}
|
||||
}`;
|
||||
cy.sendRequestWithQuery(query).its("body.data.order");
|
||||
}
|
||||
|
|
|
@ -36,7 +36,9 @@ export function updateProduct(productId, input) {
|
|||
}
|
||||
}
|
||||
`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.productUpdate.product");
|
||||
}
|
||||
|
||||
export function updateChannelInProduct({
|
||||
|
@ -83,14 +85,14 @@ export function updateChannelPriceInVariant(variantId, channelId) {
|
|||
} `;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
}
|
||||
export function createProduct(
|
||||
export function createProduct({
|
||||
attributeId,
|
||||
name,
|
||||
productType,
|
||||
category,
|
||||
productTypeId,
|
||||
categoryId,
|
||||
collectionId,
|
||||
description
|
||||
) {
|
||||
}) {
|
||||
const collection = getValueWithDefault(
|
||||
collectionId,
|
||||
`collections:["${collectionId}"]`
|
||||
|
@ -107,8 +109,8 @@ export function createProduct(
|
|||
name:"${name}"
|
||||
slug:"${name}"
|
||||
seo:{title:"${name}" description:""}
|
||||
productType:"${productType}"
|
||||
category:"${category}"
|
||||
productType:"${productTypeId}"
|
||||
category:"${categoryId}"
|
||||
${collection}
|
||||
${descriptionLine}
|
||||
}){
|
||||
|
@ -122,14 +124,16 @@ export function createProduct(
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.productCreate.product");
|
||||
}
|
||||
|
||||
export function createVariant({
|
||||
productId,
|
||||
sku,
|
||||
warehouseId,
|
||||
quantity,
|
||||
quantityInWarehouse,
|
||||
channelId,
|
||||
attributeId,
|
||||
price = 1,
|
||||
|
@ -148,7 +152,7 @@ export function createVariant({
|
|||
warehouseId,
|
||||
`stocks:{
|
||||
warehouse:"${warehouseId}"
|
||||
quantity:${quantity}
|
||||
quantity:${quantityInWarehouse}
|
||||
}`
|
||||
);
|
||||
|
||||
|
@ -172,23 +176,26 @@ export function createVariant({
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.productVariantBulkCreate.productVariants");
|
||||
}
|
||||
|
||||
export function createTypeProduct(
|
||||
export function createTypeProduct({
|
||||
name,
|
||||
attributeId,
|
||||
hasVariants = true,
|
||||
slug = name
|
||||
) {
|
||||
slug = name,
|
||||
shippable = true
|
||||
}) {
|
||||
const mutation = `mutation{
|
||||
productTypeCreate(input: {
|
||||
name: "${name}"
|
||||
slug: "${slug}"
|
||||
isShippingRequired: true
|
||||
productAttributes: "${attributeId}"
|
||||
variantAttributes: "${attributeId}"
|
||||
hasVariants: ${hasVariants}
|
||||
isShippingRequired:${shippable}
|
||||
}){
|
||||
productErrors{
|
||||
field
|
||||
|
@ -200,7 +207,9 @@ export function createTypeProduct(
|
|||
}
|
||||
}
|
||||
} `;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.productTypeCreate.productType");
|
||||
}
|
||||
|
||||
export function deleteProduct(productId) {
|
||||
|
|
|
@ -26,7 +26,9 @@ export function createShippingZone(name, country, channelId) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.shippingZoneCreate.shippingZone");
|
||||
}
|
||||
export function addChannelToShippingZone(shippingZoneId, channelId) {
|
||||
const mutation = `mutation addCh{
|
||||
|
|
|
@ -22,7 +22,9 @@ export function createWarehouse({ name, shippingZone, address, slug = name }) {
|
|||
}
|
||||
}
|
||||
}`;
|
||||
return cy.sendRequestWithQuery(mutation);
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation)
|
||||
.its("body.data.createWarehouse.warehouse");
|
||||
}
|
||||
export function getWarehouses(first, search) {
|
||||
const query = `query{
|
||||
|
|
|
@ -19,3 +19,9 @@ export function getDefaultAddress(address, addressType, withName = true) {
|
|||
}
|
||||
return `${addressType}:{${defaultAddress}}`;
|
||||
}
|
||||
export function getVariantsLines(variantsList, quantity) {
|
||||
return variantsList.map(
|
||||
variant => `{quantity:${quantity}
|
||||
variantId:"${variant.id}"}`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ export const PRODUCT_DETAILS = {
|
|||
descriptionInput: "[data-test-id='description']",
|
||||
ratingInput: "[name='rating']",
|
||||
skuInput: "[name='sku']",
|
||||
variantRow: "[data-test-id='product-variant-row']",
|
||||
variantPrice: '[data-test="price"]',
|
||||
collectionRemoveButtons: '[data-test-id="collectionRemove"]',
|
||||
variantRow: "[data-test-id='product-variant-row']"
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@ export const BUTTON_SELECTORS = {
|
|||
confirm: '[data-test="button-bar-confirm"]',
|
||||
goBackButton: "[data-test-id='app-header-back-button']",
|
||||
checkbox: "[type='checkbox']",
|
||||
checked: "[class*='checked']",
|
||||
selectOption: "[data-test*='select-option']",
|
||||
notSelectedOption: ":not([aria-selected])",
|
||||
deleteButton: '[data-test="button-bar-delete"]',
|
||||
|
|
|
@ -10,5 +10,17 @@
|
|||
"phone": "123456787",
|
||||
"currency": "PLN",
|
||||
"countryFullName": "Poland"
|
||||
}
|
||||
},
|
||||
"usAddress": {
|
||||
"companyName": "Test3",
|
||||
"streetAddress1": "Amber Prairie",
|
||||
"streetAddress2": "483",
|
||||
"city": "KIRKSHIRE",
|
||||
"postalCode": "52216",
|
||||
"country": "US",
|
||||
"countryArea": "IA",
|
||||
"currency": "USD",
|
||||
"phone": "+12025550180",
|
||||
"countryFullName": "United States of America"
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
// <reference types="cypress" />
|
||||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../apiRequests/Channels";
|
||||
import { updateChannelInProduct } from "../apiRequests/Product";
|
||||
import { getCollection } from "../apiRequests/storeFront/Collections";
|
||||
import { searchInShop } from "../apiRequests/storeFront/Search";
|
||||
|
@ -108,8 +109,7 @@ describe("Collections", () => {
|
|||
let collection;
|
||||
let channel;
|
||||
|
||||
channelsUtils
|
||||
.createChannel({ name: collectionName })
|
||||
createChannel({ name: collectionName })
|
||||
.then(channelResp => {
|
||||
channel = channelResp;
|
||||
updateChannelInProduct(product.id, channel.id);
|
||||
|
|
|
@ -83,7 +83,12 @@ describe("Channels", () => {
|
|||
|
||||
it("should validate slug name", () => {
|
||||
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
||||
createChannel(false, randomChannel, randomChannel, currency);
|
||||
createChannel({
|
||||
isActive: false,
|
||||
name: randomChannel,
|
||||
slug: randomChannel,
|
||||
currencyCode: currency
|
||||
});
|
||||
cy.visit(urlList.channels);
|
||||
createChannelByView(randomChannel, currency);
|
||||
cy.get(ADD_CHANNEL_FORM_SELECTORS.slugValidationMessage).should(
|
||||
|
@ -102,12 +107,12 @@ describe("Channels", () => {
|
|||
|
||||
it("should delete channel", () => {
|
||||
const randomChannelToDelete = `${channelStartsWith} ${faker.datatype.number()}`;
|
||||
createChannel(
|
||||
false,
|
||||
randomChannelToDelete,
|
||||
randomChannelToDelete,
|
||||
currency
|
||||
);
|
||||
createChannel({
|
||||
isActive: false,
|
||||
name: randomChannelToDelete,
|
||||
slug: randomChannelToDelete,
|
||||
currencyCode: currency
|
||||
});
|
||||
cy.addAliasToGraphRequest("Channels");
|
||||
cy.visit(urlList.channels);
|
||||
cy.wait("@Channels");
|
||||
|
@ -126,7 +131,12 @@ describe("Channels", () => {
|
|||
|
||||
it("should not be possible to add products to order with inactive channel", () => {
|
||||
const randomChannel = `${channelStartsWith} ${faker.datatype.number()}`;
|
||||
createChannel(false, randomChannel, randomChannel, currency);
|
||||
createChannel({
|
||||
isActive: false,
|
||||
name: randomChannel,
|
||||
slug: randomChannel,
|
||||
currencyCode: currency
|
||||
});
|
||||
cy.visit(urlList.orders)
|
||||
.get(ORDERS_SELECTORS.createOrder)
|
||||
.click()
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createAttribute } from "../../../apiRequests/Attribute";
|
||||
import { createCategory } from "../../../apiRequests/Category";
|
||||
import {
|
||||
checkoutShippingAddressUpdate,
|
||||
checkoutShippingMethodUpdate,
|
||||
checkoutVariantsUpdate,
|
||||
completeCheckout,
|
||||
createCheckout
|
||||
} from "../../../apiRequests/Checkout";
|
||||
import { getOrder } from "../../../apiRequests/Order";
|
||||
import { createTypeProduct } from "../../../apiRequests/Product";
|
||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
||||
import {
|
||||
addPayment,
|
||||
createAndCompleteCheckoutWithoutShipping,
|
||||
createWaitingForCaptureOrder
|
||||
} from "../../../utils/ordersUtils";
|
||||
import {
|
||||
createProductInChannel,
|
||||
deleteProductsStartsWith
|
||||
} from "../../../utils/products/productsUtils";
|
||||
import {
|
||||
createShipping,
|
||||
deleteShippingStartsWith
|
||||
} from "../../../utils/shippingUtils";
|
||||
|
||||
describe("Purchase products with all products types", () => {
|
||||
const startsWith = `CyPurchaseByType`;
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
const email = `${startsWith}@example.com`;
|
||||
const testsMessage = "Check order status";
|
||||
const { softExpect } = chai;
|
||||
|
||||
let defaultChannel;
|
||||
let address;
|
||||
let warehouse;
|
||||
let attribute;
|
||||
let category;
|
||||
let shippingMethod;
|
||||
let createProductData;
|
||||
|
||||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteProductsStartsWith(startsWith);
|
||||
deleteShippingStartsWith(startsWith);
|
||||
getDefaultChannel().then(channelResp => (defaultChannel = channelResp));
|
||||
cy.fixture("addresses")
|
||||
.then(addresses => {
|
||||
address = addresses.usAddress;
|
||||
createShipping({
|
||||
channelId: defaultChannel.id,
|
||||
name,
|
||||
address,
|
||||
price: 10
|
||||
});
|
||||
})
|
||||
.then(
|
||||
({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
|
||||
warehouse = warehouseResp;
|
||||
shippingMethod = shippingMethodResp;
|
||||
}
|
||||
);
|
||||
createAttribute(name)
|
||||
.then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
createCategory(name);
|
||||
})
|
||||
.then(categoryResp => {
|
||||
category = categoryResp;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
createProductData = {
|
||||
channelId: defaultChannel.id,
|
||||
warehouseId: warehouse.id,
|
||||
quantityInWarehouse: 10,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
price: 10
|
||||
};
|
||||
});
|
||||
|
||||
it("should purchase digital product", () => {
|
||||
const digitalName = `${startsWith}${faker.datatype.number()}`;
|
||||
createTypeProduct({
|
||||
name: digitalName,
|
||||
attributeId: attribute.id,
|
||||
shippable: false
|
||||
})
|
||||
.then(productType => {
|
||||
createProductData.name = digitalName;
|
||||
createProductData.productTypeId = productType.id;
|
||||
createProductInChannel(createProductData);
|
||||
})
|
||||
.then(({ variantsList }) => {
|
||||
createAndCompleteCheckoutWithoutShipping({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email,
|
||||
billingAddress: address,
|
||||
variantsList,
|
||||
auth: "token"
|
||||
});
|
||||
})
|
||||
.then(({ order }) => {
|
||||
getOrder(order.id);
|
||||
})
|
||||
.then(order => {
|
||||
softExpect(
|
||||
order.isShippingRequired,
|
||||
"Check if is shipping required in order"
|
||||
).to.eq(false);
|
||||
expect(order.status, testsMessage).to.be.eq("UNFULFILLED");
|
||||
});
|
||||
});
|
||||
|
||||
it("should purchase physical product", () => {
|
||||
const physicalName = `${startsWith}${faker.datatype.number()}`;
|
||||
createTypeProduct({
|
||||
name: physicalName,
|
||||
attributeId: attribute.id,
|
||||
shippable: true
|
||||
})
|
||||
.then(productType => {
|
||||
createProductData.name = physicalName;
|
||||
createProductData.productTypeId = productType.id;
|
||||
createProductInChannel(createProductData);
|
||||
})
|
||||
.then(({ variantsList }) => {
|
||||
createWaitingForCaptureOrder(
|
||||
defaultChannel.slug,
|
||||
email,
|
||||
variantsList,
|
||||
shippingMethod.id,
|
||||
address
|
||||
);
|
||||
})
|
||||
.then(({ order }) => {
|
||||
getOrder(order.id);
|
||||
})
|
||||
.then(order => {
|
||||
softExpect(
|
||||
order.isShippingRequired,
|
||||
"Check if is shipping required in order"
|
||||
).to.eq(true);
|
||||
expect(order.status, testsMessage).to.be.eq("UNFULFILLED");
|
||||
});
|
||||
});
|
||||
it("should purchase multiple products with all product types", () => {
|
||||
const physicalName = `${startsWith}${faker.datatype.number()}`;
|
||||
const digitalName = `${startsWith}${faker.datatype.number()}`;
|
||||
let digitalProductVariantsList;
|
||||
let checkout;
|
||||
createTypeProduct({
|
||||
name: digitalName,
|
||||
attributeId: attribute.id,
|
||||
shippable: false
|
||||
})
|
||||
.then(productType => {
|
||||
createProductData.name = digitalName;
|
||||
createProductData.productTypeId = productType.id;
|
||||
createProductInChannel(createProductData);
|
||||
})
|
||||
.then(({ variantsList }) => {
|
||||
digitalProductVariantsList = variantsList;
|
||||
createCheckout({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email,
|
||||
variantsList: digitalProductVariantsList,
|
||||
billingAddress: address,
|
||||
auth: "token"
|
||||
});
|
||||
})
|
||||
.then(checkoutResp => {
|
||||
checkout = checkoutResp;
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
.then(() => {
|
||||
createTypeProduct({
|
||||
name: physicalName,
|
||||
attributeId: attribute.id,
|
||||
shippable: true
|
||||
});
|
||||
})
|
||||
.then(productType => {
|
||||
createProductData.name = physicalName;
|
||||
createProductData.productTypeId = productType.id;
|
||||
createProductInChannel(createProductData);
|
||||
})
|
||||
.then(({ variantsList }) => {
|
||||
checkoutVariantsUpdate(checkout.id, variantsList);
|
||||
})
|
||||
.then(() => {
|
||||
checkoutShippingMethodUpdate(checkout.id, shippingMethod.id);
|
||||
})
|
||||
.then(({ checkoutErrors }) => {
|
||||
expect(
|
||||
checkoutErrors,
|
||||
"Should be not possible to add shipping method without shipping address"
|
||||
).to.have.lengthOf(1);
|
||||
checkoutShippingAddressUpdate(checkout.id, address);
|
||||
})
|
||||
.then(() => {
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
.then(({ paymentErrors }) => {
|
||||
expect(
|
||||
paymentErrors,
|
||||
"Should be not possible to add payment without shipping"
|
||||
).to.have.lengthOf(1);
|
||||
checkoutShippingMethodUpdate(checkout.id, shippingMethod.id);
|
||||
})
|
||||
.then(() => {
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
.then(() => {
|
||||
completeCheckout(checkout.id);
|
||||
})
|
||||
.then(order => {
|
||||
getOrder(order.id);
|
||||
})
|
||||
.then(order => {
|
||||
softExpect(
|
||||
order.isShippingRequired,
|
||||
"Check if is shipping required in order"
|
||||
).to.eq(true);
|
||||
expect(order.status, testsMessage).to.be.eq("UNFULFILLED");
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,10 +1,13 @@
|
|||
// <reference types="cypress" />
|
||||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../apiRequests/Channels";
|
||||
import { createCheckout } from "../../apiRequests/Checkout";
|
||||
import {
|
||||
addChannelToShippingMethod,
|
||||
addChannelToShippingZone
|
||||
} from "../../apiRequests/ShippingMethod";
|
||||
import { createWarehouse } from "../../apiRequests/Warehouse";
|
||||
import { SHIPPING_ZONE_DETAILS } from "../../elements/shipping/shipping-zone-details";
|
||||
import { selectChannelInHeader } from "../../steps/channelsSteps";
|
||||
import {
|
||||
|
@ -15,7 +18,6 @@ import {
|
|||
import { getFormattedCurrencyAmount } from "../../support/format/formatCurrencyAmount";
|
||||
import { urlList } from "../../url/urlList";
|
||||
import * as channelsUtils from "../../utils/channelsUtils";
|
||||
import { createCheckout } from "../../utils/ordersUtils";
|
||||
import * as productsUtils from "../../utils/products/productsUtils";
|
||||
import * as shippingUtils from "../../utils/shippingUtils";
|
||||
import { isShippingAvailableInCheckout } from "../../utils/storeFront/checkoutUtils";
|
||||
|
@ -43,7 +45,7 @@ describe("Shipping methods", () => {
|
|||
})
|
||||
.then(addresses => {
|
||||
plAddress = addresses.plAddress;
|
||||
shippingUtils.createWarehouse({ name, address: plAddress });
|
||||
createWarehouse({ name, address: plAddress });
|
||||
})
|
||||
.then(warehouseResp => {
|
||||
warehouse = warehouseResp;
|
||||
|
@ -66,7 +68,7 @@ describe("Shipping methods", () => {
|
|||
});
|
||||
}
|
||||
)
|
||||
.then(({ variants: variantsListResp }) => {
|
||||
.then(({ variantsList: variantsListResp }) => {
|
||||
variantsList = variantsListResp;
|
||||
});
|
||||
});
|
||||
|
@ -86,11 +88,10 @@ describe("Shipping methods", () => {
|
|||
let shippingZone;
|
||||
let createdChannel;
|
||||
|
||||
channelsUtils
|
||||
.createChannel({
|
||||
name: shippingName,
|
||||
currencyCode: createdChannelCurrency
|
||||
})
|
||||
createChannel({
|
||||
name: shippingName,
|
||||
currencyCode: createdChannelCurrency
|
||||
})
|
||||
.then(channel => {
|
||||
createdChannel = channel;
|
||||
shippingUtils.createShipping({
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../apiRequests/Channels";
|
||||
import { updateChannelInProduct } from "../../apiRequests/Product";
|
||||
import {
|
||||
assignProducts,
|
||||
|
@ -144,9 +145,9 @@ describe("Sales discounts", () => {
|
|||
const discountValue = 50;
|
||||
const productPrice = 100;
|
||||
|
||||
channelsUtils
|
||||
.createChannel({ name: saleName })
|
||||
.then(channelResp => (channel = channelResp));
|
||||
createChannel({ name: saleName }).then(
|
||||
channelResp => (channel = channelResp)
|
||||
);
|
||||
productsUtils
|
||||
.createProductInChannel({
|
||||
name: saleName,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// <reference types="cypress" />
|
||||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../apiRequests/Channels";
|
||||
import {
|
||||
createVoucher,
|
||||
discountOptions
|
||||
|
@ -77,7 +78,7 @@ describe("Vouchers discounts", () => {
|
|||
price: productPrice
|
||||
});
|
||||
})
|
||||
.then(({ variants: variantsResp }) => (variants = variantsResp));
|
||||
.then(({ variantsList: variantsResp }) => (variants = variantsResp));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -142,8 +143,7 @@ describe("Vouchers discounts", () => {
|
|||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
const voucherValue = 50;
|
||||
|
||||
channelsUtils
|
||||
.createChannel({ name: randomName })
|
||||
createChannel({ name: randomName })
|
||||
.then(channel => {
|
||||
createVoucher({
|
||||
voucherCode: randomName,
|
||||
|
|
|
@ -85,7 +85,7 @@ describe("Homepage analytics", () => {
|
|||
});
|
||||
}
|
||||
)
|
||||
.then(({ variants: variantsResp }) => {
|
||||
.then(({ variantsList: variantsResp }) => {
|
||||
createdVariants = variantsResp;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// <reference types="cypress" />
|
||||
import faker from "faker";
|
||||
|
||||
import { createChannel } from "../../apiRequests/Channels";
|
||||
import { CHANNEL_FORM_SELECTORS } from "../../elements/channels/channel-form-selectors";
|
||||
import { HEADER_SELECTORS } from "../../elements/header/header-selectors";
|
||||
import { DRAFT_ORDER_SELECTORS } from "../../elements/orders/draft-order-selectors";
|
||||
|
@ -26,7 +27,7 @@ describe("Channels in draft orders", () => {
|
|||
.getDefaultChannel()
|
||||
.then(channel => {
|
||||
defaultChannel = channel;
|
||||
channelsUtils.createChannel({ name: randomName });
|
||||
createChannel({ name: randomName });
|
||||
})
|
||||
.then(channelResp => {
|
||||
otherChannel = channelResp;
|
||||
|
|
|
@ -77,7 +77,7 @@ describe("Orders", () => {
|
|||
});
|
||||
}
|
||||
)
|
||||
.then(({ variants: variantsResp }) => {
|
||||
.then(({ variantsList: variantsResp }) => {
|
||||
variantsList = variantsResp;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// <reference types="cypress" />
|
||||
import faker from "faker";
|
||||
|
||||
import { createAttribute } from "../../apiRequests/Attribute";
|
||||
import { createTypeProduct } from "../../apiRequests/Product";
|
||||
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";
|
||||
|
@ -47,7 +49,7 @@ describe("Create product", () => {
|
|||
before(() => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
productUtils.deleteProductsStartsWith(startsWith);
|
||||
productUtils.createAttribute(name).then(attributeResp => {
|
||||
createAttribute(name).then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
});
|
||||
});
|
||||
|
@ -60,7 +62,7 @@ describe("Create product", () => {
|
|||
|
||||
it("should create product with variants", () => {
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
productUtils.createTypeProduct(randomName, attribute.id);
|
||||
createTypeProduct({ name: randomName, attributeId: attribute.id });
|
||||
seo.slug = randomName;
|
||||
const productData = {
|
||||
generalInfo,
|
||||
|
@ -88,7 +90,11 @@ describe("Create product", () => {
|
|||
const prices = { sellingPrice: 6, costPrice: 3 };
|
||||
const randomName = `${startsWith}${faker.datatype.number()}`;
|
||||
seo.slug = randomName;
|
||||
productUtils.createTypeProduct(randomName, attribute.id, false);
|
||||
createTypeProduct({
|
||||
name: randomName,
|
||||
attributeId: attribute.id,
|
||||
hasVariants: false
|
||||
});
|
||||
const productData = {
|
||||
generalInfo,
|
||||
seo,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createCollection } from "../../../apiRequests/Collections";
|
||||
import { updateProduct } from "../../../apiRequests/Product";
|
||||
import { PRODUCTS_LIST } from "../../../elements/catalog/products/products-list";
|
||||
import {
|
||||
selectFilterOption,
|
||||
|
@ -12,8 +13,7 @@ import { getDefaultChannel } from "../../../utils/channelsUtils";
|
|||
import {
|
||||
createProductInChannel,
|
||||
createTypeAttributeAndCategoryForProduct,
|
||||
deleteProductsStartsWith,
|
||||
updateProduct
|
||||
deleteProductsStartsWith
|
||||
} from "../../../utils/products/productsUtils";
|
||||
import {
|
||||
createShipping,
|
||||
|
|
|
@ -76,9 +76,14 @@ describe("Creating variants", () => {
|
|||
const price = 10;
|
||||
let createdProduct;
|
||||
|
||||
createProduct(attribute.id, name, productType.id, category.id)
|
||||
createProduct({
|
||||
attributeId: attribute.id,
|
||||
name,
|
||||
productTypeId: productType.id,
|
||||
categoryId: category.id
|
||||
})
|
||||
.then(resp => {
|
||||
createdProduct = resp.body.data.productCreate.product;
|
||||
createdProduct = resp;
|
||||
updateChannelInProduct({
|
||||
productId: createdProduct.id,
|
||||
channelId: defaultChannel.id
|
||||
|
@ -145,15 +150,15 @@ describe("Creating variants", () => {
|
|||
const variantsPrice = 10;
|
||||
let newChannel;
|
||||
let createdProduct;
|
||||
createChannel(true, name, name, "PLN")
|
||||
createChannel({ isActive: true, name, currencyCode: "PLN" })
|
||||
.then(resp => {
|
||||
newChannel = resp.body.data.channelCreate.channel;
|
||||
productUtils.createProduct(
|
||||
attribute.id,
|
||||
newChannel = resp;
|
||||
createProduct({
|
||||
attributeId: attribute.id,
|
||||
name,
|
||||
productType.id,
|
||||
category.id
|
||||
);
|
||||
productTypeId: productType.id,
|
||||
categoryId: category.id
|
||||
});
|
||||
})
|
||||
.then(productResp => {
|
||||
createdProduct = productResp;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createCategory } from "../../apiRequests/Category";
|
||||
import { createCollection } from "../../apiRequests/Collections";
|
||||
import { getProductDetails } from "../../apiRequests/storeFront/ProductDetails";
|
||||
import { PRODUCT_DETAILS } from "../../elements/catalog/products/product-details";
|
||||
|
@ -11,7 +12,6 @@ import { getDefaultChannel } from "../../utils/channelsUtils";
|
|||
import { deleteCollectionsStartsWith } from "../../utils/collectionsUtils";
|
||||
import { expectCorrectProductInformation } from "../../utils/products/checkProductInfo";
|
||||
import {
|
||||
createCategory,
|
||||
createProductInChannel,
|
||||
createTypeAttributeAndCategoryForProduct,
|
||||
deleteProductsStartsWith
|
||||
|
|
|
@ -8,8 +8,11 @@ import { selectChannelVariantInDetailsPage } from "../../channelsSteps";
|
|||
import { fillUpPriceList } from "./priceList";
|
||||
|
||||
export function variantsShouldBeVisible({ name, price }) {
|
||||
cy.contains(PRODUCT_DETAILS.variantRow, name).should("be.visible");
|
||||
cy.contains(PRODUCT_DETAILS.variantRow, price).should("be.visible");
|
||||
cy.contains(PRODUCT_DETAILS.variantRow, name)
|
||||
.should("be.visible")
|
||||
.find(PRODUCT_DETAILS.variantPrice)
|
||||
.invoke("text")
|
||||
.then(text => expect(text).to.includes(price));
|
||||
}
|
||||
export function createFirstVariant({ sku, warehouseId, price, attribute }) {
|
||||
cy.get(PRODUCT_DETAILS.addVariantsButton).click();
|
||||
|
@ -17,6 +20,9 @@ export function createFirstVariant({ sku, warehouseId, price, attribute }) {
|
|||
.contains(attribute)
|
||||
.find(VARIANTS_SELECTORS.attributeCheckbox)
|
||||
.click()
|
||||
.get(VARIANTS_SELECTORS.valueContainer)
|
||||
.find(BUTTON_SELECTORS.checked)
|
||||
.should("exist")
|
||||
.get(VARIANTS_SELECTORS.nextButton)
|
||||
.click();
|
||||
fillUpPriceList(price);
|
||||
|
|
|
@ -3,37 +3,40 @@ import { DRAFT_ORDER_SELECTORS } from "../elements/orders/draft-order-selectors"
|
|||
import { SELECT_SHIPPING_METHOD_FORM } from "../elements/shipping/select-shipping-method-form";
|
||||
|
||||
export function finalizeDraftOrder(name) {
|
||||
cy.get(DRAFT_ORDER_SELECTORS.addProducts)
|
||||
return cy
|
||||
.get(DRAFT_ORDER_SELECTORS.addProducts)
|
||||
.click()
|
||||
.get(ASSIGN_PRODUCTS_SELECTORS.searchInput)
|
||||
.type(name);
|
||||
cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, name)
|
||||
.find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
|
||||
.click()
|
||||
.get(ASSIGN_PRODUCTS_SELECTORS.submitButton)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.editCustomerButton)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.selectCustomer)
|
||||
.type(name);
|
||||
cy.contains(DRAFT_ORDER_SELECTORS.selectCustomerOption, name)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.addShippingCarrierLink)
|
||||
.click()
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.selectShippingMethod)
|
||||
.click()
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.shippingMethodOption)
|
||||
.first()
|
||||
.click();
|
||||
cy.addAliasToGraphRequest("OrderShippingMethodUpdate")
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.submitButton)
|
||||
.click();
|
||||
cy.wait("@OrderShippingMethodUpdate");
|
||||
cy.getTextFromElement(DRAFT_ORDER_SELECTORS.pageHeader).as(
|
||||
"draftOrderNumber"
|
||||
);
|
||||
cy.addAliasToGraphRequest("OrderDraftFinalize");
|
||||
cy.get(DRAFT_ORDER_SELECTORS.finalizeButton).click();
|
||||
cy.wait("@OrderDraftFinalize");
|
||||
return cy.get("@draftOrderNumber");
|
||||
.type(name)
|
||||
.then(() => {
|
||||
cy.contains(ASSIGN_PRODUCTS_SELECTORS.tableRow, name)
|
||||
.find(ASSIGN_PRODUCTS_SELECTORS.checkbox)
|
||||
.click()
|
||||
.get(ASSIGN_PRODUCTS_SELECTORS.submitButton)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.editCustomerButton)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.selectCustomer)
|
||||
.type(name);
|
||||
cy.contains(DRAFT_ORDER_SELECTORS.selectCustomerOption, name)
|
||||
.click()
|
||||
.get(DRAFT_ORDER_SELECTORS.addShippingCarrierLink)
|
||||
.click()
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.selectShippingMethod)
|
||||
.click()
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.shippingMethodOption)
|
||||
.first()
|
||||
.click();
|
||||
cy.addAliasToGraphRequest("OrderShippingMethodUpdate")
|
||||
.get(SELECT_SHIPPING_METHOD_FORM.submitButton)
|
||||
.click();
|
||||
cy.wait("@OrderShippingMethodUpdate");
|
||||
cy.getTextFromElement(DRAFT_ORDER_SELECTORS.pageHeader).as(
|
||||
"draftOrderNumber"
|
||||
);
|
||||
cy.addAliasToGraphRequest("OrderDraftFinalize");
|
||||
cy.get(DRAFT_ORDER_SELECTORS.finalizeButton).click();
|
||||
cy.wait("@OrderDraftFinalize");
|
||||
return cy.get("@draftOrderNumber");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,13 +32,3 @@ export function getDefaultChannel() {
|
|||
});
|
||||
});
|
||||
}
|
||||
export function createChannel({
|
||||
isActive = true,
|
||||
name,
|
||||
slug = name,
|
||||
currencyCode = "PLN"
|
||||
}) {
|
||||
return channels
|
||||
.createChannel(isActive, name, slug, currencyCode)
|
||||
.its("body.data.channelCreate.channel");
|
||||
}
|
||||
|
|
|
@ -11,14 +11,15 @@ export function createWaitingForCaptureOrder(
|
|||
let checkout;
|
||||
const auth = "token";
|
||||
cy.loginInShop();
|
||||
return createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
.then(checkoutResp => {
|
||||
checkout = checkoutResp;
|
||||
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
||||
})
|
||||
.then(() => addPayment(checkout.id))
|
||||
.then(() => checkoutRequest.completeCheckout(checkout.id))
|
||||
.then(() => checkout);
|
||||
.then(order => ({ checkout, order }));
|
||||
}
|
||||
export function createCheckoutWithVoucher({
|
||||
channelSlug,
|
||||
|
@ -30,7 +31,8 @@ export function createCheckoutWithVoucher({
|
|||
auth
|
||||
}) {
|
||||
let checkout;
|
||||
return createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
.then(checkoutResp => {
|
||||
checkout = checkoutResp;
|
||||
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
||||
|
@ -48,7 +50,8 @@ export function createReadyToFulfillOrder(
|
|||
variantsList
|
||||
) {
|
||||
let order;
|
||||
return createDraftOrder(customerId, shippingMethodId, channelId)
|
||||
return orderRequest
|
||||
.createDraftOrder(customerId, shippingMethodId, channelId)
|
||||
.then(orderResp => {
|
||||
order = orderResp;
|
||||
assignVariantsToOrder(order, variantsList);
|
||||
|
@ -64,7 +67,8 @@ export function createOrder({
|
|||
variantsList
|
||||
}) {
|
||||
let order;
|
||||
return createDraftOrder(customerId, shippingMethodId, channelId)
|
||||
return orderRequest
|
||||
.createDraftOrder(customerId, shippingMethodId, channelId)
|
||||
.then(orderResp => {
|
||||
order = orderResp;
|
||||
assignVariantsToOrder(order, variantsList);
|
||||
|
@ -78,30 +82,6 @@ function assignVariantsToOrder(order, variantsList) {
|
|||
orderRequest.addProductToOrder(order.id, variantElement.id);
|
||||
});
|
||||
}
|
||||
|
||||
export function createDraftOrder(customerId, shippingMethodId, channelId) {
|
||||
return orderRequest
|
||||
.createDraftOrder(customerId, shippingMethodId, channelId)
|
||||
.its("body.data.draftOrderCreate.order");
|
||||
}
|
||||
export function createCheckout({
|
||||
channelSlug,
|
||||
email,
|
||||
variantsList,
|
||||
address,
|
||||
auth
|
||||
}) {
|
||||
return checkoutRequest
|
||||
.createCheckout({
|
||||
channelSlug,
|
||||
email,
|
||||
productQuantity: 1,
|
||||
variantsList,
|
||||
address,
|
||||
auth
|
||||
})
|
||||
.its("body.data.checkoutCreate.checkout");
|
||||
}
|
||||
export function addPayment(checkoutId) {
|
||||
return checkoutRequest.addPayment(
|
||||
checkoutId,
|
||||
|
@ -109,3 +89,20 @@ export function addPayment(checkoutId) {
|
|||
"not-charged"
|
||||
);
|
||||
}
|
||||
export function createAndCompleteCheckoutWithoutShipping({
|
||||
channelSlug,
|
||||
email,
|
||||
variantsList,
|
||||
billingAddress,
|
||||
auth
|
||||
}) {
|
||||
let checkout;
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, billingAddress, auth })
|
||||
.then(checkoutResp => {
|
||||
checkout = checkoutResp;
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
.then(() => checkoutRequest.completeCheckout(checkout.id))
|
||||
.then(order => ({ checkout, order }));
|
||||
}
|
||||
|
|
|
@ -18,15 +18,16 @@ export function createProductInChannel({
|
|||
description = null
|
||||
}) {
|
||||
let product;
|
||||
let variants;
|
||||
return createProduct(
|
||||
attributeId,
|
||||
name,
|
||||
productTypeId,
|
||||
categoryId,
|
||||
collectionId,
|
||||
description
|
||||
)
|
||||
let variantsList;
|
||||
return productRequest
|
||||
.createProduct({
|
||||
attributeId,
|
||||
name,
|
||||
productTypeId,
|
||||
categoryId,
|
||||
collectionId,
|
||||
description
|
||||
})
|
||||
.then(productResp => {
|
||||
product = productResp;
|
||||
productRequest.updateChannelInProduct({
|
||||
|
@ -38,7 +39,7 @@ export function createProductInChannel({
|
|||
});
|
||||
})
|
||||
.then(() => {
|
||||
createVariant({
|
||||
productRequest.createVariant({
|
||||
productId: product.id,
|
||||
sku: name,
|
||||
attributeId,
|
||||
|
@ -49,8 +50,8 @@ export function createProductInChannel({
|
|||
});
|
||||
})
|
||||
.then(variantsResp => {
|
||||
variants = variantsResp;
|
||||
return { product, variants };
|
||||
variantsList = variantsResp;
|
||||
return { product, variantsList };
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -61,81 +62,21 @@ export function createTypeAttributeAndCategoryForProduct(
|
|||
let attribute;
|
||||
let productType;
|
||||
let category;
|
||||
return createAttribute(name, attributeValues)
|
||||
return attributeRequest
|
||||
.createAttribute(name, attributeValues)
|
||||
.then(attributeResp => {
|
||||
attribute = attributeResp;
|
||||
createTypeProduct(name, attributeResp.id);
|
||||
productRequest.createTypeProduct({ name, attributeId: attributeResp.id });
|
||||
})
|
||||
.then(productTypeResp => {
|
||||
productType = productTypeResp;
|
||||
createCategory(name);
|
||||
categoryRequest.createCategory(name);
|
||||
})
|
||||
.then(categoryResp => {
|
||||
category = categoryResp;
|
||||
return { attribute, category, productType };
|
||||
});
|
||||
}
|
||||
export function createAttribute(name, attributeValues) {
|
||||
return attributeRequest
|
||||
.createAttribute(name, attributeValues)
|
||||
.its("body.data.attributeCreate.attribute");
|
||||
}
|
||||
export function createTypeProduct(name, attributeId, hasVariants) {
|
||||
return productRequest
|
||||
.createTypeProduct(name, attributeId, hasVariants)
|
||||
.its("body.data.productTypeCreate.productType");
|
||||
}
|
||||
export function createCategory(name) {
|
||||
return categoryRequest
|
||||
.createCategory(name)
|
||||
.its("body.data.categoryCreate.category");
|
||||
}
|
||||
export function createProduct(
|
||||
attributeId,
|
||||
name,
|
||||
productTypeId,
|
||||
categoryId,
|
||||
collectionId,
|
||||
description
|
||||
) {
|
||||
return productRequest
|
||||
.createProduct(
|
||||
attributeId,
|
||||
name,
|
||||
productTypeId,
|
||||
categoryId,
|
||||
collectionId,
|
||||
description
|
||||
)
|
||||
.its("body.data.productCreate.product");
|
||||
}
|
||||
export function updateProduct(productId, input) {
|
||||
return productRequest
|
||||
.updateProduct(productId, input)
|
||||
.its("body.data.productUpdate.product");
|
||||
}
|
||||
export function createVariant({
|
||||
productId,
|
||||
sku,
|
||||
attributeId,
|
||||
warehouseId,
|
||||
quantityInWarehouse,
|
||||
channelId,
|
||||
price
|
||||
}) {
|
||||
return productRequest
|
||||
.createVariant({
|
||||
productId,
|
||||
sku,
|
||||
attributeId,
|
||||
warehouseId,
|
||||
quantity: quantityInWarehouse,
|
||||
channelId,
|
||||
price
|
||||
})
|
||||
.its("body.data.productVariantBulkCreate.productVariants");
|
||||
}
|
||||
|
||||
export function deleteProductsStartsWith(startsWith) {
|
||||
cy.deleteElementsStartsWith(
|
||||
productRequest.deleteProductType,
|
||||
|
|
|
@ -6,10 +6,15 @@ export function createShipping({ channelId, name, address, price = 1 }) {
|
|||
let shippingZone;
|
||||
let warehouse;
|
||||
|
||||
return createShippingZone(name, address.country, channelId)
|
||||
return shippingMethodRequest
|
||||
.createShippingZone(name, address.country, channelId)
|
||||
.then(shippingZoneResp => {
|
||||
shippingZone = shippingZoneResp;
|
||||
createWarehouse({ name, shippingZoneId: shippingZone.id, address });
|
||||
warehouseRequest.createWarehouse({
|
||||
name,
|
||||
shippingZone: shippingZone.id,
|
||||
address
|
||||
});
|
||||
})
|
||||
.then(warehouseResp => {
|
||||
warehouse = warehouseResp;
|
||||
|
@ -25,17 +30,6 @@ export function createShipping({ channelId, name, address, price = 1 }) {
|
|||
})
|
||||
.then(() => ({ shippingMethod, shippingZone, warehouse }));
|
||||
}
|
||||
|
||||
export function createShippingZone(name, country, channelId) {
|
||||
return shippingMethodRequest
|
||||
.createShippingZone(name, country, channelId)
|
||||
.its("body.data.shippingZoneCreate.shippingZone");
|
||||
}
|
||||
export function createWarehouse({ name, shippingZoneId, address }) {
|
||||
return warehouseRequest
|
||||
.createWarehouse({ name, shippingZone: shippingZoneId, address })
|
||||
.its("body.data.createWarehouse.warehouse");
|
||||
}
|
||||
export function createShippingRate(name, shippingZoneId) {
|
||||
return shippingMethodRequest
|
||||
.createShippingRate(name, shippingZoneId)
|
||||
|
|
Loading…
Reference in a new issue