From 4175ea857e27feace5ba868dee8ef24dbd4d8e1c Mon Sep 17 00:00:00 2001 From: Vikram Boinapalli <178916392+VIB05-NHSE@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:37:59 +0100 Subject: [PATCH] Task/dr 1118 testcase for mylocations (#163) * DR-1118 Test mylocations page * DR-1118 Test mylocations pageformats * DR-1118 Review comments updated * DR-1118 Review comments updated0.1 * DR-1118 Location page updated * DR-1118 Location page cleared * DR-1118 Location page updated * DR-1118 Location page lineremoved * DR-1118 New branch created --------- Co-authored-by: Vikram Boinapalli Co-authored-by: -NHSE <+VIB05-NHSE@users.noreply.github.com> --- tests/ui/package.json | 2 +- tests/ui/src/pages/base-page.ts | 17 ++++++++++ tests/ui/src/pages/view-locations-page.ts | 23 +++++++++++++ tests/ui/test/specs/view-locations.spec.ts | 39 ++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/ui/src/pages/base-page.ts create mode 100644 tests/ui/src/pages/view-locations-page.ts create mode 100644 tests/ui/test/specs/view-locations.spec.ts diff --git a/tests/ui/package.json b/tests/ui/package.json index 69f7ff80..9add015b 100644 --- a/tests/ui/package.json +++ b/tests/ui/package.json @@ -22,7 +22,7 @@ "test:debug": "npx cross-env test_env=dev npx playwright test --debug", "test:test_env": "npx cross-env test_env=dev playwright test", "test:tagged": "npx cross-env test_env=dev playwright test --grep @Test ", - "test_pipeline": "npx playwright test", + "test_pipeline": "npx playwright test --grep-invert @prototype", "allure": "allure generate --single-file -c -o allure-reports", "filecount": "npx ts-node ./utilities/fileCount.ts", "axe_report": "cat ./accessibility-reports/artifacts/*.html >> ./accessibility-reports/artifacts/FinalAccessibilityReport.html" diff --git a/tests/ui/src/pages/base-page.ts b/tests/ui/src/pages/base-page.ts new file mode 100644 index 00000000..85dcc4ea --- /dev/null +++ b/tests/ui/src/pages/base-page.ts @@ -0,0 +1,17 @@ +import { Locator, Page } from "@playwright/test"; +export default class BasePage { + constructor(readonly page: Page) { + this.page = page; + } + + static readonly userId_txt = "User ID"; + static readonly password_txt = "password"; + static readonly continue_btn = "Continue"; + + //methods + async login() { + await this.page.getByLabel(BasePage.userId_txt).fill("username"); + await this.page.getByLabel(BasePage.password_txt).fill("password"); + await this.page.getByRole("button", { name: "Continue" }).click(); + } +} diff --git a/tests/ui/src/pages/view-locations-page.ts b/tests/ui/src/pages/view-locations-page.ts new file mode 100644 index 00000000..f8d9e684 --- /dev/null +++ b/tests/ui/src/pages/view-locations-page.ts @@ -0,0 +1,23 @@ +import { Locator, Page } from "@playwright/test"; +export default class ViewLocationsPage { + constructor(readonly page: Page) { + this.page = page; + } + + static readonly myLocations_lbl = "My locations"; + static readonly reports_lbl = "Reports"; + static readonly downloadReport_btn = "Continue"; + + // Getters + getMyLocationsLabel(): Locator { + return this.page.getByRole("heading", { name: "My locations" }); + } + + getReportsLabel(): Locator { + return this.page.getByRole("heading", { name: "Reports" }); + } + + getDownloadReportButton(): Locator { + return this.page.getByRole("button", { name: "Download Report" }); + } +} diff --git a/tests/ui/test/specs/view-locations.spec.ts b/tests/ui/test/specs/view-locations.spec.ts new file mode 100644 index 00000000..36deebe6 --- /dev/null +++ b/tests/ui/test/specs/view-locations.spec.ts @@ -0,0 +1,39 @@ +import { test, expect } from "@playwright/test"; +import { allure } from "allure-playwright"; +import ViewLocationsPage from "../../src/pages/view-locations-page"; +import BasePage from "../../src/pages/base-page"; + +let viewLcPage: ViewLocationsPage; +let basePage: BasePage; +let pageTitle: string = "UEC Capacity Management"; + +test.describe("As a user I want to be able to view the locations", () => { + test.beforeEach(async ({ page }, testInfo) => { + await allure.parentSuite(testInfo.project.name); + await allure.suite("Tests for view locations journeys"); + await allure.subSuite("Tests for locations landing page"); + viewLcPage = new ViewLocationsPage(page); + basePage = new BasePage(page); + await test.step("Navigate to landing page", async () => { + await page.goto("/prototype"); + await test.step("Enter user name and password", async () => { + await basePage.login(); + }); + await test.step("Verify Title of the page", async () => { + await expect(page).toHaveTitle(pageTitle); + }); + }); + }); +//test my location page + test("My locations page is presented correctly", { tag: ["@prototype"] }, async () => { + await test.step(" My locations label is visible", async () => { + await expect.soft(viewLcPage.getMyLocationsLabel()).toHaveText("My locations"); + }); + await test.step(" The Reports section is visible", async () => { + await expect(viewLcPage.getReportsLabel()).toBeVisible(); + }); + await test.step(" The Download Report button is visible", async () => { + await expect(viewLcPage.getDownloadReportButton()).toBeVisible(); + }); + }); +});