test for opening products from order grid (#3780)

This commit is contained in:
wojteknowacki 2023-06-23 12:01:57 +02:00 committed by GitHub
parent 79779f2d3d
commit 6a2ee1f1d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 1 deletions

View file

@ -40,6 +40,7 @@ import {
expandPrivateFulfillmentMetadata, expandPrivateFulfillmentMetadata,
expandPublicFulfillmentMetadata, expandPublicFulfillmentMetadata,
finalizeDraftOrder, finalizeDraftOrder,
openVariantDetailsOptions,
selectChannelInPicker, selectChannelInPicker,
updatePrivateMetadataFieldFulfillmentOrder, updatePrivateMetadataFieldFulfillmentOrder,
updatePublicMetadataFieldFulfillmentOrder, updatePublicMetadataFieldFulfillmentOrder,
@ -56,6 +57,7 @@ describe("Orders", () => {
let variantsList; let variantsList;
let address; let address;
let taxClass; let taxClass;
let productDetails;
const shippingPrice = 2; const shippingPrice = 2;
const variantPrice = 1; const variantPrice = 1;
@ -124,7 +126,8 @@ describe("Orders", () => {
}); });
}, },
) )
.then(({ variantsList: variantsResp }) => { .then(({ variantsList: variantsResp, product }) => {
productDetails = product;
variantsList = variantsResp; variantsList = variantsResp;
cy.checkIfDataAreNotNull({ cy.checkIfDataAreNotNull({
customer, customer,
@ -518,4 +521,57 @@ describe("Orders", () => {
}); });
}, },
); );
it(
"should open product details from order details - unconfirmed order. TC: SALEOR_2133",
{ tags: ["@orders", "@allEnv", "@stable"] },
() => {
createUnconfirmedOrder({
customerId: customer.id,
channelId: defaultChannel.id,
shippingMethod,
variantsList,
address,
}).then(unconfirmedOrderResponse => {
cy.visit(urlList.orders + `${unconfirmedOrderResponse.order.id}`);
openVariantDetailsOptions();
cy.get(ORDERS_SELECTORS.openProductDetailsButton).then(
openProductInNewTabButton => {
cy.wrap(openProductInNewTabButton)
.invoke("attr", "target")
.should("eq", "_blank");
cy.wrap(openProductInNewTabButton)
.invoke("attr", "href")
.should("contain", productDetails.id.replace("=", ""));
},
);
});
},
);
it(
"should open product details from order details - confirmed order. TC: 2134",
{ tags: ["@orders", "@allEnv", "@stable"] },
() => {
let order;
createReadyToFulfillOrder({
customerId: customer.id,
channelId: defaultChannel.id,
shippingMethod,
variantsList,
address,
}).then(({ order: orderResp }) => {
order = orderResp;
cy.visit(urlList.orders + `${order.id}`);
cy.get(ORDERS_SELECTORS.rowActionButton)
.find("a")
.then(openProductInNewTabButton => {
cy.wrap(openProductInNewTabButton)
.invoke("attr", "target")
.should("eq", "_blank");
cy.wrap(openProductInNewTabButton)
.invoke("attr", "href")
.should("contain", productDetails.id.replace("=", ""));
});
});
},
);
}); });

View file

@ -10,6 +10,7 @@ export const ORDERS_SELECTORS = {
refundButton: '[data-test-id="refund-button"]', refundButton: '[data-test-id="refund-button"]',
fulfillMenuButton: '[data-test-id="fulfill-menu"]', fulfillMenuButton: '[data-test-id="fulfill-menu"]',
priceCellFirstRowOrderDetails: "[id='glide-cell-5-0']", priceCellFirstRowOrderDetails: "[id='glide-cell-5-0']",
productNameOrderDetailsRow: "'[id='glide-cell-0-0']'",
productNameSecondRowOrderDetails: "[id='glide-cell-1-1']", productNameSecondRowOrderDetails: "[id='glide-cell-1-1']",
quantityCellFirstRowOrderDetails: "[id='glide-cell-4-0']", quantityCellFirstRowOrderDetails: "[id='glide-cell-4-0']",
gridClip: "[class='clip-region']", gridClip: "[class='clip-region']",
@ -24,6 +25,8 @@ export const ORDERS_SELECTORS = {
grantRefundButton: '[data-test-id="grantRefundButton"]', grantRefundButton: '[data-test-id="grantRefundButton"]',
transactionReferenceInput: '[data-test-id="transaction-reference-input"]', transactionReferenceInput: '[data-test-id="transaction-reference-input"]',
orderTransactionsList: '[data-test-id="orderTransactionsList"]', orderTransactionsList: '[data-test-id="orderTransactionsList"]',
openProductDetailsButton: '[data-test-id="open-product-details"]',
rowActionButton: '[data-test-id="row-action-button"]',
captureManualTransactionButton: captureManualTransactionButton:
'[data-test-id="captureManualTransactionButton"]', '[data-test-id="captureManualTransactionButton"]',
}; };

View file

@ -18,6 +18,7 @@ export {
applyFixedLineDiscountForProduct, applyFixedLineDiscountForProduct,
changeQuantityOfProducts, changeQuantityOfProducts,
deleteProductFromGridTableOnIndex, deleteProductFromGridTableOnIndex,
openVariantDetailsOptions,
} from "./ordersOperations"; } from "./ordersOperations";
export { expectWelcomeMessageIncludes } from "./homePage"; export { expectWelcomeMessageIncludes } from "./homePage";
export { getDisplayedSelectors } from "./permissionsPage"; export { getDisplayedSelectors } from "./permissionsPage";

View file

@ -60,6 +60,11 @@ export function deleteProductFromGridTableOnIndex(trIndex = 0) {
.click() .click()
.wait("@OrderLineDelete"); .wait("@OrderLineDelete");
} }
export function openVariantDetailsOptions(variantIndex = 1) {
return cy.get(BUTTON_SELECTORS.showMoreButton).eq(variantIndex).click();
}
export function addNewProductToOrder(productIndex = 0, variantIndex = 0) { export function addNewProductToOrder(productIndex = 0, variantIndex = 0) {
cy.get(DRAFT_ORDER_SELECTORS.addProducts).click(); cy.get(DRAFT_ORDER_SELECTORS.addProducts).click();
return cy return cy

View file

@ -66,6 +66,7 @@ export const OrderDraftDetailsDatagrid = ({
Icon: ( Icon: (
<Link <Link
to={productUrl(lines[index]?.variant.product.id)} to={productUrl(lines[index]?.variant.product.id)}
data-test-id="open-product-details"
target="_blank" target="_blank"
className={sprinkles({ className={sprinkles({
display: "flex", display: "flex",