diff --git a/cypress/e2e/orders/transactionsForOrders.js b/cypress/e2e/orders/transactionsForOrders.js
new file mode 100644
index 000000000..a14f941c9
--- /dev/null
+++ b/cypress/e2e/orders/transactionsForOrders.js
@@ -0,0 +1,203 @@
+///
+///
+
+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;
+ });
+ });
+ },
+ );
+});
diff --git a/cypress/elements/index.js b/cypress/elements/index.js
index 26b12f042..011dcf98a 100644
--- a/cypress/elements/index.js
+++ b/cypress/elements/index.js
@@ -1,89 +1,51 @@
-import {
+export {
LOGIN_SELECTORS,
MENU_SELECTORS,
SET_PASSWORD_SELECTORS,
} from "./account/";
-import { APPS_LIST_SELECTORS } from "./apps";
-import { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST } from "./attribute";
-import {
+export { APPS_LIST_SELECTORS } from "./apps";
+export { ATTRIBUTES_DETAILS, ATTRIBUTES_LIST } from "./attribute";
+export {
CATEGORIES_LIST_SELECTORS,
CATEGORY_DETAILS_SELECTORS,
COLLECTION_SELECTORS,
PRODUCT_DETAILS,
PRODUCTS_LIST,
} from "./catalog";
-import { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS } from "./channels";
-import { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
-import {
+export { CHANNEL_FORM_SELECTORS, CHANNELS_SELECTORS } from "./channels";
+export { CONFIGURATION_SELECTORS } from "./configuration/configuration-selectors";
+export {
CUSTOMER_DETAILS_SELECTORS,
CUSTOMERS_LIST_SELECTORS,
} from "./customer/";
-import { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
-import { HOMEPAGE_SELECTORS } from "./homePage/homePage-selectors";
-import { PAGINATION } from "./navigation";
-import { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS } from "./orders";
-import { PAGE_DETAILS_SELECTORS, PAGES_LIST_SELECTORS } from "./pages/";
-import {
+export { SALES_SELECTORS, VOUCHERS_SELECTORS } from "./discounts";
+export { HOMEPAGE_SELECTORS } from "./homePage/homePage-selectors";
+export { PAGINATION } from "./navigation";
+export {
+ DRAFT_ORDERS_LIST_SELECTORS,
+ 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_TYPES_LIST_SELECTORS,
} from "./pageTypes";
-import {
+export {
PERMISSION_GROUP_DETAILS_SELECTORS,
PERMISSION_GROUP_LIST_SELECTORS,
} from "./permissionGroup";
-import { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS } from "./plugins";
-import {
+export { PLUGINS_DETAILS_SELECTORS, PLUGINS_LIST_SELECTORS } from "./plugins";
+export {
PRODUCT_TYPE_DETAILS_SELECTORS,
PRODUCT_TYPES_LIST_SELECTORS,
} from "./productTypes";
-import { ADDRESS_SELECTORS, BUTTON_SELECTORS, SHARED_ELEMENTS } from "./shared";
-import { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping";
-import {
+export { ADDRESS_SELECTORS, BUTTON_SELECTORS, SHARED_ELEMENTS } from "./shared";
+export { SHIPPING_ZONES_LIST_SELECTORS } from "./shipping";
+export {
INVITE_STAFF_MEMBER_FORM_SELECTORS,
STAFF_MEMBER_DETAILS_SELECTORS,
STAFF_MEMBERS_LIST_SELECTORS,
} from "./staffMembers";
-import { 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,
-};
+export { LANGUAGES_LIST_SELECTORS } from "./translations";
diff --git a/cypress/elements/orders/index.js b/cypress/elements/orders/index.js
index 7aac0d0c1..42437d813 100644
--- a/cypress/elements/orders/index.js
+++ b/cypress/elements/orders/index.js
@@ -1,4 +1,4 @@
-import { DRAFT_ORDERS_LIST_SELECTORS } from "./draft-orders-list-selectors";
-import { ORDERS_SELECTORS } from "./orders-selectors";
-
-export { DRAFT_ORDERS_LIST_SELECTORS, ORDERS_SELECTORS };
+export { DRAFT_ORDERS_LIST_SELECTORS } from "./draft-orders-list-selectors";
+export { ORDER_GRANT_REFUND } from "./order-grant-refund";
+export { ORDERS_SELECTORS } from "./orders-selectors";
+export { ORDER_TRANSACTION_CREATE } from "./transaction-selectors";
diff --git a/cypress/elements/orders/order-grant-refund.js b/cypress/elements/orders/order-grant-refund.js
new file mode 100644
index 000000000..cdad8ddbc
--- /dev/null
+++ b/cypress/elements/orders/order-grant-refund.js
@@ -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"]',
+};
diff --git a/cypress/elements/orders/orders-selectors.js b/cypress/elements/orders/orders-selectors.js
index e9309c376..8c1c63b6a 100644
--- a/cypress/elements/orders/orders-selectors.js
+++ b/cypress/elements/orders/orders-selectors.js
@@ -9,4 +9,10 @@ export const ORDERS_SELECTORS = {
orderFulfillmentFrame: "[data-test-id='order-fulfillment']",
refundButton: '[data-test-id="refund-button"]',
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"]',
};
diff --git a/cypress/elements/orders/transaction-selectors.js b/cypress/elements/orders/transaction-selectors.js
new file mode 100644
index 000000000..ade51a6d1
--- /dev/null
+++ b/cypress/elements/orders/transaction-selectors.js
@@ -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"]',
+};
diff --git a/cypress/fixtures/index.js b/cypress/fixtures/index.js
index c076821af..9e7b92b82 100644
--- a/cypress/fixtures/index.js
+++ b/cypress/fixtures/index.js
@@ -1,5 +1,4 @@
-import { bodyMockHomePage } from "./bodyMocks";
-import { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
-import { urlList } from "./urlList";
-
-export { bodyMockHomePage, orderDraftCreateDemoResponse, urlList };
+export { bodyMockHomePage } from "./bodyMocks";
+export { orderDraftCreateDemoResponse } from "./errors/demo/orderDratCreate";
+export { urlList } from "./urlList";
+export { ONE_PERMISSION_USERS } from "./users";
diff --git a/cypress/support/api/requests/Channels.js b/cypress/support/api/requests/Channels.js
index 0ab58e0ab..7474f17ab 100644
--- a/cypress/support/api/requests/Channels.js
+++ b/cypress/support/api/requests/Channels.js
@@ -83,3 +83,37 @@ export function updateChannelWarehouses(channelId, warehouseId) {
}`;
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);
+}
diff --git a/cypress/support/api/requests/Order.js b/cypress/support/api/requests/Order.js
index 0bdf33afe..29eccb13c 100644
--- a/cypress/support/api/requests/Order.js
+++ b/cypress/support/api/requests/Order.js
@@ -12,6 +12,12 @@ export function markOrderAsPaid(orderId) {
lines{
id
}
+ total{
+ gross{
+ amount
+ currency
+ }
+ }
}
}
}`;
@@ -94,6 +100,12 @@ export function completeOrder(orderId) {
lines{
id
}
+ total{
+ gross{
+ amount
+ currency
+ }
+ }
}
errors{
message
@@ -111,6 +123,9 @@ export function getOrder(orderId) {
token
paymentStatus
isShippingRequired
+ transactions{
+ id
+ }
shippingMethod{
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 }) {
diff --git a/cypress/support/api/requests/index.js b/cypress/support/api/requests/index.js
new file mode 100644
index 000000000..24158d763
--- /dev/null
+++ b/cypress/support/api/requests/index.js
@@ -0,0 +1,3 @@
+export { createChannel, updateChannelOrderSettings } from "./Channels";
+export { createCustomer, deleteCustomersStartsWith } from "./Customer";
+export { getOrder } from "./Order";
diff --git a/cypress/support/api/utils/index.js b/cypress/support/api/utils/index.js
new file mode 100644
index 000000000..895b484e6
--- /dev/null
+++ b/cypress/support/api/utils/index.js
@@ -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";
diff --git a/cypress/support/api/utils/ordersUtils.js b/cypress/support/api/utils/ordersUtils.js
index 9b9376bfd..72f70ede9 100644
--- a/cypress/support/api/utils/ordersUtils.js
+++ b/cypress/support/api/utils/ordersUtils.js
@@ -200,7 +200,7 @@ export function createOrder({
orderRequest.addShippingMethod(order.id, shippingMethod);
})
.then(() => orderRequest.completeOrder(order.id))
- .then(() => order);
+ .then(resp => (order = resp.order));
}
function assignVariantsToOrder(order, variantsList) {
diff --git a/cypress/support/customCommands/basicOperations/index.js b/cypress/support/customCommands/basicOperations/index.js
index 90707baa1..d8e409d61 100644
--- a/cypress/support/customCommands/basicOperations/index.js
+++ b/cypress/support/customCommands/basicOperations/index.js
@@ -50,6 +50,15 @@ Cypress.Commands.add("checkIfDataAreNotNull", data => {
Cypress.Commands.add("checkIfElementIsVisible", element => {
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) => {
cy.get(canvas).find("tr").should("have.length", rowNumber);
});
diff --git a/cypress/support/pages/index.js b/cypress/support/pages/index.js
index 8abecf811..ca27ae561 100644
--- a/cypress/support/pages/index.js
+++ b/cypress/support/pages/index.js
@@ -1,3 +1,2 @@
-import * as ordersOperationsHelpers from "./ordersOperations";
-
-export { ordersOperationsHelpers };
+export * as ordersOperationsHelpers from "./ordersOperations";
+export * as transactionsOrderUtils from "./ordersTransactionUtils";
diff --git a/cypress/support/pages/ordersTransactionUtils.js b/cypress/support/pages/ordersTransactionUtils.js
new file mode 100644
index 000000000..fd6c262fe
--- /dev/null
+++ b/cypress/support/pages/ordersTransactionUtils.js
@@ -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);
+}
diff --git a/src/orders/components/OrderAddTransaction/OrderAddTransaction.tsx b/src/orders/components/OrderAddTransaction/OrderAddTransaction.tsx
index 8ce597110..1656377b9 100644
--- a/src/orders/components/OrderAddTransaction/OrderAddTransaction.tsx
+++ b/src/orders/components/OrderAddTransaction/OrderAddTransaction.tsx
@@ -40,7 +40,11 @@ const OrderAddTransaction: React.FC = ({
return (
-
diff --git a/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx b/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx
index 56a4a044d..5389c50b3 100644
--- a/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx
+++ b/src/orders/components/OrderGrantRefundPage/OrderGrantRefundPage.tsx
@@ -155,6 +155,11 @@ const OrderGrantRefundPage: React.FC = ({
name={"reason" as keyof OrderGrantRefundFormData}
onChange={change}
type="text"
+ InputProps={{
+ inputProps: {
+ "data-test-id": "refundReasonInput",
+ },
+ }}
/>
diff --git a/src/orders/components/OrderGrantRefundPage/components/ProductCard.tsx b/src/orders/components/OrderGrantRefundPage/components/ProductCard.tsx
index 7356a5f59..1de180324 100644
--- a/src/orders/components/OrderGrantRefundPage/components/ProductCard.tsx
+++ b/src/orders/components/OrderGrantRefundPage/components/ProductCard.tsx
@@ -67,7 +67,11 @@ export const ProductsCard: React.FC = ({
>
}
toolbar={
-
+
}
diff --git a/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx b/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx
index fdbeeadc2..b25928cc2 100644
--- a/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx
+++ b/src/orders/components/OrderGrantRefundPage/components/RefundCard.tsx
@@ -59,6 +59,7 @@ export const RefundCard = ({
id={`checkbox-${id}`}
value={state.refundShipping}
onChange={() => dispatch({ type: "toggleRefundShipping" })}
+ data-test-id="refundShippingCheckbox"
/>
@@ -131,6 +133,7 @@ export const RefundCard = ({
transitionState={submitState}
variant="primary"
type="submit"
+ data-test-id="grantRefundButton"
>
{isEdit ? (
diff --git a/src/orders/components/OrderManualTransactionForm/components/DescriptionField.tsx b/src/orders/components/OrderManualTransactionForm/components/DescriptionField.tsx
index cf04e78aa..ced112504 100644
--- a/src/orders/components/OrderManualTransactionForm/components/DescriptionField.tsx
+++ b/src/orders/components/OrderManualTransactionForm/components/DescriptionField.tsx
@@ -16,7 +16,11 @@ export const DescriptionField: React.FC<
disabled={submitState === "loading" || disabled}
onChange={handleChangeDescription}
value={description}
- inputProps={{ ...props.inputProps, maxLength: 512 }}
+ inputProps={{
+ ...props.inputProps,
+ maxLength: 512,
+ "data-test-id": "transactionDescription",
+ }}
/>
);
};
diff --git a/src/orders/components/OrderManualTransactionForm/components/PriceInputField.tsx b/src/orders/components/OrderManualTransactionForm/components/PriceInputField.tsx
index a17ef46f6..c62734244 100644
--- a/src/orders/components/OrderManualTransactionForm/components/PriceInputField.tsx
+++ b/src/orders/components/OrderManualTransactionForm/components/PriceInputField.tsx
@@ -16,6 +16,11 @@ export const PriceInputField: React.FC<
disabled={submitState === "loading" || disabled}
onChange={handleChangeAmount}
value={amount?.toString() ?? ""}
+ InputProps={{
+ inputProps: {
+ "data-test-id": "transactAmountInput",
+ },
+ }}
/>
);
};
diff --git a/src/orders/components/OrderManualTransactionForm/components/PspReferenceField.tsx b/src/orders/components/OrderManualTransactionForm/components/PspReferenceField.tsx
index 6639ed062..ea20df5d2 100644
--- a/src/orders/components/OrderManualTransactionForm/components/PspReferenceField.tsx
+++ b/src/orders/components/OrderManualTransactionForm/components/PspReferenceField.tsx
@@ -16,7 +16,11 @@ export const PspReferenceField: React.FC<
disabled={submitState === "loading" || disabled}
onChange={handleChangePspReference}
value={pspReference}
- inputProps={{ ...props.inputProps, maxLength: 512 }}
+ inputProps={{
+ ...props.inputProps,
+ maxLength: 512,
+ "data-test-id": "transactionPspReference",
+ }}
/>
);
};
diff --git a/src/orders/components/OrderManualTransactionForm/components/SubmitButton.tsx b/src/orders/components/OrderManualTransactionForm/components/SubmitButton.tsx
index c66287291..0da910fb5 100644
--- a/src/orders/components/OrderManualTransactionForm/components/SubmitButton.tsx
+++ b/src/orders/components/OrderManualTransactionForm/components/SubmitButton.tsx
@@ -16,6 +16,7 @@ export const SubmitButton: React.FC<
type="submit"
transitionState={submitState}
disabled={!amount || disabled}
+ data-test-id="manualTransactionSubmit"
/>
);
};
diff --git a/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx b/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx
index 15e8c31a3..1d2bd56e1 100644
--- a/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx
+++ b/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx
@@ -63,6 +63,7 @@ const OrderMarkAsPaidDialog: React.FC = ({
})}
value={transactionReference}
onChange={handleTransactionReference}
+ data-test-id="transaction-reference-input"
/>
{errors.length > 0 && (
<>
diff --git a/src/orders/components/OrderPayment/OrderPayment.tsx b/src/orders/components/OrderPayment/OrderPayment.tsx
index 03201bec2..c9b0b772e 100644
--- a/src/orders/components/OrderPayment/OrderPayment.tsx
+++ b/src/orders/components/OrderPayment/OrderPayment.tsx
@@ -105,7 +105,11 @@ const OrderPayment: React.FC = props => {
)}
{canMarkAsPaid && (
-
+
diff --git a/src/orders/components/OrderPaymentSummaryCard/OrderPaymentSummaryCard.tsx b/src/orders/components/OrderPaymentSummaryCard/OrderPaymentSummaryCard.tsx
index eeab3d71b..93bed411a 100644
--- a/src/orders/components/OrderPaymentSummaryCard/OrderPaymentSummaryCard.tsx
+++ b/src/orders/components/OrderPaymentSummaryCard/OrderPaymentSummaryCard.tsx
@@ -83,7 +83,11 @@ const OrderPaymentSummaryCard: React.FC = ({
{canMarkAsPaid && (
- onMarkAsPaid()}>
+ onMarkAsPaid()}
+ data-test-id="markAsPaidButton"
+ >
@@ -102,6 +106,7 @@ const OrderPaymentSummaryCard: React.FC = ({
= ({
}
return (
-
+