Saleor 2962 warehouses in checkout (#1118)
* add tests for puchase by type * add expect for isShippingRequired * tests for adyen * tests for adyen * tests for adyen * tests for adyen * adyen * adyen * adyen * adyen * adyen * warehouses in chcekout * test for adyen * adyen tests * warehouse in chceckout * merge changes * remove dash * remove video * fix typo
This commit is contained in:
parent
0b1d0a3a54
commit
01d0a222ac
9 changed files with 82 additions and 244 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"baseUrl": "http://localhost:9000/dashboard/",
|
||||
"baseUrl": "http://localhost:9000/",
|
||||
"defaultCommandTimeout": 15000,
|
||||
"requestTimeout": 15000,
|
||||
"viewportWidth": 1400,
|
||||
|
|
|
@ -29,7 +29,7 @@ export function createCheckout({
|
|||
${shippingAddress}
|
||||
${billingAddressLines}
|
||||
}){
|
||||
checkoutErrors{
|
||||
errors{
|
||||
field
|
||||
message
|
||||
}
|
||||
|
@ -44,8 +44,9 @@ export function createCheckout({
|
|||
}`;
|
||||
return cy
|
||||
.sendRequestWithQuery(mutation, auth)
|
||||
.its("body.data.checkoutCreate.checkout");
|
||||
.its("body.data.checkoutCreate");
|
||||
}
|
||||
|
||||
export function addShippingMethod(checkoutId, shippingMethodId) {
|
||||
const mutation = `mutation{
|
||||
checkoutShippingMethodUpdate(checkoutId:"${checkoutId}",
|
||||
|
|
68
cypress/integration/allEnv/checkout/warehouses.js
Normal file
68
cypress/integration/allEnv/checkout/warehouses.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
import faker from "faker";
|
||||
|
||||
import { createCheckout } from "../../../apiRequests/Checkout";
|
||||
import { getDefaultChannel } from "../../../utils/channelsUtils";
|
||||
import {
|
||||
createProductInChannel,
|
||||
createTypeAttributeAndCategoryForProduct,
|
||||
deleteProductsStartsWith
|
||||
} from "../../../utils/products/productsUtils";
|
||||
import {
|
||||
createShipping,
|
||||
deleteShippingStartsWith
|
||||
} from "../../../utils/shippingUtils";
|
||||
|
||||
describe("Warehouses in checkout", () => {
|
||||
const startsWith = `CyWarehouseCheckout`;
|
||||
let defaultChannel;
|
||||
let usAddress;
|
||||
let plAddress;
|
||||
let warehouse;
|
||||
|
||||
it("should not be possible to buy product for country not listed in warehouse", () => {
|
||||
cy.clearSessionData().loginUserViaRequest();
|
||||
deleteShippingStartsWith(startsWith);
|
||||
deleteProductsStartsWith(startsWith);
|
||||
const name = `${startsWith}${faker.datatype.number()}`;
|
||||
cy.fixture("addresses")
|
||||
.then(addresses => {
|
||||
usAddress = addresses.usAddress;
|
||||
plAddress = addresses.plAddress;
|
||||
getDefaultChannel();
|
||||
})
|
||||
.then(channelResp => {
|
||||
defaultChannel = channelResp;
|
||||
createShipping({
|
||||
channelId: defaultChannel.id,
|
||||
name,
|
||||
address: usAddress
|
||||
});
|
||||
})
|
||||
.then(({ warehouse: warehouseResp }) => {
|
||||
warehouse = warehouseResp;
|
||||
createTypeAttributeAndCategoryForProduct(name);
|
||||
})
|
||||
.then(({ attribute, productType, category }) => {
|
||||
createProductInChannel({
|
||||
name,
|
||||
attributeId: attribute.id,
|
||||
categoryId: category.id,
|
||||
channelId: defaultChannel.id,
|
||||
productTypeId: productType.id,
|
||||
warehouseId: warehouse.id,
|
||||
quantityInWarehouse: 100
|
||||
});
|
||||
})
|
||||
.then(({ variantsList }) => {
|
||||
createCheckout({
|
||||
channelSlug: defaultChannel.slug,
|
||||
email: "example@example.com",
|
||||
variantsList,
|
||||
address: plAddress
|
||||
});
|
||||
})
|
||||
.then(({ errors }) => {
|
||||
expect(errors[0]).to.have.property("field", "quantity");
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,233 +0,0 @@
|
|||
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");
|
||||
});
|
||||
});
|
||||
});
|
|
@ -173,7 +173,7 @@ describe("Shipping methods", () => {
|
|||
variantsList,
|
||||
address: plAddress,
|
||||
auth: "token"
|
||||
}).then(checkout => {
|
||||
}).then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
|
@ -198,7 +198,7 @@ describe("Shipping methods", () => {
|
|||
variantsList,
|
||||
address: plAddress,
|
||||
auth: "token"
|
||||
}).then(checkout => {
|
||||
}).then(({ checkout }) => {
|
||||
const isShippingAvailable = isShippingAvailableInCheckout(
|
||||
checkout,
|
||||
shippingName
|
||||
|
|
|
@ -95,7 +95,9 @@ describe("Homepage analytics", () => {
|
|||
});
|
||||
|
||||
it("should all elements be visible on the dashboard", () => {
|
||||
cy.visit(urlList.homePage)
|
||||
cy.pause();
|
||||
cy.visit(urlList.homePage);
|
||||
cy.pause()
|
||||
.softAssertVisibility(HOMEPAGE_SELECTORS.sales)
|
||||
.softAssertVisibility(HOMEPAGE_SELECTORS.orders)
|
||||
.softAssertVisibility(HOMEPAGE_SELECTORS.activity)
|
||||
|
|
|
@ -174,7 +174,7 @@ describe("Purchase products with all products types", () => {
|
|||
auth: "token"
|
||||
});
|
||||
})
|
||||
.then(checkoutResp => {
|
||||
.then(({ checkout: checkoutResp }) => {
|
||||
checkout = checkoutResp;
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
|
|
|
@ -93,7 +93,7 @@ describe("Adyen payments", () => {
|
|||
billingAddress: address,
|
||||
auth: "token"
|
||||
})
|
||||
.then(checkoutResp => {
|
||||
.then(({ checkout: checkoutResp }) => {
|
||||
checkout = checkoutResp;
|
||||
addShippingMethod(checkout.id, shippingMethod.id);
|
||||
})
|
||||
|
|
|
@ -13,7 +13,7 @@ export function createWaitingForCaptureOrder(
|
|||
cy.loginInShop();
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
.then(checkoutResp => {
|
||||
.then(({ checkout: checkoutResp }) => {
|
||||
checkout = checkoutResp;
|
||||
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
||||
})
|
||||
|
@ -34,7 +34,7 @@ export function createCheckoutWithVoucher({
|
|||
let checkout;
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, address, auth })
|
||||
.then(checkoutResp => {
|
||||
.then(({ checkout: checkoutResp }) => {
|
||||
checkout = checkoutResp;
|
||||
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
|
||||
})
|
||||
|
@ -137,7 +137,7 @@ export function createAndCompleteCheckoutWithoutShipping({
|
|||
let checkout;
|
||||
return checkoutRequest
|
||||
.createCheckout({ channelSlug, email, variantsList, billingAddress, auth })
|
||||
.then(checkoutResp => {
|
||||
.then(({ checkout: checkoutResp }) => {
|
||||
checkout = checkoutResp;
|
||||
addPayment(checkout.id);
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue