forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Home Page Object with Topics Dropdown component and tests
- Added an id attribute to the <div> element of ComboboxTopics.vue for improved accessibility and easier testing. - Introduced HomePage page object - Introduced TopicsDropdown component object - Updated fixtures and added home-page.spec.ts file with initial tests - Activated the accessibility test for Landing Page and confirmed it passes - Skipping Home Page accessibility for now so not to block (many failures)
- Loading branch information
1 parent
9f2d01b
commit 47b8583
Showing
6 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Page, Locator } from "@playwright/test"; | ||
import BaseComponent from "./BaseComponent"; | ||
|
||
export default class TopicsDropdown extends BaseComponent { | ||
public static readonly locators = { | ||
TOPICS_DROPDOWN: "#topics-dropdown", | ||
TOPICS_OPTIONS: "#topics-dropdown ul#isVisibleElement" | ||
}; | ||
|
||
constructor(page: Page) { | ||
super(page); | ||
this.setLocators(TopicsDropdown.locators); | ||
} | ||
|
||
get topicsDropdown(): Locator { | ||
return this.getLocator("TOPICS_DROPDOWN"); | ||
} | ||
get topicsOptions(): Locator { | ||
return this.getLocator("TOPICS_OPTIONS"); | ||
} | ||
|
||
async openTopicsDropdown(): Promise<void> { | ||
if (!(await this.topicsOptions.isVisible())) { | ||
await this.topicsDropdown.click(); | ||
} | ||
} | ||
|
||
async closeTopicsDropdown(): Promise<void> { | ||
if (await this.topicsOptions.isVisible()) { | ||
await this.topicsDropdown.click(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import { test as baseTest } from "@playwright/test"; | ||
import LandingPage from "../page-objects/LandingPage"; | ||
import HomePage from "../page-objects/HomePage"; | ||
|
||
export const test = baseTest.extend<{ landingPage: LandingPage }>({ | ||
export const test = baseTest.extend<{ | ||
landingPage: LandingPage, | ||
homePage: HomePage | ||
}>({ | ||
landingPage: async ({ page }, use) => { | ||
const landingPage = new LandingPage(page); | ||
await use(landingPage); | ||
}, | ||
homePage: async ({ page }, use) => { | ||
const homePage = new HomePage(page); | ||
await use(homePage); | ||
} | ||
}); | ||
|
||
export { expect } from "@playwright/test"; | ||
export { LandingPage }; | ||
export { LandingPage, HomePage }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
import TopicsDropdown from "../component-objects/TopicsDropdown"; | ||
import BasePage from "./BasePage"; | ||
|
||
export default class HomePage extends BasePage { | ||
public static readonly locators = { | ||
}; | ||
|
||
readonly topicsDropdown: TopicsDropdown; | ||
|
||
constructor(page: Page) { | ||
super(page, "Home Page", "/home"); | ||
this.topicsDropdown = new TopicsDropdown(page); | ||
this.setLocators(HomePage.locators); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import AxeBuilder from "@axe-core/playwright"; | ||
import { HomePage, expect, test } from "../fixtures/page-fixtures"; | ||
|
||
test.describe("Home Page", () => { | ||
test.beforeEach(async ({ homePage }) => { | ||
await homePage.goto("/home"); | ||
const { topicsDropdown } = homePage.topicsDropdown; | ||
await topicsDropdown.waitFor({ state: "visible" }); | ||
}); | ||
|
||
/* *********************************************************** */ | ||
/* ACCESSIBILITY TESTS */ | ||
/* *********************************************************** */ | ||
|
||
// Test accessibility of the home page (skip this test for now). | ||
// Note: Check to make sure that this is eventually done for light and dark modes. | ||
test.skip("There are no detectable accessibility issues", async ({ | ||
homePage, | ||
}, testInfo) => { | ||
const results = await new AxeBuilder({ page: homePage.getPage }) | ||
.withTags(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"]) | ||
.analyze(); | ||
|
||
await testInfo.attach("accessibility-scan-results", { | ||
body: JSON.stringify(results, null, 2), | ||
contentType: "application/json", | ||
}); | ||
|
||
expect(results.violations).toEqual([]); | ||
}); | ||
|
||
test("The topics dropdown should be functional", async ({ homePage }) => { | ||
await homePage.topicsDropdown.openTopicsDropdown(); | ||
await expect(homePage.topicsDropdown.topicsOptions).toBeVisible(); | ||
await homePage.topicsDropdown.closeTopicsDropdown(); | ||
await expect(homePage.topicsDropdown.topicsOptions).toBeHidden(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters