Add e2e for capture transactions in orders (#3567)
* Update schema, remove transaction specific files * Merge `.transaction` queries and mutations into regular files * Merge OrderDetails fragments * Remove usage of `.transaction` graphl types * Update fixtures * Remove usage of useFlag, remove duplicated queries & mutations * Fix displayed event type for INFO * Remove type alias from order/types.ts, remove type casting * Fix failing tests * Add preview label and better description in Channel settings * Update button in GrantRefund page * Fix missing data-test-id * add e2e for capture transactions in orders * creates tests for transactions order view switched on --------- Co-authored-by: Jonatan Witoszek <jonatan.witoszek@saleor.io> Co-authored-by: wojteknowacki <wojciech.nowacki@saleor.io>
This commit is contained in:
parent
967d10f992
commit
70c7f3a2f8
27 changed files with 491 additions and 84 deletions
203
cypress/e2e/orders/transactionsForOrders.js
Normal file
203
cypress/e2e/orders/transactionsForOrders.js
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
/// <reference types="cypress"/>
|
||||||
|
/// <reference types="../../support"/>
|
||||||
|
|
||||||
|
import faker from "faker";
|
||||||
|
|
||||||
|
import { ORDERS_SELECTORS } from "../../elements/orders/orders-selectors";
|
||||||
|
import { ONE_PERMISSION_USERS, urlList } from "../../fixtures";
|
||||||
|
import {
|
||||||
|
createChannel,
|
||||||
|
createCustomer,
|
||||||
|
deleteCustomersStartsWith,
|
||||||
|
getOrder,
|
||||||
|
updateChannelOrderSettings,
|
||||||
|
} from "../../support/api/requests";
|
||||||
|
import {
|
||||||
|
createOrder,
|
||||||
|
createReadyToFulfillOrder,
|
||||||
|
createShipping,
|
||||||
|
deleteChannelsStartsWith,
|
||||||
|
deleteShippingStartsWith,
|
||||||
|
getDefaultTaxClass,
|
||||||
|
productsUtils,
|
||||||
|
updateTaxConfigurationForChannel,
|
||||||
|
} from "../../support/api/utils";
|
||||||
|
import { transactionsOrderUtils } from "../../support/pages/";
|
||||||
|
|
||||||
|
describe("Orders", () => {
|
||||||
|
const startsWith = "CyOrders-";
|
||||||
|
const randomName = startsWith + faker.datatype.number();
|
||||||
|
const randomRefNumber = startsWith + faker.datatype.number();
|
||||||
|
const randomPSPNumber = startsWith + faker.datatype.number();
|
||||||
|
|
||||||
|
let customer;
|
||||||
|
let channel;
|
||||||
|
let warehouse;
|
||||||
|
let shippingMethod;
|
||||||
|
let variantsList;
|
||||||
|
let address;
|
||||||
|
let taxClass;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest();
|
||||||
|
deleteChannelsStartsWith(startsWith);
|
||||||
|
deleteCustomersStartsWith(startsWith);
|
||||||
|
deleteShippingStartsWith(startsWith);
|
||||||
|
productsUtils.deleteProductsStartsWith(startsWith);
|
||||||
|
|
||||||
|
createChannel({ name: randomName })
|
||||||
|
.then(channelResp => {
|
||||||
|
channel = channelResp;
|
||||||
|
|
||||||
|
updateChannelOrderSettings({
|
||||||
|
channelId: channel.id,
|
||||||
|
markAsPaidStrategy: "TRANSACTION_FLOW",
|
||||||
|
});
|
||||||
|
updateTaxConfigurationForChannel({ channelSlug: channel.slug });
|
||||||
|
getDefaultTaxClass();
|
||||||
|
})
|
||||||
|
.then(resp => {
|
||||||
|
taxClass = resp;
|
||||||
|
cy.fixture("addresses");
|
||||||
|
})
|
||||||
|
.then(addresses => {
|
||||||
|
address = addresses.plAddress;
|
||||||
|
createCustomer(`${randomName}@example.com`, randomName, address, true);
|
||||||
|
})
|
||||||
|
.then(customerResp => {
|
||||||
|
customer = customerResp.user;
|
||||||
|
createShipping({
|
||||||
|
channelId: channel.id,
|
||||||
|
name: randomName,
|
||||||
|
address,
|
||||||
|
taxClassId: taxClass.id,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({ warehouse: warehouseResp, shippingMethod: shippingMethodResp }) => {
|
||||||
|
shippingMethod = shippingMethodResp;
|
||||||
|
warehouse = warehouseResp;
|
||||||
|
productsUtils.createTypeAttributeAndCategoryForProduct({
|
||||||
|
name: randomName,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
({
|
||||||
|
productType: productTypeResp,
|
||||||
|
attribute: attributeResp,
|
||||||
|
category: categoryResp,
|
||||||
|
}) => {
|
||||||
|
productsUtils.createProductInChannel({
|
||||||
|
name: randomName,
|
||||||
|
channelId: channel.id,
|
||||||
|
warehouseId: warehouse.id,
|
||||||
|
productTypeId: productTypeResp.id,
|
||||||
|
attributeId: attributeResp.id,
|
||||||
|
categoryId: categoryResp.id,
|
||||||
|
taxClassId: taxClass.id,
|
||||||
|
price: 10,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.then(({ variantsList: variantsResp }) => {
|
||||||
|
variantsList = variantsResp;
|
||||||
|
cy.checkIfDataAreNotNull({
|
||||||
|
customer,
|
||||||
|
channel,
|
||||||
|
warehouse,
|
||||||
|
shippingMethod,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.clearSessionData().loginUserViaRequest(
|
||||||
|
"auth",
|
||||||
|
ONE_PERMISSION_USERS.order,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should mark order as paid. TC: 3901",
|
||||||
|
{ tags: ["@orders", "@allEnv", "@stable"] },
|
||||||
|
() => {
|
||||||
|
createOrder({
|
||||||
|
customerId: customer.id,
|
||||||
|
shippingMethod,
|
||||||
|
channelId: channel.id,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
}).then(order => {
|
||||||
|
cy.visit(urlList.orders + `${order.id}`);
|
||||||
|
transactionsOrderUtils.markAsPaidOrderWithRefNumber(randomRefNumber);
|
||||||
|
cy.checkIfElementIsVisible(ORDERS_SELECTORS.orderTransactionsList);
|
||||||
|
getOrder(order.id).then(orderResp => {
|
||||||
|
expect(orderResp.paymentStatus).to.be.eq("FULLY_CHARGED");
|
||||||
|
expect(orderResp.transactions).to.be.not.null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should be able to grant and send refund TC: 3902",
|
||||||
|
{ tags: ["@orders", "@allEnv", "@stable"] },
|
||||||
|
() => {
|
||||||
|
createReadyToFulfillOrder({
|
||||||
|
customerId: customer.id,
|
||||||
|
shippingMethod,
|
||||||
|
channelId: channel.id,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
}).then(({ order: orderResp }) => {
|
||||||
|
const orderPrice = orderResp.total.gross.amount;
|
||||||
|
|
||||||
|
cy.visit(urlList.orders + `${orderResp.id}`);
|
||||||
|
cy.checkIfElementNotExist(ORDERS_SELECTORS.markAsPaidButton);
|
||||||
|
transactionsOrderUtils.grantRefundAllProductsAndShippingWithReason(
|
||||||
|
"refund reason: wrong size",
|
||||||
|
orderPrice,
|
||||||
|
);
|
||||||
|
transactionsOrderUtils.sendRefundWithDescriptionPSPAndAmount(
|
||||||
|
"refund description",
|
||||||
|
randomPSPNumber,
|
||||||
|
orderPrice,
|
||||||
|
);
|
||||||
|
getOrder(orderResp.id).then(orderResp => {
|
||||||
|
expect(orderResp.paymentStatus).to.be.eq("NOT_CHARGED");
|
||||||
|
expect(orderResp.transactions).to.be.not.null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
"should be able to capture manual transaction that covers partial order price TC: 3903",
|
||||||
|
{ tags: ["@orders", "@allEnv", "@stable"] },
|
||||||
|
() => {
|
||||||
|
createOrder({
|
||||||
|
customerId: customer.id,
|
||||||
|
shippingMethod,
|
||||||
|
channelId: channel.id,
|
||||||
|
variantsList,
|
||||||
|
address,
|
||||||
|
}).then(order => {
|
||||||
|
const partialOrderPrice = order.total.gross.amount - 1;
|
||||||
|
|
||||||
|
cy.visit(urlList.orders + `${order.id}`);
|
||||||
|
transactionsOrderUtils.captureManualTransaction(
|
||||||
|
"Manual capture description",
|
||||||
|
randomPSPNumber,
|
||||||
|
partialOrderPrice,
|
||||||
|
);
|
||||||
|
getOrder(order.id).then(orderResp => {
|
||||||
|
expect(orderResp.paymentStatus).to.be.eq("PARTIALLY_CHARGED");
|
||||||
|
expect(orderResp.transactions).to.be.not.null;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
|
@ -1,89 +1,51 @@
|
||||||
import {
|
export {
|
||||||
LOGIN_SELECTORS,
|
LOGIN_SELECTORS,
|
||||||
MENU_SELECTORS,
|
MENU_SELECTORS,
|
||||||
SET_PASSWORD_SELECTORS,
|
SET_PASSWORD_SELECTORS,
|
||||||
} from "./account/";
|
} from "./account/";
|
||||||
import { APPS_LIST_SELECTORS } from "./apps";
|
export { APPS_LIST_SELECTORS } from "./apps";
|
||||||
import { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST } from "./attribute";
|
export { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST } from "./attribute";
|
||||||
import {
|
export {
|
||||||
CATEGORIES_LIST_SELECTORS,
|
CATEGORIES_LIST_SELECTORS,
|
||||||
CATEGORY_DETAILS_SELECTORS,
|
CATEGORY_DETAILS_SELECTORS,
|
||||||
COLLECTION_SELECTORS,
|
COLLECTION_SELECTORS,
|
||||||
PRODUCT_DETAILS,
|
PRODUCT_DETAILS,
|
||||||
PRODUCTS_LIST,
|
PRODUCTS_LIST,
|
||||||
} from "./catalog";
|
} from "./catalog";
|
||||||
import { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS } from "./channels";
|
export { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS } from "./channels";
|
||||||
import { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
|
export { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
|
||||||
import {
|
export {
|
||||||
CUSTOMER_DETAILS_SELECTORS,
|
CUSTOMER_DETAILS_SELECTORS,
|
||||||
CUSTOMERS_LIST_SELECTORS,
|
CUSTOMERS_LIST_SELECTORS,
|
||||||
} from "./customer/";
|
} from "./customer/";
|
||||||
import { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
|
export { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
|
||||||
import { HOMEPAGE_SELECTORS } from "./homePage/homePage-selectors";
|
export { HOMEPAGE_SELECTORS } from "./homePage/homePage-selectors";
|
||||||
import { PAGINATION } from "./navigation";
|
export { PAGINATION } from "./navigation";
|
||||||
import { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS } from "./orders";
|
export {
|
||||||
import { PAGE_DETAILS_SELECTORS, PAGES_LIST_SELECTORS } from "./pages/";
|
DRAFT_ORDERS_LIST_SELECTORS,
|
||||||
import {
|
ORDER_GRANT_REFUND,
|
||||||
|
ORDER_TRANSACTION_CREATE,
|
||||||
|
ORDERS_SELECTORS,
|
||||||
|
} from "./orders";
|
||||||
|
export { PAGE_DETAILS_SELECTORS, PAGES_LIST_SELECTORS } from "./pages/";
|
||||||
|
export {
|
||||||
PAGE_TYPE_DETAILS_SELECTORS,
|
PAGE_TYPE_DETAILS_SELECTORS,
|
||||||
PAGE_TYPES_LIST_SELECTORS,
|
PAGE_TYPES_LIST_SELECTORS,
|
||||||
} from "./pageTypes";
|
} from "./pageTypes";
|
||||||
import {
|
export {
|
||||||
PERMISSION_GROUP_DETAILS_SELECTORS,
|
PERMISSION_GROUP_DETAILS_SELECTORS,
|
||||||
PERMISSION_GROUP_LIST_SELECTORS,
|
PERMISSION_GROUP_LIST_SELECTORS,
|
||||||
} from "./permissionGroup";
|
} from "./permissionGroup";
|
||||||
import { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS } from "./plugins";
|
export { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS } from "./plugins";
|
||||||
import {
|
export {
|
||||||
PRODUCT_TYPE_DETAILS_SELECTORS,
|
PRODUCT_TYPE_DETAILS_SELECTORS,
|
||||||
PRODUCT_TYPES_LIST_SELECTORS,
|
PRODUCT_TYPES_LIST_SELECTORS,
|
||||||
} from "./productTypes";
|
} from "./productTypes";
|
||||||
import { ADDRESS_SELECTORS, BUTTON_SELECTORS, SHARED_ELEMENTS } from "./shared";
|
export { ADDRESS_SELECTORS, BUTTON_SELECTORS, SHARED_ELEMENTS } from "./shared";
|
||||||
import { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping";
|
export { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping";
|
||||||
import {
|
export {
|
||||||
INVITE_STAFF_MEMBER_FORM_SELECTORS,
|
INVITE_STAFF_MEMBER_FORM_SELECTORS,
|
||||||
STAFF_MEMBER_DETAILS_SELECTORS,
|
STAFF_MEMBER_DETAILS_SELECTORS,
|
||||||
STAFF_MEMBERS_LIST_SELECTORS,
|
STAFF_MEMBERS_LIST_SELECTORS,
|
||||||
} from "./staffMembers";
|
} from "./staffMembers";
|
||||||
import { LANGUAGES_LIST_SELECTORS } from "./translations";
|
export { LANGUAGES_LIST_SELECTORS } from "./translations";
|
||||||
|
|
||||||
export {
|
|
||||||
ADDRESS_SELECTORS,
|
|
||||||
APPS_LIST_SELECTORS,
|
|
||||||
ATTRIBUTES_DETAILS,
|
|
||||||
ATTRIBUTES_LIST,
|
|
||||||
BUTTON_SELECTORS,
|
|
||||||
CATEGORIES_LIST_SELECTORS,
|
|
||||||
CATEGORY_DETAILS_SELECTORS,
|
|
||||||
CHANNEL_FORM_SELECTORS,
|
|
||||||
CHANNELS_SELECTORS,
|
|
||||||
COLLECTION_SELECTORS,
|
|
||||||
CONFIGURATION_SELECTORS,
|
|
||||||
CUSTOMER_DETAILS_SELECTORS,
|
|
||||||
CUSTOMERS_LIST_SELECTORS,
|
|
||||||
DRAFT_ORDERS_LIST_SELECTORS,
|
|
||||||
HOMEPAGE_SELECTORS,
|
|
||||||
INVITE_STAFF_MEMBER_FORM_SELECTORS,
|
|
||||||
LANGUAGES_LIST_SELECTORS,
|
|
||||||
LOGIN_SELECTORS,
|
|
||||||
MENU_SELECTORS,
|
|
||||||
ORDERS_SELECTORS,
|
|
||||||
PAGE_DETAILS_SELECTORS,
|
|
||||||
PAGE_TYPE_DETAILS_SELECTORS,
|
|
||||||
PAGE_TYPES_LIST_SELECTORS,
|
|
||||||
PAGES_LIST_SELECTORS,
|
|
||||||
PAGINATION,
|
|
||||||
PERMISSION_GROUP_DETAILS_SELECTORS,
|
|
||||||
PERMISSION_GROUP_LIST_SELECTORS,
|
|
||||||
PLUGINS_DETAILS_SELECTORS,
|
|
||||||
PLUGINS_LIST_SELECTORS,
|
|
||||||
PRODUCT_DETAILS,
|
|
||||||
PRODUCT_TYPE_DETAILS_SELECTORS,
|
|
||||||
PRODUCT_TYPES_LIST_SELECTORS,
|
|
||||||
PRODUCTS_LIST,
|
|
||||||
SALES_SELECTORS,
|
|
||||||
SET_PASSWORD_SELECTORS,
|
|
||||||
SHARED_ELEMENTS,
|
|
||||||
SHIPPING_ZONES_LIST_SELECTORS,
|
|
||||||
STAFF_MEMBER_DETAILS_SELECTORS,
|
|
||||||
STAFF_MEMBERS_LIST_SELECTORS,
|
|
||||||
VOUCHERS_SELECTORS,
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { DRAFT_ORDERS_LIST_SELECTORS } from "./draft-orders-list-selectors";
|
export { DRAFT_ORDERS_LIST_SELECTORS } from "./draft-orders-list-selectors";
|
||||||
import { ORDERS_SELECTORS } from "./orders-selectors";
|
export { ORDER_GRANT_REFUND } from "./order-grant-refund";
|
||||||
|
export { ORDERS_SELECTORS } from "./orders-selectors";
|
||||||
export { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS };
|
export { ORDER_TRANSACTION_CREATE } from "./transaction-selectors";
|
||||||
|
|
9
cypress/elements/orders/order-grant-refund.js
Normal file
9
cypress/elements/orders/order-grant-refund.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export const ORDER_GRANT_REFUND = {
|
||||||
|
productsQuantityInput: '[data-test-id*="quantity-input"]',
|
||||||
|
setMaxQuantityButton: '[data-test-id="setMaxQuantityButton"]',
|
||||||
|
refundReasonInput: '[data-test-id="refundReasonInput"]',
|
||||||
|
refundShippingCheckbox: '[data-test-id="refundShippingCheckbox"]',
|
||||||
|
applySelectedRefundButton: '[data-test-id="applySelectedRefundButton"]',
|
||||||
|
refundAmountInput: '[data-test-id="amountInput"]',
|
||||||
|
grantRefundButton: '[data-test-id="grantRefundButton"]',
|
||||||
|
};
|
|
@ -9,4 +9,10 @@ export const ORDERS_SELECTORS = {
|
||||||
orderFulfillmentFrame: "[data-test-id='order-fulfillment']",
|
orderFulfillmentFrame: "[data-test-id='order-fulfillment']",
|
||||||
refundButton: '[data-test-id="refund-button"]',
|
refundButton: '[data-test-id="refund-button"]',
|
||||||
fulfillMenuButton: '[data-test-id="fulfill-menu"]',
|
fulfillMenuButton: '[data-test-id="fulfill-menu"]',
|
||||||
|
markAsPaidButton: '[data-test-id="markAsPaidButton"]',
|
||||||
|
transactionReferenceInput: '[data-test-id="transaction-reference-input"]',
|
||||||
|
orderTransactionsList: '[data-test-id="orderTransactionsList"]',
|
||||||
|
grantRefundButton: '[data-test-id="grantRefundButton"]',
|
||||||
|
captureManualTransactionButton:
|
||||||
|
'[data-test-id="captureManualTransactionButton"]',
|
||||||
};
|
};
|
||||||
|
|
6
cypress/elements/orders/transaction-selectors.js
Normal file
6
cypress/elements/orders/transaction-selectors.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export const ORDER_TRANSACTION_CREATE = {
|
||||||
|
transactionDescription: '[data-test-id="transactionDescription"]',
|
||||||
|
transactionPspReference: '[data-test-id="transactionPspReference"]',
|
||||||
|
transactAmountInput: '[data-test-id="transactAmountInput"]',
|
||||||
|
manualTransactionSubmit: '[data-test-id="manualTransactionSubmit"]',
|
||||||
|
};
|
|
@ -1,5 +1,4 @@
|
||||||
import { bodyMockHomePage } from "./bodyMocks";
|
export { bodyMockHomePage } from "./bodyMocks";
|
||||||
import { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
|
export { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
|
||||||
import { urlList } from "./urlList";
|
export { urlList } from "./urlList";
|
||||||
|
export { ONE_PERMISSION_USERS } from "./users";
|
||||||
export { bodyMockHomePage, orderDraftCreateDemoResponse, urlList };
|
|
||||||
|
|
|
@ -83,3 +83,37 @@ export function updateChannelWarehouses(channelId, warehouseId) {
|
||||||
}`;
|
}`;
|
||||||
return cy.sendRequestWithQuery(mutation);
|
return cy.sendRequestWithQuery(mutation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateChannelOrderSettings({
|
||||||
|
channelId,
|
||||||
|
automaticallyConfirmAllNewOrders = true,
|
||||||
|
automaticallyFulfillNonShippableGiftCard = true,
|
||||||
|
expireOrdersAfter = 0,
|
||||||
|
markAsPaidStrategy = "PAYMENT_FLOW", // TRANSACTION_FLOW - creates the TransactionItem object.
|
||||||
|
defaultTransactionFlowStrategy = "AUTHORIZATION",
|
||||||
|
}) {
|
||||||
|
const mutation = `mutation{
|
||||||
|
channelUpdate(id:"${channelId}", input: {orderSettings: {
|
||||||
|
automaticallyConfirmAllNewOrders: ${automaticallyConfirmAllNewOrders},
|
||||||
|
automaticallyFulfillNonShippableGiftCard: ${automaticallyFulfillNonShippableGiftCard},
|
||||||
|
expireOrdersAfter: ${expireOrdersAfter},
|
||||||
|
markAsPaidStrategy: ${markAsPaidStrategy},
|
||||||
|
defaultTransactionFlowStrategy: ${defaultTransactionFlowStrategy}
|
||||||
|
}}){
|
||||||
|
errors{
|
||||||
|
field
|
||||||
|
message
|
||||||
|
}
|
||||||
|
channel {
|
||||||
|
orderSettings{
|
||||||
|
automaticallyConfirmAllNewOrders
|
||||||
|
automaticallyFulfillNonShippableGiftCard
|
||||||
|
expireOrdersAfter
|
||||||
|
markAsPaidStrategy
|
||||||
|
defaultTransactionFlowStrategy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return cy.sendRequestWithQuery(mutation);
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,12 @@ export function markOrderAsPaid(orderId) {
|
||||||
lines{
|
lines{
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
total{
|
||||||
|
gross{
|
||||||
|
amount
|
||||||
|
currency
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
@ -94,6 +100,12 @@ export function completeOrder(orderId) {
|
||||||
lines{
|
lines{
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
total{
|
||||||
|
gross{
|
||||||
|
amount
|
||||||
|
currency
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
errors{
|
errors{
|
||||||
message
|
message
|
||||||
|
@ -111,6 +123,9 @@ export function getOrder(orderId) {
|
||||||
token
|
token
|
||||||
paymentStatus
|
paymentStatus
|
||||||
isShippingRequired
|
isShippingRequired
|
||||||
|
transactions{
|
||||||
|
id
|
||||||
|
}
|
||||||
shippingMethod{
|
shippingMethod{
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -142,7 +157,7 @@ export function getOrder(orderId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
cy.sendRequestWithQuery(query).its("body.data.order");
|
return cy.sendRequestWithQuery(query).its("body.data.order");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fulfillOrder({ orderId, warehouse, quantity, linesId }) {
|
export function fulfillOrder({ orderId, warehouse, quantity, linesId }) {
|
||||||
|
|
3
cypress/support/api/requests/index.js
Normal file
3
cypress/support/api/requests/index.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export { createChannel, updateChannelOrderSettings } from "./Channels";
|
||||||
|
export { createCustomer, deleteCustomersStartsWith } from "./Customer";
|
||||||
|
export { getOrder } from "./Order";
|
8
cypress/support/api/utils/index.js
Normal file
8
cypress/support/api/utils/index.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
export { deleteChannelsStartsWith } from "./channelsUtils";
|
||||||
|
export { createOrder, createReadyToFulfillOrder } from "./ordersUtils";
|
||||||
|
export { createShipping, deleteShippingStartsWith } from "./shippingUtils";
|
||||||
|
export {
|
||||||
|
getDefaultTaxClass,
|
||||||
|
updateTaxConfigurationForChannel,
|
||||||
|
} from "./taxesUtils";
|
||||||
|
export * as productsUtils from "./products/productsUtils";
|
|
@ -200,7 +200,7 @@ export function createOrder({
|
||||||
orderRequest.addShippingMethod(order.id, shippingMethod);
|
orderRequest.addShippingMethod(order.id, shippingMethod);
|
||||||
})
|
})
|
||||||
.then(() => orderRequest.completeOrder(order.id))
|
.then(() => orderRequest.completeOrder(order.id))
|
||||||
.then(() => order);
|
.then(resp => (order = resp.order));
|
||||||
}
|
}
|
||||||
|
|
||||||
function assignVariantsToOrder(order, variantsList) {
|
function assignVariantsToOrder(order, variantsList) {
|
||||||
|
|
|
@ -50,6 +50,15 @@ Cypress.Commands.add("checkIfDataAreNotNull", data => {
|
||||||
Cypress.Commands.add("checkIfElementIsVisible", element => {
|
Cypress.Commands.add("checkIfElementIsVisible", element => {
|
||||||
cy.get(element).should("be.visible");
|
cy.get(element).should("be.visible");
|
||||||
});
|
});
|
||||||
|
Cypress.Commands.add("checkIfElementIsNotVisible", element => {
|
||||||
|
cy.get(element).should("not.be.visible");
|
||||||
|
});
|
||||||
|
Cypress.Commands.add("checkIfElementExist", element => {
|
||||||
|
cy.get(element).should("exist");
|
||||||
|
});
|
||||||
|
Cypress.Commands.add("checkIfElementNotExist", element => {
|
||||||
|
cy.get(element).should("not.exist");
|
||||||
|
});
|
||||||
Cypress.Commands.add("assertCanvasRowsNumber", (canvas, rowNumber) => {
|
Cypress.Commands.add("assertCanvasRowsNumber", (canvas, rowNumber) => {
|
||||||
cy.get(canvas).find("tr").should("have.length", rowNumber);
|
cy.get(canvas).find("tr").should("have.length", rowNumber);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
import * as ordersOperationsHelpers from "./ordersOperations";
|
export * as ordersOperationsHelpers from "./ordersOperations";
|
||||||
|
export * as transactionsOrderUtils from "./ordersTransactionUtils";
|
||||||
export { ordersOperationsHelpers };
|
|
||||||
|
|
111
cypress/support/pages/ordersTransactionUtils.js
Normal file
111
cypress/support/pages/ordersTransactionUtils.js
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
import {
|
||||||
|
BUTTON_SELECTORS,
|
||||||
|
ORDER_GRANT_REFUND,
|
||||||
|
ORDER_TRANSACTION_CREATE,
|
||||||
|
ORDERS_SELECTORS,
|
||||||
|
} from "../../elements";
|
||||||
|
|
||||||
|
export function markAsPaidOrderWithRefNumber(transactionNumber) {
|
||||||
|
cy.addAliasToGraphRequest("OrderMarkAsPaid");
|
||||||
|
clickMarkAsPaidButton();
|
||||||
|
typeTransactionReference(`ref_${transactionNumber}`);
|
||||||
|
clickConfirmMarkAsPaidButton().waitForRequestAndCheckIfNoErrors(
|
||||||
|
"@OrderMarkAsPaid",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
export function captureManualTransaction(
|
||||||
|
transactionDescription,
|
||||||
|
transactionPSPReference,
|
||||||
|
amount,
|
||||||
|
) {
|
||||||
|
clickCaptureManualTransactionButton();
|
||||||
|
typeTransactionDescription(`desc_${transactionDescription}`);
|
||||||
|
typeTransactionPSPReference(`psp_${transactionPSPReference}`);
|
||||||
|
typeRefundTotalAmount(amount);
|
||||||
|
clickCreateManualTransactionButton().confirmationMessageShouldAppear();
|
||||||
|
}
|
||||||
|
export function grantRefundAllProductsAndShippingWithReason(
|
||||||
|
refundReason,
|
||||||
|
total,
|
||||||
|
) {
|
||||||
|
cy.addAliasToGraphRequest("OrderDetailsGrantRefund");
|
||||||
|
clickGrantRefundButton();
|
||||||
|
cy.waitForRequestAndCheckIfNoErrors("@OrderDetailsGrantRefund");
|
||||||
|
clickMaxQuantityButton();
|
||||||
|
typeRefundReason(refundReason);
|
||||||
|
clickRefundShippingCheckbox();
|
||||||
|
clickApplyRefundButton();
|
||||||
|
cy.get(ORDER_GRANT_REFUND.refundAmountInput).should("contain.value", total);
|
||||||
|
clickConfirmRefundButton();
|
||||||
|
cy.confirmationMessageShouldAppear();
|
||||||
|
}
|
||||||
|
export function sendRefundWithDescriptionPSPAndAmount(
|
||||||
|
transactionDescription,
|
||||||
|
transactionPSPReference,
|
||||||
|
amount,
|
||||||
|
) {
|
||||||
|
clickSendRefundButton();
|
||||||
|
typeTransactionDescription(`desc_${transactionDescription}`);
|
||||||
|
typeTransactionPSPReference(`psp_${transactionPSPReference}`);
|
||||||
|
typeRefundTotalAmount(amount);
|
||||||
|
cy.addAliasToGraphRequest("CreateManualTransactionRefund");
|
||||||
|
clickRefundSubmitButton();
|
||||||
|
cy.waitForRequestAndCheckIfNoErrors(
|
||||||
|
"@CreateManualTransactionRefund",
|
||||||
|
).confirmationMessageShouldAppear();
|
||||||
|
}
|
||||||
|
export function clickMarkAsPaidButton() {
|
||||||
|
return cy.clickOnElement(ORDERS_SELECTORS.markAsPaidButton);
|
||||||
|
}
|
||||||
|
export function clickRefundSubmitButton() {
|
||||||
|
return cy.clickOnElement(ORDER_TRANSACTION_CREATE.manualTransactionSubmit);
|
||||||
|
}
|
||||||
|
export function clickCreateManualTransactionButton() {
|
||||||
|
return cy.clickOnElement(ORDER_TRANSACTION_CREATE.manualTransactionSubmit);
|
||||||
|
}
|
||||||
|
export function clickMaxQuantityButton() {
|
||||||
|
return cy.clickOnElement(ORDER_GRANT_REFUND.setMaxQuantityButton);
|
||||||
|
}
|
||||||
|
export function clickCaptureManualTransactionButton() {
|
||||||
|
return cy.clickOnElement(ORDERS_SELECTORS.captureManualTransactionButton);
|
||||||
|
}
|
||||||
|
export function typeRefundReason(refundReasonDescription) {
|
||||||
|
return cy
|
||||||
|
.get(ORDER_GRANT_REFUND.refundReasonInput)
|
||||||
|
.type(`reason_${refundReasonDescription}`);
|
||||||
|
}
|
||||||
|
export function typeRefundTotalAmount(amount) {
|
||||||
|
return cy.get(ORDER_TRANSACTION_CREATE.transactAmountInput).type(amount);
|
||||||
|
}
|
||||||
|
export function typeTransactionReference(reference) {
|
||||||
|
return cy.get(ORDERS_SELECTORS.transactionReferenceInput).type(reference);
|
||||||
|
}
|
||||||
|
export function typeTransactionDescription(transactionDescription) {
|
||||||
|
return cy
|
||||||
|
.get(ORDER_TRANSACTION_CREATE.transactionDescription)
|
||||||
|
.type(`desc_${transactionDescription}`);
|
||||||
|
}
|
||||||
|
export function typeTransactionPSPReference(transactionPSPReference) {
|
||||||
|
return cy
|
||||||
|
.get(ORDER_TRANSACTION_CREATE.transactionPspReference)
|
||||||
|
.type(`psp_${transactionPSPReference}`);
|
||||||
|
}
|
||||||
|
export function clickGrantRefundButton() {
|
||||||
|
return cy.clickOnElement(ORDERS_SELECTORS.grantRefundButton);
|
||||||
|
}
|
||||||
|
export function clickSendRefundButton() {
|
||||||
|
return cy.clickOnElement(ORDERS_SELECTORS.refundButton);
|
||||||
|
}
|
||||||
|
export function clickRefundShippingCheckbox() {
|
||||||
|
return cy.clickOnElement(ORDER_GRANT_REFUND.refundShippingCheckbox);
|
||||||
|
}
|
||||||
|
export function clickApplyRefundButton() {
|
||||||
|
return cy.clickOnElement(ORDER_GRANT_REFUND.applySelectedRefundButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clickConfirmRefundButton() {
|
||||||
|
return cy.clickOnElement(ORDER_GRANT_REFUND.grantRefundButton);
|
||||||
|
}
|
||||||
|
export function clickConfirmMarkAsPaidButton() {
|
||||||
|
return cy.clickOnElement(BUTTON_SELECTORS.submit);
|
||||||
|
}
|
|
@ -40,7 +40,11 @@ const OrderAddTransaction: React.FC<OrderAddTransactionProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.wrapper}>
|
<div className={classes.wrapper}>
|
||||||
<Button variant="primary" onClick={onAddTransaction}>
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
onClick={onAddTransaction}
|
||||||
|
data-test-id="captureManualTransactionButton"
|
||||||
|
>
|
||||||
<FormattedMessage {...addTransactionMessages.captureTransaction} />
|
<FormattedMessage {...addTransactionMessages.captureTransaction} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -155,6 +155,11 @@ const OrderGrantRefundPage: React.FC<OrderGrantRefundPageProps> = ({
|
||||||
name={"reason" as keyof OrderGrantRefundFormData}
|
name={"reason" as keyof OrderGrantRefundFormData}
|
||||||
onChange={change}
|
onChange={change}
|
||||||
type="text"
|
type="text"
|
||||||
|
InputProps={{
|
||||||
|
inputProps: {
|
||||||
|
"data-test-id": "refundReasonInput",
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
@ -67,7 +67,11 @@ export const ProductsCard: React.FC<ProductsCardProps> = ({
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
toolbar={
|
toolbar={
|
||||||
<Button variant="secondary" onClick={handleSetMaxQuanity}>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={handleSetMaxQuanity}
|
||||||
|
data-test-id="setMaxQuantityButton"
|
||||||
|
>
|
||||||
<FormattedMessage {...grantRefundPageMessages.setMaxQuantity} />
|
<FormattedMessage {...grantRefundPageMessages.setMaxQuantity} />
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ export const RefundCard = ({
|
||||||
id={`checkbox-${id}`}
|
id={`checkbox-${id}`}
|
||||||
value={state.refundShipping}
|
value={state.refundShipping}
|
||||||
onChange={() => dispatch({ type: "toggleRefundShipping" })}
|
onChange={() => dispatch({ type: "toggleRefundShipping" })}
|
||||||
|
data-test-id="refundShippingCheckbox"
|
||||||
/>
|
/>
|
||||||
<label htmlFor={`checkbox-${id}`}>
|
<label htmlFor={`checkbox-${id}`}>
|
||||||
{!currency ? (
|
{!currency ? (
|
||||||
|
@ -104,6 +105,7 @@ export const RefundCard = ({
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => form.set({ amount: totalSelectedPrice.toString() })}
|
onClick={() => form.set({ amount: totalSelectedPrice.toString() })}
|
||||||
|
data-test-id="applySelectedRefundButton"
|
||||||
>
|
>
|
||||||
<FormattedMessage {...buttonMessages.apply} />
|
<FormattedMessage {...buttonMessages.apply} />
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -131,6 +133,7 @@ export const RefundCard = ({
|
||||||
transitionState={submitState}
|
transitionState={submitState}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
data-test-id="grantRefundButton"
|
||||||
>
|
>
|
||||||
{isEdit ? (
|
{isEdit ? (
|
||||||
<FormattedMessage {...grantRefundPageMessages.editRefundBtn} />
|
<FormattedMessage {...grantRefundPageMessages.editRefundBtn} />
|
||||||
|
|
|
@ -16,7 +16,11 @@ export const DescriptionField: React.FC<
|
||||||
disabled={submitState === "loading" || disabled}
|
disabled={submitState === "loading" || disabled}
|
||||||
onChange={handleChangeDescription}
|
onChange={handleChangeDescription}
|
||||||
value={description}
|
value={description}
|
||||||
inputProps={{ ...props.inputProps, maxLength: 512 }}
|
inputProps={{
|
||||||
|
...props.inputProps,
|
||||||
|
maxLength: 512,
|
||||||
|
"data-test-id": "transactionDescription",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,11 @@ export const PriceInputField: React.FC<
|
||||||
disabled={submitState === "loading" || disabled}
|
disabled={submitState === "loading" || disabled}
|
||||||
onChange={handleChangeAmount}
|
onChange={handleChangeAmount}
|
||||||
value={amount?.toString() ?? ""}
|
value={amount?.toString() ?? ""}
|
||||||
|
InputProps={{
|
||||||
|
inputProps: {
|
||||||
|
"data-test-id": "transactAmountInput",
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,11 @@ export const PspReferenceField: React.FC<
|
||||||
disabled={submitState === "loading" || disabled}
|
disabled={submitState === "loading" || disabled}
|
||||||
onChange={handleChangePspReference}
|
onChange={handleChangePspReference}
|
||||||
value={pspReference}
|
value={pspReference}
|
||||||
inputProps={{ ...props.inputProps, maxLength: 512 }}
|
inputProps={{
|
||||||
|
...props.inputProps,
|
||||||
|
maxLength: 512,
|
||||||
|
"data-test-id": "transactionPspReference",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@ export const SubmitButton: React.FC<
|
||||||
type="submit"
|
type="submit"
|
||||||
transitionState={submitState}
|
transitionState={submitState}
|
||||||
disabled={!amount || disabled}
|
disabled={!amount || disabled}
|
||||||
|
data-test-id="manualTransactionSubmit"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,6 +63,7 @@ const OrderMarkAsPaidDialog: React.FC<OrderMarkAsPaidDialogProps> = ({
|
||||||
})}
|
})}
|
||||||
value={transactionReference}
|
value={transactionReference}
|
||||||
onChange={handleTransactionReference}
|
onChange={handleTransactionReference}
|
||||||
|
data-test-id="transaction-reference-input"
|
||||||
/>
|
/>
|
||||||
{errors.length > 0 && (
|
{errors.length > 0 && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -105,7 +105,11 @@ const OrderPayment: React.FC<OrderPaymentProps> = props => {
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{canMarkAsPaid && (
|
{canMarkAsPaid && (
|
||||||
<Button variant="tertiary" onClick={onMarkAsPaid}>
|
<Button
|
||||||
|
variant="tertiary"
|
||||||
|
onClick={onMarkAsPaid}
|
||||||
|
data-test-id="markAsPaidButton"
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
{...paymentButtonMessages.markAsPaid}
|
{...paymentButtonMessages.markAsPaid}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -83,7 +83,11 @@ const OrderPaymentSummaryCard: React.FC<OrderPaymementProps> = ({
|
||||||
<FormattedMessage {...orderPaymentMessages.noPayments} />
|
<FormattedMessage {...orderPaymentMessages.noPayments} />
|
||||||
</Typography>
|
</Typography>
|
||||||
{canMarkAsPaid && (
|
{canMarkAsPaid && (
|
||||||
<Button variant="tertiary" onClick={() => onMarkAsPaid()}>
|
<Button
|
||||||
|
variant="tertiary"
|
||||||
|
onClick={() => onMarkAsPaid()}
|
||||||
|
data-test-id="markAsPaidButton"
|
||||||
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
{...orderPaymentActionButtonMessages.markAsPaid}
|
{...orderPaymentActionButtonMessages.markAsPaid}
|
||||||
/>
|
/>
|
||||||
|
@ -102,6 +106,7 @@ const OrderPaymentSummaryCard: React.FC<OrderPaymementProps> = ({
|
||||||
<Button
|
<Button
|
||||||
href={orderGrantRefundUrl(order.id)}
|
href={orderGrantRefundUrl(order.id)}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
|
data-test-id="grantRefundButton"
|
||||||
>
|
>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
{...orderPaymentActionButtonMessages.grantRefund}
|
{...orderPaymentActionButtonMessages.grantRefund}
|
||||||
|
|
|
@ -41,7 +41,10 @@ const OrderTransaction: React.FC<OrderTransactionProps> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={clsx(classes.card, disabled && classes.disabled)}>
|
<Card
|
||||||
|
className={clsx(classes.card, disabled && classes.disabled)}
|
||||||
|
data-test-id="orderTransactionsList"
|
||||||
|
>
|
||||||
<CardTitle
|
<CardTitle
|
||||||
transaction={transaction}
|
transaction={transaction}
|
||||||
onTransactionAction={onTransactionAction}
|
onTransactionAction={onTransactionAction}
|
||||||
|
|
Loading…
Reference in a new issue