-
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.
Add playwright tests with Github action
- Loading branch information
1 parent
fa6b196
commit 4a17760
Showing
7 changed files
with
89 additions
and
475 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
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,15 @@ | ||
import { test as base } from '@playwright/test' | ||
import { StandardPage } from './standard-page' | ||
|
||
type MyFixtures = { | ||
standardPage: StandardPage | ||
} | ||
|
||
export const test = base.extend<MyFixtures>({ | ||
standardPage: async ({ page }, use) => { | ||
const standardPage = new StandardPage(page) | ||
await standardPage.goto() | ||
|
||
await use(standardPage) | ||
} | ||
}) |
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,24 @@ | ||
import type { Page, Locator } from '@playwright/test' | ||
|
||
export class StandardPage { | ||
public readonly menu: Locator | ||
public readonly heading: Locator | ||
|
||
constructor(public readonly page: Page) { | ||
this.menu = this.page.getByLabel('open drawer') | ||
this.heading = this.page.locator('h1') | ||
} | ||
|
||
async goto() { | ||
await this.page.goto('/') | ||
} | ||
|
||
async gotoMenuItem(menuItemName: string) { | ||
await this.menu.click() | ||
await this.page.getByRole('menuitem', { name: menuItemName }).click() | ||
} | ||
|
||
async gotoLink(linkName: string) { | ||
await this.page.getByRole('link', { name: linkName }).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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from '@playwright/test' | ||
import { test } from './fixtures/my-test' | ||
|
||
test.describe('Navigation', () => { | ||
test('test navigation to all standardPages', async ({ standardPage }) => { | ||
await expect(standardPage.heading).toContainText('Hello human') | ||
|
||
await standardPage.gotoMenuItem('Blog') | ||
await expect(standardPage.heading).toContainText('Blog') | ||
|
||
await standardPage.gotoMenuItem('Apps') | ||
await expect(standardPage.heading).toContainText('Apps') | ||
|
||
await standardPage.gotoMenuItem('CV') | ||
await expect(standardPage.heading).toContainText('CV') | ||
|
||
await standardPage.gotoLink('Uses') | ||
await expect(standardPage.heading).toContainText('Uses') | ||
|
||
await standardPage.gotoLink('Kudos') | ||
await expect(standardPage.heading).toContainText('Kudos') | ||
|
||
await standardPage.gotoLink('Values') | ||
await expect(standardPage.heading).toContainText('Values') | ||
|
||
await standardPage.gotoLink('Privacy policy') | ||
await expect(standardPage.heading).toContainText('Privacy policy') | ||
}) | ||
}) |
Oops, something went wrong.