diff --git a/.changeset/pretty-hairs-happen.md b/.changeset/pretty-hairs-happen.md new file mode 100644 index 00000000000..1141179629b --- /dev/null +++ b/.changeset/pretty-hairs-happen.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Make discount rules flag visible diff --git a/.changeset/sour-bikes-sort.md b/.changeset/sour-bikes-sort.md new file mode 100644 index 00000000000..a1d3541d0ad --- /dev/null +++ b/.changeset/sour-bikes-sort.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": minor +--- + +Test for deleting a shipping method from a shipping zone details page diff --git a/.featureFlags/discounts-rules.md b/.featureFlags/discounts-rules.md index b2fb5af902a..6da6c427284 100644 --- a/.featureFlags/discounts-rules.md +++ b/.featureFlags/discounts-rules.md @@ -3,7 +3,10 @@ name: discounts_rules displayName: Discounts rules enabled: false payload: "default" -visible: false +visible: true --- -New discount rules base on new promotion API +![Discount rules](./images/discounts-list.png) + +Apply the new discounts rules to narrow your promotions audience. +Set up conditions and channels that must be fulfilled to apply defined reward. diff --git a/.featureFlags/generated.tsx b/.featureFlags/generated.tsx index 1cde58a7327..4089ebdef61 100644 --- a/.featureFlags/generated.tsx +++ b/.featureFlags/generated.tsx @@ -1,10 +1,13 @@ // @ts-nocheck -import R48846 from "./images/filters.png" +import L10838 from "./images/discounts-list.png" +import W33914 from "./images/filters.png" -const discounts_rules = () => (<>

New discount rules base on new promotion API

+const discounts_rules = () => (<>

Discount rules

+

Apply the new discounts rules to narrow your promotions audience. +Set up conditions and channels that must be fulfilled to apply defined reward.

) -const product_filters = () => (<>

new filters

+const product_filters = () => (<>

new filters

Experience the new look and enhanced abilities of new fitering mechanism. Easily combine any criteria you want, and quickly browse their values.

) @@ -13,7 +16,7 @@ export const AVAILABLE_FLAGS = [{ name: "discounts_rules", displayName: "Discounts rules", component: discounts_rules, - visible: false, + visible: true, content: { enabled: false, payload: "default", diff --git a/.featureFlags/images/discounts-list.png b/.featureFlags/images/discounts-list.png new file mode 100644 index 00000000000..c9e91532ab0 Binary files /dev/null and b/.featureFlags/images/discounts-list.png differ diff --git a/playwright/data/commonLocators.ts b/playwright/data/commonLocators.ts index 23194e24737..e3d75b3be30 100644 --- a/playwright/data/commonLocators.ts +++ b/playwright/data/commonLocators.ts @@ -1,6 +1,6 @@ export const LOCATORS = { - successBanner: '[data-test-type="success"]', - errorBanner: '[data-test-type="error"]', - infoBanner: '[data-test-type="info"]', - dataGridTable: "[data-testid='data-grid-canvas']", + successBanner: "[data-test-type=\"success\"]", + errorBanner: "[data-test-type=\"error\"]", + infoBanner: "[data-test-type=\"info\"]", + dataGridTable: "[data-testid=\"data-grid-canvas\"]", }; diff --git a/playwright/data/e2eTestData.ts b/playwright/data/e2eTestData.ts index 2d6b3fc0d95..a2f542a5d0e 100644 --- a/playwright/data/e2eTestData.ts +++ b/playwright/data/e2eTestData.ts @@ -205,6 +205,23 @@ export const SHIPPING_METHODS = { id: "U2hpcHBpbmdab25lOjIzOTA%3D", info: "Shipping method that is used to add rates", }, + shippingMethodWithRatesToBeDeleted: { + id: "U2hpcHBpbmdab25lOjIzODk%3D", + info: "Shipping zone with methods to be deleted", + name: "e2e-test-shippingZone-to-be-deleted", + rates: { + priceBasedRateToBeDeleted: { + id: "U2hpcHBpbmdNZXRob2RUeXBlOjIyMjA=", + info: "Price based shipping rate", + name: "shippingMEthod_to-be-deleted", + }, + weightBasedRateToBeDeleted: { + id: "U2hpcHBpbmdNZXRob2RUeXBlOjIyMjA=", + info: "Weight based shipping rate", + name: "shippingMethod_to_be_deleted", + }, + }, + }, }; export const USERS = { userToBeDeactivated: { diff --git a/playwright/pages/dialogs/deleteShippingMethodDialog.ts b/playwright/pages/dialogs/deleteShippingMethodDialog.ts new file mode 100644 index 00000000000..4ca202ae4fe --- /dev/null +++ b/playwright/pages/dialogs/deleteShippingMethodDialog.ts @@ -0,0 +1,17 @@ +import type { Locator, Page } from "@playwright/test"; + +export class DeleteShippingMethodDialog { + readonly page: Page; + + readonly deleteButton: Locator; + + constructor(page: Page) { + this.page = page; + + this.deleteButton = page.getByTestId("submit"); + } + + async clickDeleteButton() { + await this.deleteButton.click(); + } +} diff --git a/playwright/pages/shippingMethodsPage.ts b/playwright/pages/shippingMethodsPage.ts index f5897afdc0d..c6b3304180f 100644 --- a/playwright/pages/shippingMethodsPage.ts +++ b/playwright/pages/shippingMethodsPage.ts @@ -1,4 +1,5 @@ import { URL_LIST } from "@data/url"; +import { DeleteShippingMethodDialog } from "@dialogs/deleteShippingMethodDialog"; import { BasePage } from "@pages/basePage"; import { AssignCountriesDialog } from "@pages/dialogs/assignCountriesDialog"; import { RightSideDetailsPage } from "@pages/pageElements/rightSideDetailsSection"; @@ -9,6 +10,7 @@ export class ShippingMethodsPage { readonly basePage: BasePage; readonly rightSideDetailsPage: RightSideDetailsPage; readonly assignCountriesDialog: AssignCountriesDialog; + readonly deleteShippingMethodDialog: DeleteShippingMethodDialog; constructor( page: Page, @@ -21,16 +23,22 @@ export class ShippingMethodsPage { .getByTestId("shipping-zone-description") .locator("textarea"), readonly saveButton = page.getByTestId("button-bar-confirm"), + readonly shippingZoneName = page.getByTestId("page-header"), + readonly deleteShippingMethodButton = page.getByTestId("shipping-method-row").getByRole("button").getByTestId("delete-button"), + readonly priceBasedRatesSection = page.getByTestId("price-based-rates"), + readonly weightBasedRatesSection = page.getByTestId("weight-based-rates"), ) { this.page = page; this.basePage = new BasePage(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); this.assignCountriesDialog = new AssignCountriesDialog(page); + this.deleteShippingMethodDialog = new DeleteShippingMethodDialog(page); } async clickAddWeightRateButton() { await this.addWeightRateButton.click(); } + async clickAddPriceRateButton() { await this.addPriceRateButton.click(); } @@ -44,6 +52,7 @@ export class ShippingMethodsPage { `${shippingZoneName} - ${new Date().toISOString()}`, ); } + async typeShippingZoneDescription( shippingDescription = "Biggest zone in e2e world", ) { @@ -61,6 +70,7 @@ export class ShippingMethodsPage { timeout: 10000, }); } + async gotoExistingShippingMethod(shippingMethodId: string) { const existingShippingMethodUrl = `${URL_LIST.shippingMethods}${shippingMethodId}`; await console.log( @@ -76,4 +86,10 @@ export class ShippingMethodsPage { async clickCreateShippingZoneButton() { await this.createShippingZoneButton.click(); } + + async clickDeleteShippingMethod() { + await this.priceBasedRatesSection.locator(this.deleteShippingMethodButton).click(); + + } + } diff --git a/playwright/tests/shippingMethods.spec.ts b/playwright/tests/shippingMethods.spec.ts index 61933578eb1..93d5a5a6c04 100644 --- a/playwright/tests/shippingMethods.spec.ts +++ b/playwright/tests/shippingMethods.spec.ts @@ -6,8 +6,8 @@ import { expect, test } from "@playwright/test"; test.use({ storageState: "playwright/.auth/admin.json" }); test("TC: SALEOR_31 Create basic shipping method @shipping-method @e2e", async ({ - page, -}) => { + page, + }) => { const shippingMethodsPage = new ShippingMethodsPage(page); await shippingMethodsPage.gotoListView(); @@ -26,9 +26,9 @@ test("TC: SALEOR_31 Create basic shipping method @shipping-method @e2e", async ( await shippingMethodsPage.saveShippingZone(); await shippingMethodsPage.basePage.expectSuccessBanner(); }); -test("TC: SALEOR_32 Add price rate to shipping method - with excluded zip codes adn excluded product @shipping-method @e2e", async ({ - page, -}) => { +test("TC: SALEOR_32 Add price rate to shipping method - with excluded zip codes and excluded product @shipping-method @e2e", async ({ + page, + }) => { const shippingMethodsPage = new ShippingMethodsPage(page); const shippingRatesPage = new ShippingRatesPage(page); @@ -55,9 +55,9 @@ test("TC: SALEOR_32 Add price rate to shipping method - with excluded zip codes 1, ); }); -test("TC: SALEOR_33 Add weight rate to shipping method - with included zip codes adn excluded product @shipping-method @e2e", async ({ - page, -}) => { +test("TC: SALEOR_33 Add weight rate to shipping method - with included zip codes and excluded product @shipping-method @e2e", async ({ + page, + }) => { const shippingMethodsPage = new ShippingMethodsPage(page); const shippingRatesPage = new ShippingRatesPage(page); @@ -85,3 +85,21 @@ test("TC: SALEOR_33 Add weight rate to shipping method - with included zip codes 1, ); }); + +test("TC: SALEOR_34 Delete a single shipping method from the shipping zone details page @shipping-method @e2e", async ({ + page, + }) => { + const shippingMethodsPage = new ShippingMethodsPage(page); + await shippingMethodsPage.gotoExistingShippingMethod( + SHIPPING_METHODS.shippingMethodWithRatesToBeDeleted.id, + ); + await expect(shippingMethodsPage.basePage.pageHeader).toBeVisible(); + const priceBasedRate = SHIPPING_METHODS.shippingMethodWithRatesToBeDeleted.rates.priceBasedRateToBeDeleted.name; + await expect(shippingMethodsPage.priceBasedRatesSection).toContainText(priceBasedRate); + await shippingMethodsPage.clickDeleteShippingMethod(); + await shippingMethodsPage.deleteShippingMethodDialog.clickDeleteButton(); + await shippingMethodsPage.basePage.expectSuccessBanner(); + await expect(shippingMethodsPage.priceBasedRatesSection).toContainText("No shipping rates found"); + await expect(shippingMethodsPage.priceBasedRatesSection).not.toContainText(priceBasedRate); +}); + diff --git a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx index 5b0e785d5e0..44519f232c2 100644 --- a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx +++ b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx @@ -70,7 +70,11 @@ const ShippingZoneRates: React.FC = props => { const intl = useIntl(); return ( - + = props => { hover={!!rate} key={rate ? rate.id : "skeleton"} href={rate && getRateEditHref(rate.id)} + data-test-id="shipping-method-row" > {maybe(() => rate.name, )} @@ -190,7 +195,7 @@ const ShippingZoneRates: React.FC = props => { onClick={() => onRateRemove(rate.id)} className={classes.buttonColumn} > - +