Skip to content

Commit

Permalink
Merge branch 'main' into e2e-pool
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejewsky authored Nov 10, 2023
2 parents c4ede1f + 9f83d90 commit bb9d906
Show file tree
Hide file tree
Showing 24 changed files with 1,072 additions and 619 deletions.
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
5 changes: 5 additions & 0 deletions .changeset/funny-badgers-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Delay home queries to be non-blocking for the UI
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"]',
},
};
4 changes: 2 additions & 2 deletions cypress/support/customCommands/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Cypress.Commands.add("loginInShop", () => {
});

Cypress.Commands.add("visitHomePageLoggedViaApi", user => {
cy.addAliasToGraphRequest("Home")
cy.addAliasToGraphRequest("UserDetails")
.loginUserViaRequest("auth", user)
.visit(urlList.homePage)
.waitForRequestAndCheckIfNoErrors("@Home");
.waitForRequestAndCheckIfNoErrors("@UserDetails");
});

Cypress.Commands.add(
Expand Down
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
18 changes: 8 additions & 10 deletions cypress/support/pages/homePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { HOMEPAGE_SELECTORS } from "../../elements/homePage/homePage-selectors";
export function changeChannel(channelName) {
cy.get(HEADER_SELECTORS.channelSelect)
.click()
.addAliasToGraphRequest("Home")
.get(HEADER_SELECTORS.channelSelectList)
.contains(channelName)
.click()
.wait("@Home");
.click();
}

export function expectWelcomeMessageIncludes(name) {
Expand All @@ -21,37 +19,37 @@ export function expectWelcomeMessageIncludes(name) {

export function getOrdersReadyToFulfillRegex(
ordersReadyToFulfillBefore,
quantityOfNewOrders
quantityOfNewOrders,
) {
const allOrdersReadyToFulfill =
ordersReadyToFulfillBefore + quantityOfNewOrders;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`
`${notANumberRegex}${allOrdersReadyToFulfill}${notANumberRegex}`,
);
}

export function getOrdersReadyForCaptureRegex(
ordersReadyForCaptureBefore,
quantityOfNewOrders
quantityOfNewOrders,
) {
const allOrdersReadyForCapture =
ordersReadyForCaptureBefore + quantityOfNewOrders;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`
`${notANumberRegex}${allOrdersReadyForCapture}${notANumberRegex}`,
);
}

export function getProductsOutOfStockRegex(
productsOutOfStockBefore,
quantityOfNewProducts
quantityOfNewProducts,
) {
const allProductsOutOfStock =
productsOutOfStockBefore + quantityOfNewProducts;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`
`${notANumberRegex}${allProductsOutOfStock}${notANumberRegex}`,
);
}

Expand All @@ -67,7 +65,7 @@ export function getSalesAmountRegex(salesAmountBefore, addedAmount) {
const totalAmountWithSeparators = `${totalAmountIntegerWithThousandsSeparator}${decimalSeparator}${totalAmountDecimalValue}`;
const notANumberRegex = "\\D*";
return new RegExp(
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`
`${notANumberRegex}${totalAmountWithSeparators}${notANumberRegex}`,
);
}

Expand Down
6 changes: 6 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@
"context": "section description",
"string": "Strategy defines the preference of warehouses for stock allocations and reservations."
},
"/Fa+RP": {
"string": "Couldn't load top products"
},
"/ILyIf": {
"context": "tax classes menu header",
"string": "Tax class label"
Expand Down Expand Up @@ -241,6 +244,9 @@
"context": "page label",
"string": "Hidden"
},
"/U8FUp": {
"string": "Couldn't load activities"
},
"/V7UOC": {
"context": "unassign category from sale and save, button",
"string": "Unassign and save"
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

0 comments on commit bb9d906

Please sign in to comment.