Skip to content

Commit 351b7b9

Browse files
creating register actions
1 parent 7df75f5 commit 351b7b9

4 files changed

Lines changed: 94 additions & 1 deletion

File tree

tests/login.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { test } from '@playwright/test';
22
import { AuthFacade } from '../ui/facade/auth-facade';
3+
import { RegisterFacade } from '../ui/facade/register-facade';
34

45

56
test.beforeEach(async ({ page }) => {
@@ -8,7 +9,15 @@ test.beforeEach(async ({ page }) => {
89

910
test.describe('Authentication tests', () => {
1011

11-
test('CT001 - Should be able to logging in with an exist user', async ({ page }) => {
12+
test('CT001 - Should be able to create a new user with success', async ({ page }) => {
13+
const register = new RegisterFacade(page);
14+
await register.registerAs("usuarioteste@gmail.com",
15+
"Testezinho da Silva",
16+
"12345",
17+
"12345");
18+
});
19+
20+
test('CT002 - Should be able to logging in with an exist user', async ({ page }) => {
1221
const auth = new AuthFacade(page);
1322
await auth.loginAs("usuarioteste@gmail.com", "12345");
1423
});

ui/facade/register-facade.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Page } from '@playwright/test';
2+
import { LoginPage } from '../pages/login-page';
3+
import { RegisterPage } from '../pages/register-page';
4+
5+
export class RegisterFacade {
6+
constructor(private page: Page) { }
7+
8+
async registerAs(email: string, name: string, password: string, confirmationPassword: string) {
9+
10+
const loginPage = new LoginPage(this.page);
11+
const registerPage = new RegisterPage(this.page);
12+
13+
await loginPage.clickRegisterButton();
14+
await registerPage.fillEmail(email);
15+
await registerPage.fillName(name);
16+
await registerPage.fillPassword(password);
17+
await registerPage.fillPasswordConfirmation(confirmationPassword);
18+
await registerPage.clickRegisterButton();
19+
}
20+
21+
// async registerConfiration() {
22+
// const registerPage = new RegisterPage(this.page);
23+
// }
24+
}

ui/pages/login-page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export class LoginPage {
77
readonly emailInput: Locator;
88
readonly passwordInput: Locator;
99
readonly loginButton: Locator;
10+
readonly registerButton: Locator;
1011

1112
constructor(page: Page) {
1213
this.page = page;
1314
this.emailInput = page.getByPlaceholder('Informe seu e-mail');
1415
this.passwordInput = page.getByPlaceholder('Informe sua senha');
1516
this.loginButton = page.getByRole('button', { name: 'Acessar' });
17+
this.registerButton = page.getByRole('button', { name: 'Registrar' });
1618
}
1719

1820
async fillEmail(email: string) {
@@ -27,4 +29,8 @@ export class LoginPage {
2729
await this.loginButton.click();
2830
}
2931

32+
async clickRegisterButton() {
33+
await this.loginButton.click();
34+
}
35+
3036
}

ui/pages/register-page.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { Page, Locator } from "@playwright/test";
2+
3+
4+
export class RegisterPage {
5+
6+
readonly page: Page;
7+
readonly emailRegisterInput: Locator;
8+
readonly nameRegisterInput: Locator;
9+
readonly passwordRegisterInput: Locator;
10+
readonly passwordConfirmationRegisterInput: Locator;
11+
readonly accountWithOrWithoutBalanceToggle: Locator;
12+
readonly registerButton: Locator;
13+
readonly confirmationMessage: Locator;
14+
readonly confirmationIcon: Locator;
15+
readonly closeButton: Locator;
16+
17+
constructor(page: Page) {
18+
this.page = page;
19+
this.emailRegisterInput = page.locator('form').filter({ hasText: 'Voltar ao loginE-mailÉ campo' }).getByPlaceholder('Informe seu e-mail');
20+
this.nameRegisterInput = page.getByRole('textbox', { name: 'Informe seu Nome' });
21+
this.passwordRegisterInput = page.locator('form').filter({ hasText: 'Voltar ao loginE-mailÉ campo' }).getByPlaceholder('Informe sua senha');
22+
this.passwordConfirmationRegisterInput = page.getByRole('textbox', { name: 'Informe a confirmação da senha' });
23+
this.accountWithOrWithoutBalanceToggle = page.locator('div').filter({ hasText: /^Criar conta com saldo \?$/ }).locator('span');
24+
this.registerButton = page.getByRole('button', { name: 'Cadastrar' });
25+
this.confirmationMessage = page.getByText('A conta 329-0 foi criada com');
26+
this.confirmationIcon = page.locator('div').filter({ hasText: /^A conta 329-0 foi criada com sucessoFechar$/ }).getByRole('img');
27+
this.closeButton = page.getByText('Fechar');
28+
}
29+
30+
async fillEmail(email: string) {
31+
await this.emailRegisterInput.fill(email);
32+
}
33+
34+
async fillName(password: string) {
35+
await this.nameRegisterInput.fill(password);
36+
}
37+
38+
async fillPassword(password: string) {
39+
await this.passwordRegisterInput.fill(password);
40+
}
41+
42+
async fillPasswordConfirmation(password: string) {
43+
await this.passwordConfirmationRegisterInput.fill(password);
44+
}
45+
46+
async clickBalanceToggle() {
47+
await this.accountWithOrWithoutBalanceToggle.click();
48+
}
49+
50+
async clickRegisterButton() {
51+
await this.registerButton.click();
52+
}
53+
54+
}

0 commit comments

Comments
 (0)