Last active
February 1, 2023 19:44
-
-
Save nadvolod/76be1456544c7a40e843004af664f038 to your computer and use it in GitHub Desktop.
Flawed automated playwright tests
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
test('Dashboard page should not have any WCAG A violations', async ({ page }) => { | |
const authentication = new Authentication(page); | |
const loginPage = new LoginPage(page); | |
const dashboardPage = new DashboardPage(page); | |
await loginPage.login(user) | |
// Wait until the logo is visible - default 30000 | |
await dashboardPage.waitForLogo() | |
await page.getByRole('button', { name: 'Log In' }).click(); | |
await authentication.loginWith2FA(user) | |
await expect(loginPage.isErrorPresent()).toBeTruthy(); | |
await expect(loginPage.invalidUsernameIcon.toBeVisible()).toBeTruthy(); | |
// await expect(page.locator('#invalid-username-icon')).toBeVisible() | |
// await expect(page.locator('#invalid-password-icon')).toBeVisible() | |
// better approach | |
await expect(dashboardPage.toBeLoaded()); | |
// bad approach | |
// await page.waitForSelector(dashboardPage.logoTxt, {timeout: 30000}); | |
expect(await dashboardPage.getViolationsWithTags(tags)).toEqual([]); | |
}); | |
test('Login with valid data', async ({page}) => { | |
const loginPage = new LoginPage(page); | |
const authentication = new Authentication(page); | |
const dashboardPage = new DashboardPage(page); | |
await loginPage.login(user) | |
await authentication.loginWith2FA(user) | |
expect(dashboardPage.isLogoVisible()).toBeTruthy(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment