|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { UIhelper } from "../../utils/ui-helper"; |
| 3 | +import { Common } from "../../utils/common"; |
| 4 | +import { UI_HELPER_ELEMENTS } from "../../support/pageObjects/global-obj"; |
| 5 | + |
| 6 | +test.describe("Test ApplicationProvider", () => { |
| 7 | + let uiHelper: UIhelper; |
| 8 | + |
| 9 | + test.beforeEach(async ({ page }) => { |
| 10 | + const common = new Common(page); |
| 11 | + uiHelper = new UIhelper(page); |
| 12 | + await common.loginAsGuest(); |
| 13 | + }); |
| 14 | + |
| 15 | + test("Verify that the TestPage is rendered", async ({ page }) => { |
| 16 | + await page.goto("/application-provider-test-page"); |
| 17 | + await uiHelper.verifyText("application/provider TestPage"); |
| 18 | + await uiHelper.verifyText( |
| 19 | + "This card will work only if you register the TestProviderOne and TestProviderTwo correctly.", |
| 20 | + ); |
| 21 | + await uiHelper.verifyTextinCard("Context one", "Context one"); |
| 22 | + |
| 23 | + const contextOneFirstLocator = page |
| 24 | + .locator(UI_HELPER_ELEMENTS.MuiCard("Context one")) |
| 25 | + .first(); |
| 26 | + const contextOneSecondLocator = page |
| 27 | + .locator(UI_HELPER_ELEMENTS.MuiCard("Context one")) |
| 28 | + .last(); |
| 29 | + const contextOneIncrementButton = contextOneFirstLocator |
| 30 | + .locator("button") |
| 31 | + .filter({ hasText: "+" }); |
| 32 | + await contextOneIncrementButton.click(); |
| 33 | + expect(contextOneFirstLocator.getByText("1")).toBeVisible(); |
| 34 | + expect(contextOneSecondLocator.getByText("1")).toBeVisible(); |
| 35 | + |
| 36 | + await uiHelper.verifyTextinCard("Context two", "Context two"); |
| 37 | + const contextTwoFirstLocator = page |
| 38 | + .locator(UI_HELPER_ELEMENTS.MuiCard("Context two")) |
| 39 | + .first(); |
| 40 | + const contextTwoSecondLocator = page |
| 41 | + .locator(UI_HELPER_ELEMENTS.MuiCard("Context two")) |
| 42 | + .last(); |
| 43 | + const contextTwoIncrementButton = contextTwoFirstLocator |
| 44 | + .locator("button") |
| 45 | + .filter({ hasText: "+" }); |
| 46 | + await contextTwoIncrementButton.click(); |
| 47 | + expect(contextTwoFirstLocator.getByText("1")).toBeVisible(); |
| 48 | + expect(contextTwoSecondLocator.getByText("1")).toBeVisible(); |
| 49 | + }); |
| 50 | +}); |
0 commit comments