diff --git a/.changeset/olive-walls-joke.md b/.changeset/olive-walls-joke.md new file mode 100644 index 00000000000..24ad1bbeee3 --- /dev/null +++ b/.changeset/olive-walls-joke.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": minor +--- + +Home page critical test migration to playwright diff --git a/playwright/pages/homePage.ts b/playwright/pages/homePage.ts index c56190e7ff3..32f08cd65af 100644 --- a/playwright/pages/homePage.ts +++ b/playwright/pages/homePage.ts @@ -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(); + } } diff --git a/playwright/tests/home.spec.ts b/playwright/tests/home.spec.ts new file mode 100644 index 00000000000..58480572938 --- /dev/null +++ b/playwright/tests/home.spec.ts @@ -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(); +});