Skip to content

Commit

Permalink
[TEST] [E2E] Delete shipping rate from its details page (#4625)
Browse files Browse the repository at this point in the history
* test for deleting shipping rate from it's details page

* CR fixes
  • Loading branch information
yellowee committed Jan 17, 2024
1 parent 05dc813 commit 7c7c73c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-horses-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Deleting shipping rate from it's details page
31 changes: 28 additions & 3 deletions playwright/pages/shippingMethodsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class ShippingMethodsPage {
readonly assignCountriesDialog: AssignCountriesDialog;
readonly deleteShippingMethodDialog: DeleteShippingMethodDialog;


constructor(
page: Page,
readonly assignCountryButton = page.getByTestId("assign-country"),
Expand All @@ -24,7 +25,9 @@ export class ShippingMethodsPage {
.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 deleteShippingRateButton = page.getByTestId("button-bar-delete"),
readonly shippingRateNameInput = page.getByTestId("shipping-rate-name-input"),
readonly deleteShippingRateButtonOnList = page.getByTestId("shipping-method-row").getByRole("button").getByTestId("delete-button"),
readonly priceBasedRatesSection = page.getByTestId("price-based-rates"),
readonly weightBasedRatesSection = page.getByTestId("weight-based-rates"),
) {
Expand Down Expand Up @@ -83,13 +86,35 @@ export class ShippingMethodsPage {
});
}

async gotoExistingShippingRate(shippingMethodId: string, shippingRateId: string) {
const existingShippingRateUrl = `${URL_LIST.shippingMethods}${shippingMethodId}/${shippingRateId}`;

await console.log(
`Navigates to existing shipping rate page: ${existingShippingRateUrl}`,
);

await this.page.goto(existingShippingRateUrl);

await this.shippingRateNameInput.waitFor({
state: "visible",
timeout: 10000,
});
}


async clickCreateShippingZoneButton() {
await this.createShippingZoneButton.click();
}

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

}

async clickDeleteShippingRateButton() {
await this.deleteShippingRateButton.click();
}


}

23 changes: 19 additions & 4 deletions playwright/tests/shippingMethods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,35 @@ test("TC: SALEOR_33 Add weight rate to shipping method - with included zip codes
);
});

test("TC: SALEOR_34 Delete a single shipping method from the shipping zone details page @shipping-method @e2e", async ({
page,
}) => {
test("TC: SALEOR_34 Delete a single shipping rate 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.clickDeletePriceBasedShippingMethod();
await shippingMethodsPage.deleteShippingMethodDialog.clickDeleteButton();
await shippingMethodsPage.basePage.expectSuccessBanner();
await expect(shippingMethodsPage.priceBasedRatesSection).toContainText("No shipping rates found");
await expect(shippingMethodsPage.priceBasedRatesSection).not.toContainText(priceBasedRate);
});

test("TC: SALEOR_35 Delete a single shipping rate from its details page @shipping-method @e2e", async ({
page,
}) => {
const shippingMethodsPage = new ShippingMethodsPage(page);
const shippingMethodId = SHIPPING_METHODS.shippingMethodWithRatesToBeDeleted.id;
const shippingRateId = SHIPPING_METHODS.shippingMethodWithRatesToBeDeleted.rates.weightBasedRateToBeDeleted.id;
const weightBasedRate = SHIPPING_METHODS.shippingMethodWithRatesToBeDeleted.rates.weightBasedRateToBeDeleted.name;

await shippingMethodsPage.gotoExistingShippingRate(shippingMethodId, shippingRateId);
await shippingMethodsPage.clickDeleteShippingRateButton();
await shippingMethodsPage.deleteShippingMethodDialog.clickDeleteButton();
await shippingMethodsPage.basePage.expectSuccessBanner();
await expect(shippingMethodsPage.weightBasedRatesSection).toContainText("No shipping rates found");
await expect(shippingMethodsPage.weightBasedRatesSection).not.toContainText(weightBasedRate);
});

0 comments on commit 7c7c73c

Please sign in to comment.