-
Notifications
You must be signed in to change notification settings - Fork 3
[WD-22490] chore: update playwright tests #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
24cc15c
updated tests
muhammad-ali-pk 30ddd6c
fix failing test
muhammad-ali-pk 7aee96e
added table view tests
muhammad-ali-pk 5c636f3
Merge branch 'main' into update-playwright-tests
muhammad-ali-pk 1faa733
Merge branch 'main' into update-playwright-tests
muhammad-ali-pk 2f37bff
Merge branch 'main' into update-playwright-tests
muhammad-ali-pk 66af00e
Address comments
muhammad-ali-pk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
| export {}; | ||
|
|
||
| declare global { | ||
| interface Window { | ||
| __E2E_TESTING__?: boolean; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,47 @@ | ||
| import { Page, expect } from "@playwright/test"; | ||
|
|
||
| export async function removeWebpage(page: Page, JIRA_TASKS: string[]): Promise<void> { | ||
| page.getByRole("button", { name: /Request removal/i }).click(); | ||
| const modal = page.locator(".p-modal").first(); | ||
| await expect(modal).toBeVisible(); | ||
| await expect(page.getByRole("heading", { name: /Submit request for page removal/i })).toBeVisible(); | ||
| await modal.locator('input[type="date"]').fill(new Date().toISOString().split("T")[0]); | ||
| const checkboxes = await page.locator("input[type='checkbox'][required]"); | ||
| if (checkboxes) { | ||
| const checkboxCount = await checkboxes.count(); | ||
| for (let i = 0; i < checkboxCount; i++) { | ||
| await checkboxes.nth(i).check(); | ||
| } | ||
| } | ||
|
|
||
| const responsePromise = page.waitForResponse((response) => response.url().includes("request-removal")); | ||
| await modal.getByRole("button", { name: /Submit/i }).click(); | ||
| const response = await responsePromise; | ||
|
|
||
| if (response.status() === 200) { | ||
| const responseBody = await response.json(); | ||
| if (responseBody.jira_task_id) { | ||
| JIRA_TASKS.push(responseBody.jira_task_id); | ||
| } | ||
| } | ||
|
|
||
| await expect(page.locator(".l-notification__container .p-notification--negative")).not.toBeVisible(); | ||
| } | ||
|
|
||
| export async function selectTableView(page: Page): Promise<void> { | ||
| const tableViewListItem = page.locator(".l-navigation__drawer .p-panel__content .p-side-navigation__link", { | ||
| hasText: /Table view/i, | ||
| }); | ||
| await tableViewListItem.click(); | ||
|
|
||
| await page.getByText("/Loading projects. Please wait./i").waitFor({ state: "detached" }); | ||
| } | ||
|
|
||
| export async function selectTreeView(page: Page): Promise<void> { | ||
| const treeViewListItem = page.locator(".l-navigation__drawer .p-panel__content .p-side-navigation__link", { | ||
| hasText: /Tree view/i, | ||
| }); | ||
| await treeViewListItem.click(); | ||
|
|
||
| await page.getByText("/Loading.../i").waitFor({ state: "detached" }); | ||
| } |
This file contains hidden or 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,43 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
| import { config } from "../config"; | ||
| import { selectTableView } from "../utils/common"; | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto(`${config.BASE_URL}/app`); | ||
| }); | ||
|
|
||
| test.describe("Test Table View", () => { | ||
| test("table view is visible", async ({ page }) => { | ||
| await selectTableView(page); | ||
| // expect a page showing all the projects in an accordion | ||
| expect(page.getByRole("heading", { name: /All pages/i })).toBeVisible(); | ||
| const projects = page.locator(".p-accordion__list .p-accordion__group"); | ||
| const projectCount = await projects.count(); | ||
| expect(projectCount).toBeGreaterThan(0); | ||
|
|
||
| // check all projects have pages | ||
| for (let i = 0; i < projectCount; i++) { | ||
| const project = projects.nth(i); | ||
| const projectHeading = project.locator(".p-accordion__heading"); | ||
| const projectPageCount = await projectHeading.locator(".p-badge").innerText(); | ||
| expect(parseInt(projectPageCount)).toBeGreaterThan(1); | ||
|
|
||
| // select each project | ||
| await project.click(); | ||
|
|
||
| // select a random page | ||
| const pages = project.locator(".p-accordion__panel table tbody tr"); | ||
| const pagesCount = await pages.count(); | ||
| const selectedPage = project | ||
| .locator(".p-accordion__panel table tbody tr") | ||
| .nth(Math.floor(Math.random() * pagesCount)); | ||
| await selectedPage.locator(".p-button--link").first().click(); | ||
|
|
||
| // check the page details are visible | ||
| await expect(page.getByText(/Description/i).first()).toBeVisible(); | ||
|
|
||
| // click the back button | ||
| await page.getByRole("button", { name: /Back/i }).click(); | ||
| } | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.