Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update flow to create manual voucher codes #4413

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-days-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

update e2e voucher code creation tests
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = defineConfig({
screenshotsFolder: "cypress/reports/mochareports",
screenshotOnRunFailure: true,
experimentalMemoryManagement: true,
numTestsKeptInMemory: 0,
numTestsKeptInMemory: 8,
retries: {
runMode: 2,
openMode: 0,
Expand Down
11 changes: 7 additions & 4 deletions cypress/elements/discounts/vouchers.js
Original file line number Diff line number Diff line change
@@ -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']",
Expand All @@ -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"]',
},
};
9 changes: 5 additions & 4 deletions cypress/support/pages/discounts/vouchersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/components/SubMenu/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export const SubMenu = ({ menuItems }: SubMenuProps) => {
borderBottomWidth={1}
borderColor="neutralPlain"
>
<Text variant="bodyStrong">{title}</Text>
<Text
data-test-id={String(title).toLowerCase()}
variant="bodyStrong"
>
{title}
</Text>
<Text>{description}</Text>
</List.Item>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const VoucherCodesAddButton = ({
<Popover open={isSubMenuOpen} onOpenChange={setSubMenuOpen}>
<Popover.Trigger>
<Button
data-test-id="add-code-button"
type="button"
backgroundColor="interactiveNeutralDefault"
color="textNeutralContrasted"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const VoucherCodesManualDialog = ({
</DashboardModal.Title>
<Box display="grid" gap={3} __width={390}>
<Input
data-test-id="enter-code-input"
name="code"
type="text"
size="small"
Expand All @@ -73,6 +74,7 @@ export const VoucherCodesManualDialog = ({
{intl.formatMessage(buttonMessages.back)}
</Button>
<ConfirmButton
data-test-id="confirm-button"
transitionState={confirmButtonTransitionState}
onClick={handleSubmit}
>
Expand Down
Loading