Fix tests for orders (#2213)

This commit is contained in:
Karolina Rakoczy 2022-08-04 12:59:42 +02:00 committed by GitHub
parent b0d7342e1f
commit eaf3271dc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 35 deletions

View file

@ -105,9 +105,9 @@ describe("Orders", () => {
); );
}); });
xit( it(
"should create order with selected channel. TC: SALEOR_2104", "should create order with selected channel. TC: SALEOR_2104",
{ tags: ["@orders", "@allEnv"] }, { tags: ["@orders", "@allEnv", "@stable"] },
() => { () => {
cy.visit(urlList.orders) cy.visit(urlList.orders)
.get(ORDERS_SELECTORS.createOrder) .get(ORDERS_SELECTORS.createOrder)
@ -145,7 +145,7 @@ describe("Orders", () => {
it( it(
"should cancel fulfillment. TC: SALEOR_2106", "should cancel fulfillment. TC: SALEOR_2106",
{ tags: ["@orders", "@allEnv"] }, { tags: ["@orders", "@allEnv", "@stable"] },
() => { () => {
let order; let order;
createFulfilledOrder({ createFulfilledOrder({
@ -212,7 +212,7 @@ describe("Orders", () => {
getOrder(order.id); getOrder(order.id);
}) })
.then(orderResp => { .then(orderResp => {
expect(orderResp.paymentStatus).to.be.eq("FULLY_REFUNDED"); expect(orderResp.paymentStatus).to.be.eq("PARTIALLY_REFUNDED");
}); });
}, },
); );

View file

@ -6,9 +6,16 @@ export function markOrderAsPaid(orderId) {
errors{ errors{
message message
} }
order{
id
number
lines{
id
}
}
} }
}`; }`;
return cy.sendRequestWithQuery(mutation); return cy.sendRequestWithQuery(mutation).its("body.data.orderMarkAsPaid");
} }
export function updateOrdersSettings(automaticallyConfirmAllNewOrders = true) { export function updateOrdersSettings(automaticallyConfirmAllNewOrders = true) {
@ -43,12 +50,12 @@ export function createDraftOrder({
customerId, customerId,
shippingMethodId, shippingMethodId,
channelId, channelId,
address address,
}) { }) {
const user = getValueWithDefault(customerId, `user:"${customerId}"`); const user = getValueWithDefault(customerId, `user:"${customerId}"`);
const shippingMethod = getValueWithDefault( const shippingMethod = getValueWithDefault(
shippingMethodId, shippingMethodId,
`shippingMethod:"${shippingMethodId}"` `shippingMethod:"${shippingMethodId}"`,
); );
const mutation = `mutation{ const mutation = `mutation{

View file

@ -2,7 +2,7 @@ import * as checkoutRequest from "../requests/Checkout";
import * as orderRequest from "../requests/Order"; import * as orderRequest from "../requests/Order";
import { import {
getPaymentMethodStripeId, getPaymentMethodStripeId,
sendConfirmationToStripe sendConfirmationToStripe,
} from "../requests/stripe"; } from "../requests/stripe";
import { createProductInChannel } from "./products/productsUtils"; import { createProductInChannel } from "./products/productsUtils";
@ -11,7 +11,7 @@ export function createWaitingForCaptureOrder({
email, email,
variantsList, variantsList,
shippingMethodName, shippingMethodName,
address address,
}) { }) {
let checkout; let checkout;
const auth = "token"; const auth = "token";
@ -23,13 +23,13 @@ export function createWaitingForCaptureOrder({
variantsList, variantsList,
address, address,
billingAddress: address, billingAddress: address,
auth auth,
}) })
.then(({ checkout: checkoutResp }) => { .then(({ checkout: checkoutResp }) => {
checkout = checkoutResp; checkout = checkoutResp;
const shippingMethodId = getShippingMethodIdFromCheckout( const shippingMethodId = getShippingMethodIdFromCheckout(
checkout, checkout,
shippingMethodName shippingMethodName,
); );
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId); checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
}) })
@ -44,7 +44,7 @@ export function getShippingMethodIdFromCheckout(checkout, shippingMethodName) {
return null; return null;
} else { } else {
return checkout.shippingMethods.find( return checkout.shippingMethods.find(
element => element.name === shippingMethodName element => element.name === shippingMethodName,
).id; ).id;
} }
} }
@ -53,11 +53,11 @@ export function updateShippingInCheckout(checkoutToken, shippingMethodName) {
return checkoutRequest.getCheckout(checkoutToken).then(checkout => { return checkoutRequest.getCheckout(checkoutToken).then(checkout => {
const shippingMethodId = getShippingMethodIdFromCheckout( const shippingMethodId = getShippingMethodIdFromCheckout(
checkout, checkout,
shippingMethodName shippingMethodName,
); );
return checkoutRequest.checkoutShippingMethodUpdate( return checkoutRequest.checkoutShippingMethodUpdate(
checkout.id, checkout.id,
shippingMethodId shippingMethodId,
); );
}); });
} }
@ -70,7 +70,7 @@ export function createCheckoutWithVoucher({
address, address,
shippingMethodName, shippingMethodName,
voucherCode, voucherCode,
auth auth,
}) { }) {
let checkout; let checkout;
return checkoutRequest return checkoutRequest
@ -81,13 +81,13 @@ export function createCheckoutWithVoucher({
variantsList, variantsList,
address, address,
billingAddress: address, billingAddress: address,
auth auth,
}) })
.then(({ checkout: checkoutResp }) => { .then(({ checkout: checkoutResp }) => {
checkout = checkoutResp; checkout = checkoutResp;
const shippingMethodId = getShippingMethodIdFromCheckout( const shippingMethodId = getShippingMethodIdFromCheckout(
checkout, checkout,
shippingMethodName shippingMethodName,
); );
checkoutRequest.addShippingMethod(checkout.id, shippingMethodId); checkoutRequest.addShippingMethod(checkout.id, shippingMethodId);
}) })
@ -96,7 +96,7 @@ export function createCheckoutWithVoucher({
}) })
.then(resp => ({ .then(resp => ({
addPromoCodeResp: resp.body.data.checkoutAddPromoCode, addPromoCodeResp: resp.body.data.checkoutAddPromoCode,
checkout checkout,
})); }));
} }
@ -107,7 +107,7 @@ export function purchaseProductWithPromoCode({
address, address,
shippingMethodName, shippingMethodName,
voucherCode, voucherCode,
auth auth,
}) { }) {
let checkout; let checkout;
@ -118,7 +118,7 @@ export function purchaseProductWithPromoCode({
address, address,
shippingMethodName, shippingMethodName,
voucherCode, voucherCode,
auth auth,
}) })
.then(({ checkout: checkoutResp }) => { .then(({ checkout: checkoutResp }) => {
checkout = checkoutResp; checkout = checkoutResp;
@ -133,7 +133,7 @@ export function createReadyToFulfillOrder({
shippingMethodId, shippingMethodId,
channelId, channelId,
variantsList, variantsList,
address address,
}) { }) {
let order; let order;
return orderRequest return orderRequest
@ -142,8 +142,8 @@ export function createReadyToFulfillOrder({
order = orderResp; order = orderResp;
assignVariantsToOrder(order, variantsList); assignVariantsToOrder(order, variantsList);
}) })
.then(() => orderRequest.markOrderAsPaid(order.id)) .then(() => orderRequest.completeOrder(order.id))
.then(() => orderRequest.completeOrder(order.id)); .then(() => orderRequest.markOrderAsPaid(order.id));
} }
export function createFulfilledOrder({ export function createFulfilledOrder({
@ -153,20 +153,20 @@ export function createFulfilledOrder({
variantsList, variantsList,
address, address,
warehouse, warehouse,
quantity = 1 quantity = 1,
}) { }) {
return createReadyToFulfillOrder({ return createReadyToFulfillOrder({
customerId, customerId,
shippingMethodId, shippingMethodId,
channelId, channelId,
variantsList, variantsList,
address address,
}).then(({ order }) => { }).then(({ order }) => {
orderRequest.fulfillOrder({ orderRequest.fulfillOrder({
orderId: order.id, orderId: order.id,
warehouse, warehouse,
quantity, quantity,
linesId: order.lines linesId: order.lines,
}); });
}); });
} }
@ -176,7 +176,7 @@ export function createOrder({
shippingMethodId, shippingMethodId,
channelId, channelId,
variantsList, variantsList,
address address,
}) { }) {
let order; let order;
return orderRequest return orderRequest
@ -199,7 +199,7 @@ export function addPayment(checkoutId) {
return checkoutRequest.addPayment({ return checkoutRequest.addPayment({
checkoutId, checkoutId,
gateway: "mirumee.payments.dummy", gateway: "mirumee.payments.dummy",
token: "not-charged" token: "not-charged",
}); });
} }
@ -207,7 +207,7 @@ export function addAdyenPayment(checkoutId, amount) {
return checkoutRequest.addPayment({ return checkoutRequest.addPayment({
checkoutId, checkoutId,
gateway: "mirumee.payments.adyen", gateway: "mirumee.payments.adyen",
amount amount,
}); });
} }
export function addStripePayment(checkoutId, amount, token) { export function addStripePayment(checkoutId, amount, token) {
@ -215,7 +215,7 @@ export function addStripePayment(checkoutId, amount, token) {
checkoutId, checkoutId,
gateway: "saleor.payments.stripe", gateway: "saleor.payments.stripe",
amount, amount,
token token,
}); });
} }
@ -224,7 +224,7 @@ export function createAndCompleteCheckoutWithoutShipping({
email, email,
variantsList, variantsList,
billingAddress, billingAddress,
auth auth,
}) { }) {
let checkout; let checkout;
return checkoutRequest return checkoutRequest
@ -247,7 +247,7 @@ export function createOrderWithNewProduct({
quantityInWarehouse = 1, quantityInWarehouse = 1,
trackInventory = true, trackInventory = true,
shippingMethod, shippingMethod,
address address,
}) { }) {
let variantsList; let variantsList;
return createProductInChannel({ return createProductInChannel({
@ -258,7 +258,7 @@ export function createOrderWithNewProduct({
name, name,
warehouseId, warehouseId,
quantityInWarehouse, quantityInWarehouse,
trackInventory trackInventory,
}) })
.then(({ variantsList: variantsListResp }) => { .then(({ variantsList: variantsListResp }) => {
variantsList = variantsListResp; variantsList = variantsListResp;
@ -267,7 +267,7 @@ export function createOrderWithNewProduct({
email: "email@example.com", email: "email@example.com",
variantsList, variantsList,
shippingMethodName: shippingMethod.name, shippingMethodName: shippingMethod.name,
address address,
}); });
}) })
.then(({ order, checkout }) => ({ order, checkout, variantsList })); .then(({ order, checkout }) => ({ order, checkout, variantsList }));
@ -276,7 +276,7 @@ export function createOrderWithNewProduct({
export function addStripePaymentAndGetConfirmationData({ export function addStripePaymentAndGetConfirmationData({
card, card,
checkoutId, checkoutId,
amount amount,
}) { }) {
let paymentMethodId; let paymentMethodId;