Skip to content

Commit

Permalink
Migrate home page test (#4342)
Browse files Browse the repository at this point in the history
* migrated create products tests to Playwright

* permission tests with playwright wip

* migrated navigation tests to playwright

* switch to camel case in pw project - remove faker random number generator

* login function in setup unification, wait for success banner extended to 15s

* migrated create basic variant test to playwright

* Create full info variant - via edit variant page

* Create basic order test

* changeset update, removed empty file

* playground for grid

* Home page critical test migration to playwright
  • Loading branch information
wojteknowacki authored Oct 23, 2023
1 parent f39cc69 commit ae0b8da
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-walls-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Home page critical test migration to playwright
45 changes: 41 additions & 4 deletions playwright/pages/homePage.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
import type {
Locator,
Page,
} from "@playwright/test";
import { expect, Locator, Page } from "@playwright/test";

export class HomePage {
readonly page: Page;
readonly welcomeMessage: Locator;
readonly sales: Locator;
readonly orders: Locator;
readonly activity: Locator;
readonly topProducts: Locator;
readonly ordersReadyToFulfill: Locator;
readonly paymentsWaitingForCapture: Locator;
readonly productsOutOfStock: Locator;
readonly channelSelect: Locator;
readonly channelOptions: Locator;

constructor(page: Page) {
this.page = page;
this.channelSelect = page.getByTestId("app-channel-select");
this.channelOptions = page.locator("[data-test-id*='select-field-option']");
this.welcomeMessage = page.getByTestId("home-header");
this.sales = page.getByTestId("sales-analytics");
this.orders = page.getByTestId("orders-analytics");
this.activity = page.getByTestId("activity-card");
this.topProducts = page.getByTestId("top-products");
this.ordersReadyToFulfill = page.getByTestId("orders-to-fulfill");
this.paymentsWaitingForCapture = page.getByTestId("orders-to-capture");
this.productsOutOfStock = page.getByTestId("products-out-of-stock");
}
async goto() {
await this.page.goto("/");
}

async clickChannelSelectButton() {
await this.channelSelect.click();
}

async selectDifferentChannelThanGiven(defaultChannelName: string) {
await this.channelOptions
.filter({ hasNotText: defaultChannelName })
.first()
.click();
}

async expectHomePageElementsToBeVisible() {
await expect(this.sales).toBeVisible();
await expect(this.orders).toBeVisible();
await expect(this.activity).toBeVisible();
await expect(this.topProducts).toBeVisible();
await expect(this.ordersReadyToFulfill).toBeVisible();
await expect(this.paymentsWaitingForCapture).toBeVisible();
await expect(this.productsOutOfStock).toBeVisible();
}
}
23 changes: 23 additions & 0 deletions playwright/tests/home.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { HomePage } from "@pages/homePage";
import { expect, test } from "@playwright/test";

test.use({ storageState: "playwright/.auth/admin.json" });

test("TC: SALEOR_29 Correct information on dashboard home page @basic-regression", async ({
page,
}) => {
const homePage = new HomePage(page);

await page.goto("/");
await expect(homePage.channelSelect).toBeVisible({ timeout: 10000 });

await homePage.expectHomePageElementsToBeVisible();
const defaultChannelName = await homePage.channelSelect.innerText();

await homePage.clickChannelSelectButton();
await homePage.selectDifferentChannelThanGiven(defaultChannelName);
const selectedChannelName = await homePage.channelSelect.innerText();

await expect(defaultChannelName).not.toEqual(selectedChannelName);
await homePage.expectHomePageElementsToBeVisible();
});

0 comments on commit ae0b8da

Please sign in to comment.