Skip to content

Commit

Permalink
Merge branch 'main' into migrated-collection-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wojteknowacki authored Jan 12, 2024
2 parents 21c21a9 + 1a32555 commit dd6f647
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-hairs-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Make discount rules flag visible
5 changes: 5 additions & 0 deletions .changeset/sour-bikes-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Test for deleting a shipping method from a shipping zone details page
7 changes: 5 additions & 2 deletions .featureFlags/discounts-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 7 additions & 4 deletions .featureFlags/generated.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => (<><p>New discount rules base on new promotion API</p>
const discounts_rules = () => (<><p><img src={L10838} alt="Discount rules"/></p>
<p>Apply the new discounts rules to narrow your promotions audience.
Set up conditions and channels that must be fulfilled to apply defined reward.</p>
</>)
const product_filters = () => (<><p><img src={R48846} alt="new filters"/></p>
const product_filters = () => (<><p><img src={W33914} alt="new filters"/></p>
<p>Experience the new look and enhanced abilities of new fitering mechanism.
Easily combine any criteria you want, and quickly browse their values.</p>
</>)
Expand All @@ -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",
Expand Down
Binary file added .featureFlags/images/discounts-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions playwright/data/commonLocators.ts
Original file line number Diff line number Diff line change
@@ -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\"]",
};
17 changes: 17 additions & 0 deletions playwright/data/e2eTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
17 changes: 17 additions & 0 deletions playwright/pages/dialogs/deleteShippingMethodDialog.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
16 changes: 16 additions & 0 deletions playwright/pages/shippingMethodsPage.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -9,6 +10,7 @@ export class ShippingMethodsPage {
readonly basePage: BasePage;
readonly rightSideDetailsPage: RightSideDetailsPage;
readonly assignCountriesDialog: AssignCountriesDialog;
readonly deleteShippingMethodDialog: DeleteShippingMethodDialog;

constructor(
page: Page,
Expand All @@ -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();
}
Expand All @@ -44,6 +52,7 @@ export class ShippingMethodsPage {
`${shippingZoneName} - ${new Date().toISOString()}`,
);
}

async typeShippingZoneDescription(
shippingDescription = "Biggest zone in e2e world",
) {
Expand All @@ -61,6 +70,7 @@ export class ShippingMethodsPage {
timeout: 10000,
});
}

async gotoExistingShippingMethod(shippingMethodId: string) {
const existingShippingMethodUrl = `${URL_LIST.shippingMethods}${shippingMethodId}`;
await console.log(
Expand All @@ -76,4 +86,10 @@ export class ShippingMethodsPage {
async clickCreateShippingZoneButton() {
await this.createShippingZoneButton.click();
}

async clickDeleteShippingMethod() {
await this.priceBasedRatesSection.locator(this.deleteShippingMethodButton).click();

}

}
34 changes: 26 additions & 8 deletions playwright/tests/shippingMethods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);
});

Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ const ShippingZoneRates: React.FC<ShippingZoneRatesProps> = props => {
const intl = useIntl();

return (
<Card>
<Card
data-test-id={
variant === "price" ? "price-based-rates" : "weight-based-rates"
}
>
<CardTitle
title={
variant === "price"
Expand Down Expand Up @@ -141,6 +145,7 @@ const ShippingZoneRates: React.FC<ShippingZoneRatesProps> = props => {
hover={!!rate}
key={rate ? rate.id : "skeleton"}
href={rate && getRateEditHref(rate.id)}
data-test-id="shipping-method-row"
>
<TableCell className={classes.nameColumn}>
{maybe<React.ReactNode>(() => rate.name, <Skeleton />)}
Expand Down Expand Up @@ -190,7 +195,7 @@ const ShippingZoneRates: React.FC<ShippingZoneRatesProps> = props => {
onClick={() => onRateRemove(rate.id)}
className={classes.buttonColumn}
>
<DeleteIcon />
<DeleteIcon data-test-id="delete-button" />
</IconButtonTableCell>
</TableButtonWrapper>
</TableRowLink>
Expand Down

0 comments on commit dd6f647

Please sign in to comment.