Skip to content

Commit

Permalink
Migrated warehouses tests: Edit warehouse; Delete warehouse (#4593)
Browse files Browse the repository at this point in the history
* Migrated warehouses tests: Edit warehouse; Delete warehouse

* Update nervous-flowers-hear.md

* Update nervous-flowers-hear.md
  • Loading branch information
wojteknowacki committed Jan 5, 2024
1 parent b606c3e commit 460f033
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 54 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-flowers-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"saleor-dashboard": minor
---

Migrated warehouses tests: Edit warehouse; Delete warehouse
nightly workflow: do not trigger test complete job if testmo-report-preparation is skipped/failed
2 changes: 1 addition & 1 deletion .github/workflows/tests-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ jobs:
test-complete:
needs:
[testmo-report-preparation, run-tests-in-parallel, run-tests-on-release]
if: always()
if: always() && !contains(needs.testmo-report-preparation.result, 'skipped') && !contains(needs.testmo-report-preparation.result, 'failure')
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions playwright/data/e2eTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ export const CHANNELS = {
name: "z - channel to be deleted",
},
};
export const WAREHOUSES = {
warehouseToBeEdited: {
id: "V2FyZWhvdXNlOjgzNGQwYjQwLWMwZGItNGRhZi04N2RjLWQ2ODBiYzY3NGVlMw%3D%3D",
name: "warehouse to be edited",
},
warehouseToBeDeleted: {
name: "warehouseto be deleted",
},
};

export const PRODUCTS = {
singleProductType: {
Expand Down
14 changes: 14 additions & 0 deletions playwright/pages/dialogs/deleteWarehouseDialog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Page } from "@playwright/test";

export class DeleteWarehouseDialog {
readonly page: Page;

constructor(page: Page, readonly deleteButton = page.getByTestId("submit")) {
this.page = page;
}

async clickDeleteButton() {
await this.deleteButton.click();
await this.deleteButton.waitFor({ state: "hidden" });
}
}
15 changes: 15 additions & 0 deletions playwright/pages/pageElements/rightSideDetailsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ export class RightSideDetailsPage {
readonly selectWarehouseShippingMethodButton = page.getByTestId(
"select-warehouse-for-shipping-method",
),
readonly stockSettingsSection = page.getByTestId("stock-settings-section"),
readonly selectChannelShippingPageButton = page.getByTestId(
"select-channel-for-shipping-method",
),
readonly pickupDisabledButton = page.getByTestId("DISABLED"),
readonly pickupAllWarehousesButton = page.getByTestId("ALL"),

readonly categorySelectOption = page.locator(
"[data-test-id*='select-option']",
Expand Down Expand Up @@ -155,6 +158,18 @@ export class RightSideDetailsPage {
async clickAddWarehousesButton() {
await this.addWarehousesButton.click();
}
async clickPublicStockButton() {
await this.stockSettingsSection.getByText("Public").click();
}
async clickPickupDisabledButton() {
await this.pickupDisabledButton.click();
}
async clickPickupAllWarehousesButton() {
await this.pickupAllWarehousesButton.click();
}
async clickPrivateStockButton() {
await this.stockSettingsSection.getByText("Private").click();
}
async selectShippingZone(zoneName = "Asia") {
await this.shippingZonesSelect.click();
await this.page.getByRole("option", { name: zoneName });
Expand Down
117 changes: 75 additions & 42 deletions playwright/pages/warehousePage.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
import type { Locator, Page } from "@playwright/test";
import { URL_LIST } from "@data/url";
import { DeleteWarehouseDialog } from "@dialogs/deleteWarehouseDialog";
import { BasePage } from "@pages/basePage";
import type { Page } from "@playwright/test";

import { BasePage } from "./basePage";
import { RightSideDetailsPage } from "./pageElements/rightSideDetailsSection";

export class WarehousePage {
export class WarehousePage extends BasePage {
readonly page: Page;
readonly createNewWarehouseButton: Locator;
readonly saveButton: Locator;
readonly warehouseNameInput: Locator;
readonly companyNameInput: Locator;
readonly companyCityInput: Locator;
readonly companyAddressLine1Input: Locator;
readonly companyAddressLine2Input: Locator;
readonly companyZipInput: Locator;
readonly companyPhoneInput: Locator;
readonly companyCountrySelect: Locator;
readonly companyCountryOptions: Locator;
readonly basePage: BasePage;
readonly deleteWarehouseDialog: DeleteWarehouseDialog;
readonly rightSideDetailsPage: RightSideDetailsPage;

constructor(page: Page) {
this.page = page;
this.basePage = new BasePage(page);
this.createNewWarehouseButton = page.getByTestId("create-warehouse");
this.saveButton = page.getByTestId("button-bar-confirm");
this.warehouseNameInput = page
constructor(
page: Page,
readonly createNewWarehouseButton = page.getByTestId("create-warehouse"),
readonly deleteWarehouseButton = page.getByTestId("delete-button"),
readonly saveButton = page.getByTestId("button-bar-confirm"),
readonly warehousesList = page.getByTestId("warehouses-list"),
readonly warehouseNameInput = page
.getByTestId("warehouse-name-input")
.locator("input");
this.companyNameInput = page
.locator("input"),
readonly companyNameInput = page
.getByTestId("company-name-input")
.locator("input");
this.companyAddressLine1Input = page
.locator("input"),
readonly companyAddressLine1Input = page
.getByTestId("company-address-line-1-input")
.locator("input");
this.companyAddressLine2Input = page
.locator("input"),
readonly companyAddressLine2Input = page
.getByTestId("company-address-line-2-input")
.locator("input");
this.companyCityInput = page
.locator("input"),
readonly companyCityInput = page
.getByTestId("company-city-input")
.locator("input");
this.companyZipInput = page
.locator("input"),
readonly companyZipInput = page
.getByTestId("company-zip-input")
.locator("input");
this.companyPhoneInput = page
.locator("input"),
readonly companyPhoneInput = page
.getByTestId("company-phone-input")
.locator("input");
this.companyCountrySelect = page.getByTestId(
.locator("input"),
readonly companyCountrySelect = page.getByTestId(
"address-edit-country-select-field",
);
this.companyCountryOptions = page.getByTestId(
),
readonly companyCountryOptions = page.getByTestId(
"single-autocomplete-select-option",
);
),
) {
super(page);
this.page = page;
this.basePage = new BasePage(page);
this.deleteWarehouseDialog = new DeleteWarehouseDialog(page);
this.rightSideDetailsPage = new RightSideDetailsPage(page);
}

async clickCreateNewWarehouseButton() {
Expand All @@ -68,17 +69,49 @@ export class WarehousePage {
phone = "++541159133745",
country = "Argentina",
) {
await this.warehouseNameInput.fill(warehouseName);
await this.companyNameInput.fill(companyName);
await this.companyAddressLine1Input.fill(lineAddress1);
await this.companyAddressLine2Input.fill(lineAddress2);
await this.typeWarehouseName(warehouseName);
await this.typeCompanyName(companyName);
await this.typeAddressLine1(lineAddress1);
await this.typeAddressLine2(lineAddress2);
await this.companyCityInput.fill(cityName);
await this.companyZipInput.fill(zip);
await this.companyPhoneInput.fill(phone);
await this.typePhone(phone);
await this.companyCountrySelect.click();
await this.page
.getByTestId("autocomplete-dropdown")
.getByRole("option", { name: country })
.click();
}

async typeWarehouseName(warehouseName: string) {
await this.warehouseNameInput.fill(warehouseName);
}
async typeAddressLine1(lineAddress1: string) {
await this.companyAddressLine1Input.fill(lineAddress1);
}
async typeAddressLine2(lineAddress2: string) {
await this.companyAddressLine2Input.fill(lineAddress2);
}
async typeCompanyName(warehouseName: string) {
await this.companyNameInput.fill(warehouseName);
}
async typePhone(phone: string) {
await this.companyPhoneInput.fill(phone);
}
async gotoWarehouseListView() {
await this.page.goto(URL_LIST.warehouses);
}
async clickDeleteWarehouseButton(warehouseName: string) {
await this.page
.getByTestId(`warehouse-entry-${warehouseName}`)
.locator(this.deleteWarehouseButton)
.click();
}
async gotoExistingWarehousePage(warehouseId: string) {
const existingWarehouseUrl = URL_LIST.warehouses + warehouseId;
await console.log(
"Navigating to warehouse details: " + existingWarehouseUrl,
);
await this.page.goto(existingWarehouseUrl);
}
}
43 changes: 35 additions & 8 deletions playwright/tests/warehouse.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
import { URL_LIST } from "@data/url";
import { WAREHOUSES } from "@data/e2eTestData";
import { WarehousePage } from "@pages/warehousePage";
import { test } from "@playwright/test";
import { expect, test } from "@playwright/test";

test.use({ storageState: "playwright/.auth/admin.json" });
let warehousePage: WarehousePage;
test.beforeEach(({ page }) => {
warehousePage = new WarehousePage(page);
});

test("TC: SALEOR_30 Create basic warehouse @e2e @warehouse", async ({
page,
}) => {
const warehousePage = new WarehousePage(page);

await page.goto(URL_LIST.warehouses);
test("TC: SALEOR_30 Create basic warehouse @e2e @warehouse", async () => {
await warehousePage.gotoWarehouseListView();
await warehousePage.clickCreateNewWarehouseButton();
await warehousePage.completeWarehouseForm();
await warehousePage.clickSaveButton();
await warehousePage.basePage.expectSuccessBanner();
});
test("TC: SALEOR_100 Edit warehouse @e2e @warehouse", async () => {
await warehousePage.gotoExistingWarehousePage(
WAREHOUSES.warehouseToBeEdited.id,
);

await warehousePage.typeWarehouseName("edited warehouse");
await warehousePage.typeCompanyName("Umbrella");
await warehousePage.typeAddressLine1("edited warehouse address 1");
await warehousePage.typeAddressLine2("edited warehouse address 2");
await warehousePage.typePhone("+48655922888");
await warehousePage.rightSideDetailsPage.clickPublicStockButton();
await warehousePage.rightSideDetailsPage.clickPickupAllWarehousesButton();
await warehousePage.clickSaveButton();
await warehousePage.basePage.expectSuccessBanner();
});
test("TC: SALEOR_101 Delete warehouse @e2e @warehouse", async () => {
await warehousePage.gotoWarehouseListView();
await warehousePage.clickDeleteWarehouseButton(
WAREHOUSES.warehouseToBeDeleted.name,
);

await warehousePage.deleteWarehouseDialog.clickDeleteButton();
await warehousePage.expectSuccessBanner();
await expect(warehousePage.warehousesList).not.toContainText(
WAREHOUSES.warehouseToBeDeleted.name,
);
});
3 changes: 2 additions & 1 deletion src/warehouses/components/WarehouseList/WarehouseList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const WarehouseList: React.FC<WarehouseListProps> = props => {
/>
</TableRowLink>
</TableFooter>
<TableBody>
<TableBody data-test-id="warehouses-list">
{renderCollection(
warehouses,
warehouse => (
Expand Down Expand Up @@ -158,6 +158,7 @@ const WarehouseList: React.FC<WarehouseListProps> = props => {
</IconButton>
<TableButtonWrapper>
<IconButton
data-test-id="delete-button"
variant="secondary"
color="primary"
onClick={stopPropagation(() => onRemove(warehouse?.id))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { makeStyles } from "@saleor/macaw-ui";
import React from "react";
import { FormattedMessage } from "react-intl";

import { WarehouseDetailsPageFormData } from "./../WarehouseDetailsPage";
import { WarehouseDetailsPageFormData } from "../WarehouseDetailsPage";
import messages from "./messages";

export interface WarehouseSettingsProps {
Expand Down Expand Up @@ -175,7 +175,7 @@ const WarehouseSettings: React.FC<WarehouseSettingsProps> = ({
<CardTitle
title={<FormattedMessage {...messages.warehouseSettingsStockTitle} />}
/>
<CardContent>
<CardContent data-test-id="stock-settings-section">
<RadioGroupField
disabled={disabled}
choices={isPrivateChoices}
Expand Down

0 comments on commit 460f033

Please sign in to comment.