From 8d5c3458237279350b7ee207427ed869f00b11d9 Mon Sep 17 00:00:00 2001 From: wojteknowacki Date: Thu, 9 Nov 2023 13:56:27 +0100 Subject: [PATCH 1/2] update flow to create manual voucher codes --- cypress.config.js | 2 +- cypress/elements/discounts/vouchers.js | 11 +++++++---- cypress/support/pages/discounts/vouchersPage.js | 9 +++++---- src/components/SubMenu/SubMenu.tsx | 7 ++++++- .../VoucherCodesAddButton/VoucherCodesAddButton.tsx | 1 + .../VoucherCodesManualDialog.tsx | 2 ++ 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cypress.config.js b/cypress.config.js index 384450108a5..a7a6a49ebdb 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -14,7 +14,7 @@ module.exports = defineConfig({ screenshotsFolder: "cypress/reports/mochareports", screenshotOnRunFailure: true, experimentalMemoryManagement: true, - numTestsKeptInMemory: 0, + numTestsKeptInMemory: 8, retries: { runMode: 2, openMode: 0, diff --git a/cypress/elements/discounts/vouchers.js b/cypress/elements/discounts/vouchers.js index 74fc77534d1..e4c0ec36c54 100644 --- a/cypress/elements/discounts/vouchers.js +++ b/cypress/elements/discounts/vouchers.js @@ -1,6 +1,9 @@ export const VOUCHERS_SELECTORS = { createVoucherButton: "[data-test-id='create-voucher']", - voucherCodeInput: "[name='code']", + manualVoucherItem: "[data-test-id='manual']", + voucherCodeConfirmButton: "[data-test-id='confirm-button']", + voucherCodeAddButton: "[data-test-id='add-code-button']", + voucherCodeNameInput: "[data-test-id='enter-code-input']", discountRadioButtons: "[name='discountType']", percentageDiscountRadioButton: "[name='discountType'][value='VALUE_PERCENTAGE']", @@ -17,12 +20,12 @@ export const VOUCHERS_SELECTORS = { usageLimitCheckbox: '[data-test-id="has-usage-limit"]', usageLimitTextField: '[data-test-id="usage-limit"]', applyOncePerCustomerCheckbox: '[data-test-id="apply-once-per-customer"]', - onlyForStaffCheckbox: '[data-test-id="only-for-staff"]' + onlyForStaffCheckbox: '[data-test-id="only-for-staff"]', }, requirements: { minOrderValueCheckbox: '[name="requirementsPicker"][value="ORDER"]', minAmountOfItemsCheckbox: '[name="requirementsPicker"][value="ITEM"]', minCheckoutItemsQuantityInput: '[name="minCheckoutItemsQuantity"]', - minOrderValueInput: '[name="minSpent"]' - } + minOrderValueInput: '[name="minSpent"]', + }, }; diff --git a/cypress/support/pages/discounts/vouchersPage.js b/cypress/support/pages/discounts/vouchersPage.js index 8728da31ff0..1bd90b9c0e4 100644 --- a/cypress/support/pages/discounts/vouchersPage.js +++ b/cypress/support/pages/discounts/vouchersPage.js @@ -25,10 +25,11 @@ export function createVoucher({ }) { cy.get(VOUCHERS_SELECTORS.createVoucherButton).click(); selectChannelInDetailsPages(channelName); - cy.get(VOUCHERS_SELECTORS.voucherCodeInput) - .type(voucherCode) - .get(discountOption) - .click(); + cy.get(VOUCHERS_SELECTORS.voucherCodeAddButton).click(); + cy.get(VOUCHERS_SELECTORS.manualVoucherItem).click(); + cy.get(VOUCHERS_SELECTORS.voucherCodeNameInput).type(voucherCode); + cy.get(VOUCHERS_SELECTORS.voucherCodeConfirmButton).click(); + cy.get(discountOption).click(); if (discountOption !== discountOptions.SHIPPING) { cy.get(VOUCHERS_SELECTORS.discountValueInputs).type(voucherValue, { force: true, diff --git a/src/components/SubMenu/SubMenu.tsx b/src/components/SubMenu/SubMenu.tsx index aca49397c71..6661c3129d0 100644 --- a/src/components/SubMenu/SubMenu.tsx +++ b/src/components/SubMenu/SubMenu.tsx @@ -33,7 +33,12 @@ export const SubMenu = ({ menuItems }: SubMenuProps) => { borderBottomWidth={1} borderColor="neutralPlain" > - {title} + + {title} + {description} ); diff --git a/src/discounts/components/VoucherCodesAddButton/VoucherCodesAddButton.tsx b/src/discounts/components/VoucherCodesAddButton/VoucherCodesAddButton.tsx index 37c9d5ccb62..282b5e8b446 100644 --- a/src/discounts/components/VoucherCodesAddButton/VoucherCodesAddButton.tsx +++ b/src/discounts/components/VoucherCodesAddButton/VoucherCodesAddButton.tsx @@ -55,6 +55,7 @@ export const VoucherCodesAddButton = ({