Skip to content

Commit

Permalink
Filter products by channel availability test (#4540)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojteknowacki committed Dec 15, 2023
1 parent 9870979 commit d06043b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-bananas-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Filter products by channel availability test
10 changes: 10 additions & 0 deletions playwright/data/e2eTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ export const PRODUCTS = {
id: "UHJvZHVjdDo3NjE%3D",
info: "Single product type to be updated",
},
productAvailableOnlyInPlnChannel: {
id: "UHJvZHVjdDo3NjM%3D",
name: "a beer available only in pln channel",
info: "Product available only in PLN channel",
},
productAvailableOnlyInUsdChannel: {
id: "UHJvZHVjdDo3NjQ%3D",
name: "a beer available only in USD channel",
info: "Product available only in USD channel",
},
productToAddVariants: {
id: "UHJvZHVjdDo3Mjk%3D",
name: "beer with variants",
Expand Down
5 changes: 5 additions & 0 deletions playwright/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class BasePage {
.locator('[class="clip-region"]')
.locator("textarea"),
readonly successBanner = page.locator(LOCATORS.successBanner),
readonly filterButton = page.getByTestId("filters-button"),
readonly errorBanner = page.locator(LOCATORS.errorBanner),
readonly infoBanner = page.locator(LOCATORS.infoBanner),
readonly previousPagePaginationButton = page.getByTestId(
Expand All @@ -38,6 +39,10 @@ export class BasePage {
return cellText;
}

async clickFilterButton() {
await this.filterButton.click();
}

async typeInSearchOnListView(searchItem: string) {
await this.searchInputListView.fill(searchItem);
}
Expand Down
37 changes: 37 additions & 0 deletions playwright/pages/pageElements/filtersPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { Page } from "@playwright/test";

export class FiltersPage {
readonly page: Page;
constructor(
page: Page,
readonly saveFiltersButton = page.getByTestId("save-filters-button"),
readonly rightInput = page.getByTestId("right-0"),
readonly dropDownOptions = page.getByTestId("select-option"),
readonly leftInput = page.getByTestId("left-0"),
readonly showFiltersButton = page.getByTestId("filters-button"),
readonly addFilterButton = page.getByTestId("add-filter-button"),
) {
this.page = page;
}

async clickAddFilterButton() {
await this.addFilterButton.click();
}
async clickLeftInput() {
await this.leftInput.click();
}
async clickRightInput() {
await this.rightInput.click();
}
async clickSaveFiltersButton() {
await this.saveFiltersButton.click();
}

async pickFilter(filterKind: string, channelName: string) {
await this.clickAddFilterButton();
await this.clickLeftInput();
await this.dropDownOptions.filter({ hasText: filterKind }).click();
await this.clickRightInput();
await this.dropDownOptions.filter({ hasText: channelName }).click();
}
}
3 changes: 3 additions & 0 deletions playwright/pages/productPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { expect, Page } from "@playwright/test";

import { BasePage } from "./basePage";
import { DeleteProductDialog } from "./dialogs/deleteProductDialog";
import { FiltersPage } from "./pageElements/filtersPage";

const productName = `e2e-productName-${faker.datatype.number()}`;
const productDescription = `e2e-productDescription-${faker.datatype.number()}`;
Expand All @@ -23,6 +24,7 @@ export class ProductPage {
readonly basePage: BasePage;
readonly channelSelectDialog: ChannelSelectDialog;
readonly deleteProductDialog: DeleteProductDialog;
readonly filtersPage: FiltersPage;

constructor(
page: Page,
Expand Down Expand Up @@ -84,6 +86,7 @@ export class ProductPage {
this.channelSelectDialog = new ChannelSelectDialog(page);
this.metadataSeoPage = new MetadataSeoPage(page);
this.rightSideDetailsPage = new RightSideDetailsPage(page);
this.filtersPage = new FiltersPage(page);
}

async gotoCreateProductPage(productTypeId: string) {
Expand Down
28 changes: 28 additions & 0 deletions playwright/tests/product.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ test("TC: SALEOR_58 As an admin I should be able use pagination on product list
1,
1,
);

await expect(
firstPageProductName,
`Second side first product name: ${secondPageProductName} should be visible and be different than: ${firstPageProductName}`,
Expand All @@ -249,3 +250,30 @@ test("TC: SALEOR_58 As an admin I should be able use pagination on product list
`Product from first page: ${firstPageProductName} should be visible again`,
).toContainText(firstPageProductName);
});

test("TC: SALEOR_59 As an admin I should be able to filter products by channel on product list view @basic-regression @product @e2e", async ({
page,
}) => {
const productPage = new ProductPage(page);
await productPage.gotoProductListPage();
await productPage.basePage.waitForGrid();

await expect(
productPage.basePage.gridCanvas,
`Product: ${PRODUCTS.productAvailableOnlyInUsdChannel.name} should be visible on grid table`,
).toContainText(PRODUCTS.productAvailableOnlyInUsdChannel.name);

await productPage.basePage.clickFilterButton();
await productPage.filtersPage.pickFilter("Channel", "Channel-PLN");
await productPage.filtersPage.clickSaveFiltersButton();
await productPage.basePage.waitForGrid();

await expect(
productPage.basePage.gridCanvas,
`Product: ${PRODUCTS.productAvailableOnlyInUsdChannel.name} should not be visible on grid table`,
).not.toContainText(PRODUCTS.productAvailableOnlyInUsdChannel.name);
await expect(
productPage.basePage.gridCanvas,
`Product: ${PRODUCTS.productAvailableOnlyInPlnChannel.name} should be visible on grid table`,
).toContainText(PRODUCTS.productAvailableOnlyInPlnChannel.name);
});

0 comments on commit d06043b

Please sign in to comment.