-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Tests refactor pageobjects (#26245)
Co-authored-by: Weslley de Campos <weslley.campos@objective.com.br>
- Loading branch information
1 parent
9b523a6
commit c6663cb
Showing
47 changed files
with
1,836 additions
and
2,716 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 |
---|---|---|
@@ -1,39 +1,46 @@ | ||
import { test, expect } from './utils/test'; | ||
import { Global, LoginPage } from './pageobjects'; | ||
import { Page } from '@playwright/test' | ||
|
||
test.describe('[Forgot Password]', () => { | ||
let loginPage: LoginPage; | ||
let global: Global; | ||
import { Auth } from './page-objects'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
loginPage = new LoginPage(page); | ||
global = new Global(page); | ||
test.describe('Forgot Password', () => { | ||
let page: Page; | ||
let pageAuth: Auth; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage(); | ||
pageAuth = new Auth(page); | ||
}); | ||
|
||
test.beforeAll(async () => { | ||
await page.goto('/'); | ||
await loginPage.btnForgotPassword.click(); | ||
await pageAuth.btnForgotPassword.click(); | ||
}); | ||
|
||
test('expect be required', async () => { | ||
loginPage.btnSubmit.click(); | ||
test('expect trigger a validation error if no email is provided', async () => { | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
await expect(pageAuth.textErrorEmail).toBeVisible(); | ||
}); | ||
|
||
test('expect invalid for email without domain', async () => { | ||
await loginPage.emailField.type('mail'); | ||
await loginPage.btnSubmit.click(); | ||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
test('expect trigger a validation if a invalid email is provided (1)', async () => { | ||
await pageAuth.inputEmail.type('mail'); | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await expect(pageAuth.textErrorEmail).toBeVisible(); | ||
}); | ||
|
||
test('expect be invalid for email with invalid domain', async () => { | ||
await loginPage.emailField.type('mail@mail'); | ||
await loginPage.btnSubmit.click(); | ||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
test('expect trigger a validation if a invalid email is provided (2)', async () => { | ||
await pageAuth.inputEmail.type('mail@mail'); | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await expect(pageAuth.textErrorEmail).toBeVisible(); | ||
}); | ||
|
||
test('expect user type a valid email', async () => { | ||
await loginPage.emailField.type('mail@mail.com'); | ||
await loginPage.btnSubmit.click(); | ||
await expect(global.getToastBarSuccess).toBeVisible(); | ||
test('expect to show a success toast if a valid email is provided', async () => { | ||
await pageAuth.inputEmail.type('mail@mail.com'); | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await expect(pageAuth.toastSuccess).toBeVisible(); | ||
}); | ||
}); |
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,38 +1,48 @@ | ||
import { test, expect } from './utils/test'; | ||
import { registerUser } from './utils/mocks/userAndPasswordMock'; | ||
import { LoginPage } from './pageobjects'; | ||
|
||
test.describe('[Register]', () => { | ||
let loginPage: LoginPage; | ||
import { Page } from '@playwright/test'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
loginPage = new LoginPage(page); | ||
import { Auth } from './page-objects'; | ||
|
||
test.describe('Register', () => { | ||
let page: Page; | ||
let pageAuth: Auth; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
page = await browser.newPage(); | ||
pageAuth = new Auth(page); | ||
}); | ||
|
||
test.beforeEach(async () => { | ||
await page.goto('/'); | ||
await pageAuth.btnRegister.click(); | ||
}); | ||
|
||
test('expect user click in register button without data', async () => { | ||
await loginPage.btnRegister.click(); | ||
await loginPage.btnSubmit.click(); | ||
test('expect trigger a validation error if no data is provided', async () => { | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await expect(loginPage.nameInvalidText).toBeVisible(); | ||
await expect(loginPage.emailInvalidText).toBeVisible(); | ||
await expect(loginPage.passwordInvalidText).toBeVisible(); | ||
await expect(pageAuth.textErrorName).toBeVisible(); | ||
await expect(pageAuth.textErrorEmail).toBeVisible(); | ||
await expect(pageAuth.textErrorPassword).toBeVisible(); | ||
}); | ||
|
||
test('expect user click in register button with different password', async () => { | ||
await loginPage.btnRegister.click(); | ||
await loginPage.passwordField.type(registerUser.password); | ||
await loginPage.emailField.type(registerUser.email); | ||
await loginPage.nameField.type(registerUser.name); | ||
await loginPage.confirmPasswordField.type('wrong_password'); | ||
test('expect trigger a validation error if different password is provided', async () => { | ||
await pageAuth.inputName.type(faker.name.firstName()); | ||
await pageAuth.inputEmail.type(faker.internet.email()); | ||
await pageAuth.inputPassword.type('any_password'); | ||
await pageAuth.inputPasswordConfirm.type('any_password_2'); | ||
await pageAuth.btnSubmit.click(); | ||
|
||
await loginPage.btnSubmit.click(); | ||
await expect(loginPage.confirmPasswordInvalidText).toBeVisible(); | ||
await expect(loginPage.confirmPasswordInvalidText).toHaveText('The password confirmation does not match password'); | ||
await expect(pageAuth.textErrorPasswordConfirm).toBeVisible(); | ||
}); | ||
|
||
test('expect new user is created', async () => { | ||
await loginPage.btnRegister.click(); | ||
await loginPage.registerNewUser(registerUser); | ||
test('expect successfully register a new user', async () => { | ||
await pageAuth.inputName.type(faker.name.firstName()); | ||
await pageAuth.inputEmail.type(faker.internet.email()); | ||
await pageAuth.inputPassword.type('any_password'); | ||
await pageAuth.inputPasswordConfirm.type('any_password'); | ||
await pageAuth.btnSubmit.click(); | ||
await pageAuth.btnRegisterConfirmUsername.click(); | ||
}); | ||
}); |
Oops, something went wrong.