Skip to content

Commit 46ce6e1

Browse files
refactor: update test configurations and enhance login/register flows
1 parent 351b7b9 commit 46ce6e1

6 files changed

Lines changed: 31 additions & 18 deletions

File tree

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { defineConfig, devices } from '@playwright/test';
1414
export default defineConfig({
1515
testDir: './tests',
1616
/* Run tests in files in parallel */
17-
fullyParallel: true,
17+
fullyParallel: false,
1818
/* Fail the build on CI if you accidentally left test.only in the source code. */
1919
forbidOnly: !!process.env.CI,
2020
/* Retry on CI only */

tests/login.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@ test.beforeEach(async ({ page }) => {
77
await page.goto('/')
88
})
99

10-
test.describe('Authentication tests', () => {
10+
test.describe('Register and Authentication tests', () => {
1111

1212
test('CT001 - Should be able to create a new user with success', async ({ page }) => {
1313
const register = new RegisterFacade(page);
14+
const auth = new AuthFacade(page);
15+
1416
await register.registerAs("usuarioteste@gmail.com",
1517
"Testezinho da Silva",
1618
"12345",
1719
"12345");
18-
});
1920

20-
test('CT002 - Should be able to logging in with an exist user', async ({ page }) => {
21-
const auth = new AuthFacade(page);
21+
await register.registerConfirmation();
22+
23+
// Do login at the same flow because the application doesn't have database, so it saves only in memory
2224
await auth.loginAs("usuarioteste@gmail.com", "12345");
25+
2326
});
2427

28+
// test('CT002 - Should be able to logging in with an exist user', async ({ page }) => {
29+
// const auth = new AuthFacade(page);
30+
// await auth.loginAs("usuarioteste@gmail.com", "12345");
31+
// });
32+
2533
});

ui/facade/auth-facade.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Page } from '@playwright/test';
1+
import { expect, Page } from '@playwright/test';
22
import { LoginPage } from '../pages/login-page';
33

44
export class AuthFacade {
@@ -9,5 +9,7 @@ export class AuthFacade {
99
await loginPage.fillEmail(email);
1010
await loginPage.fillPassword(password);
1111
await loginPage.clickLoginButton();
12+
await this.page.waitForURL("https://bugbank.netlify.app/home");
13+
await expect(this.page).toHaveURL("https://bugbank.netlify.app/home");
1214
}
1315
}

ui/facade/register-facade.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Page } from '@playwright/test';
1+
import { expect, Page } from '@playwright/test';
22
import { LoginPage } from '../pages/login-page';
33
import { RegisterPage } from '../pages/register-page';
44

55
export class RegisterFacade {
66
constructor(private page: Page) { }
77

88
async registerAs(email: string, name: string, password: string, confirmationPassword: string) {
9-
109
const loginPage = new LoginPage(this.page);
1110
const registerPage = new RegisterPage(this.page);
1211

@@ -18,7 +17,11 @@ export class RegisterFacade {
1817
await registerPage.clickRegisterButton();
1918
}
2019

21-
// async registerConfiration() {
22-
// const registerPage = new RegisterPage(this.page);
23-
// }
20+
async registerConfirmation() {
21+
const registerPage = new RegisterPage(this.page);
22+
23+
await expect(registerPage.confirmationMessage).toBeVisible();
24+
await expect(registerPage.confirmationIcon).toBeVisible();
25+
await registerPage.closeButton.click();
26+
}
2427
}

ui/pages/login-page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export class LoginPage {
1111

1212
constructor(page: Page) {
1313
this.page = page;
14-
this.emailInput = page.getByPlaceholder('Informe seu e-mail');
15-
this.passwordInput = page.getByPlaceholder('Informe sua senha');
14+
this.emailInput = page.locator('form').filter({ hasText: 'E-mailSenhaAcessarRegistrarConheça nossos requisitosA aplicação não conta com' }).getByPlaceholder('Informe seu e-mail');
15+
this.passwordInput = page.locator('form').filter({ hasText: 'E-mailSenhaAcessarRegistrarConheça nossos requisitosA aplicação não conta com' }).getByPlaceholder('Informe sua senha');
1616
this.loginButton = page.getByRole('button', { name: 'Acessar' });
1717
this.registerButton = page.getByRole('button', { name: 'Registrar' });
1818
}
@@ -30,7 +30,7 @@ export class LoginPage {
3030
}
3131

3232
async clickRegisterButton() {
33-
await this.loginButton.click();
33+
await this.registerButton.click();
3434
}
3535

3636
}

ui/pages/register-page.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export class RegisterPage {
1616

1717
constructor(page: Page) {
1818
this.page = page;
19-
this.emailRegisterInput = page.locator('form').filter({ hasText: 'Voltar ao loginE-mailÉ campo' }).getByPlaceholder('Informe seu e-mail');
19+
this.emailRegisterInput = page.locator('form').filter({ hasText: 'Voltar ao loginE-' }).getByPlaceholder('Informe seu e-mail');
2020
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');
21+
this.passwordRegisterInput = page.locator('form').filter({ hasText: 'Voltar ao loginE-' }).getByPlaceholder('Informe sua senha');
2222
this.passwordConfirmationRegisterInput = page.getByRole('textbox', { name: 'Informe a confirmação da senha' });
2323
this.accountWithOrWithoutBalanceToggle = page.locator('div').filter({ hasText: /^Criar conta com saldo \?$/ }).locator('span');
2424
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');
25+
this.confirmationMessage = page.getByText(/A conta \d+-\d+ foi criada com/);;
26+
this.confirmationIcon = page.locator('div').filter({ hasText: /^A conta \d+-\d+ foi criada com sucessoFechar$/ }).getByRole('img');
2727
this.closeButton = page.getByText('Fechar');
2828
}
2929

0 commit comments

Comments
 (0)