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,
|
||||
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";
|
||||
|
|
|
@ -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";
|
||||
|
|
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']",
|
||||
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"]',
|
||||
};
|
||||
|
|
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";
|
||||
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";
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 }) {
|
||||
|
|
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);
|
||||
})
|
||||
.then(() => orderRequest.completeOrder(order.id))
|
||||
.then(() => order);
|
||||
.then(resp => (order = resp.order));
|
||||
}
|
||||
|
||||
function assignVariantsToOrder(order, variantsList) {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
import * as ordersOperationsHelpers from "./ordersOperations";
|
||||
|
||||
export { ordersOperationsHelpers };
|
||||
export * as ordersOperationsHelpers from "./ordersOperations";
|
||||
export * as transactionsOrderUtils from "./ordersTransactionUtils";
|
||||
|
|
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 (
|
||||
<div className={classes.wrapper}>
|
||||
<Button variant="primary" onClick={onAddTransaction}>
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={onAddTransaction}
|
||||
data-test-id="captureManualTransactionButton"
|
||||
>
|
||||
<FormattedMessage {...addTransactionMessages.captureTransaction} />
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
@ -155,6 +155,11 @@ const OrderGrantRefundPage: React.FC<OrderGrantRefundPageProps> = ({
|
|||
name={"reason" as keyof OrderGrantRefundFormData}
|
||||
onChange={change}
|
||||
type="text"
|
||||
InputProps={{
|
||||
inputProps: {
|
||||
"data-test-id": "refundReasonInput",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
|
|
@ -67,7 +67,11 @@ export const ProductsCard: React.FC<ProductsCardProps> = ({
|
|||
</>
|
||||
}
|
||||
toolbar={
|
||||
<Button variant="secondary" onClick={handleSetMaxQuanity}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={handleSetMaxQuanity}
|
||||
data-test-id="setMaxQuantityButton"
|
||||
>
|
||||
<FormattedMessage {...grantRefundPageMessages.setMaxQuantity} />
|
||||
</Button>
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ export const RefundCard = ({
|
|||
id={`checkbox-${id}`}
|
||||
value={state.refundShipping}
|
||||
onChange={() => dispatch({ type: "toggleRefundShipping" })}
|
||||
data-test-id="refundShippingCheckbox"
|
||||
/>
|
||||
<label htmlFor={`checkbox-${id}`}>
|
||||
{!currency ? (
|
||||
|
@ -104,6 +105,7 @@ export const RefundCard = ({
|
|||
variant="secondary"
|
||||
size="small"
|
||||
onClick={() => form.set({ amount: totalSelectedPrice.toString() })}
|
||||
data-test-id="applySelectedRefundButton"
|
||||
>
|
||||
<FormattedMessage {...buttonMessages.apply} />
|
||||
</Button>
|
||||
|
@ -131,6 +133,7 @@ export const RefundCard = ({
|
|||
transitionState={submitState}
|
||||
variant="primary"
|
||||
type="submit"
|
||||
data-test-id="grantRefundButton"
|
||||
>
|
||||
{isEdit ? (
|
||||
<FormattedMessage {...grantRefundPageMessages.editRefundBtn} />
|
||||
|
|
|
@ -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",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -16,6 +16,11 @@ export const PriceInputField: React.FC<
|
|||
disabled={submitState === "loading" || disabled}
|
||||
onChange={handleChangeAmount}
|
||||
value={amount?.toString() ?? ""}
|
||||
InputProps={{
|
||||
inputProps: {
|
||||
"data-test-id": "transactAmountInput",
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ export const SubmitButton: React.FC<
|
|||
type="submit"
|
||||
transitionState={submitState}
|
||||
disabled={!amount || disabled}
|
||||
data-test-id="manualTransactionSubmit"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -63,6 +63,7 @@ const OrderMarkAsPaidDialog: React.FC<OrderMarkAsPaidDialogProps> = ({
|
|||
})}
|
||||
value={transactionReference}
|
||||
onChange={handleTransactionReference}
|
||||
data-test-id="transaction-reference-input"
|
||||
/>
|
||||
{errors.length > 0 && (
|
||||
<>
|
||||
|
|
|
@ -105,7 +105,11 @@ const OrderPayment: React.FC<OrderPaymentProps> = props => {
|
|||
</Button>
|
||||
)}
|
||||
{canMarkAsPaid && (
|
||||
<Button variant="tertiary" onClick={onMarkAsPaid}>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
onClick={onMarkAsPaid}
|
||||
data-test-id="markAsPaidButton"
|
||||
>
|
||||
<FormattedMessage
|
||||
{...paymentButtonMessages.markAsPaid}
|
||||
/>
|
||||
|
|
|
@ -83,7 +83,11 @@ const OrderPaymentSummaryCard: React.FC<OrderPaymementProps> = ({
|
|||
<FormattedMessage {...orderPaymentMessages.noPayments} />
|
||||
</Typography>
|
||||
{canMarkAsPaid && (
|
||||
<Button variant="tertiary" onClick={() => onMarkAsPaid()}>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
onClick={() => onMarkAsPaid()}
|
||||
data-test-id="markAsPaidButton"
|
||||
>
|
||||
<FormattedMessage
|
||||
{...orderPaymentActionButtonMessages.markAsPaid}
|
||||
/>
|
||||
|
@ -102,6 +106,7 @@ const OrderPaymentSummaryCard: React.FC<OrderPaymementProps> = ({
|
|||
<Button
|
||||
href={orderGrantRefundUrl(order.id)}
|
||||
variant="secondary"
|
||||
data-test-id="grantRefundButton"
|
||||
>
|
||||
<FormattedMessage
|
||||
{...orderPaymentActionButtonMessages.grantRefund}
|
||||
|
|
|
@ -41,7 +41,10 @@ const OrderTransaction: React.FC<OrderTransactionProps> = ({
|
|||
}
|
||||
|
||||
return (
|
||||
<Card className={clsx(classes.card, disabled && classes.disabled)}>
|
||||
<Card
|
||||
className={clsx(classes.card, disabled && classes.disabled)}
|
||||
data-test-id="orderTransactionsList"
|
||||
>
|
||||
<CardTitle
|
||||
transaction={transaction}
|
||||
onTransactionAction={onTransactionAction}
|
||||
|
|
Loading…
Reference in a new issue