Skip to content

Commit f2d6c0f

Browse files
committed
feat/ajustes-cenarios
1 parent ae245f6 commit f2d6c0f

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

fluxos/cartilhaFluxos.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { Page } from '@playwright/test';
2-
import { InventoryPage } from '../pages/ItensPage';
2+
import { ItensPage } from '../pages/ItensPage';
33

44
export class CartFlows {
55
readonly page: Page;
6-
readonly inventoryPage: InventoryPage;
6+
readonly ItensPage: ItensPage;
77

88
constructor(page: Page) {
99
this.page = page;
10-
this.inventoryPage = new InventoryPage(page);
10+
this.ItensPage = new ItensPage(page);
1111
}
1212

1313
async adicionarKitBasicoAoCarrinho() {
14-
await this.inventoryPage.backpackAddToCartBtn.click();
15-
await this.inventoryPage.bikeLightAddToCartBtn.click();
16-
await this.inventoryPage.boltTshirtAddToCartBtn.click();
17-
await this.inventoryPage.cartLink.click();
14+
await this.ItensPage.backpackAddToCartBtn.click();
15+
await this.ItensPage.bikeLightAddToCartBtn.click();
16+
await this.ItensPage.boltTshirtAddToCartBtn.click();
17+
await this.ItensPage.cartLink.click();
1818
}
1919
}

pages/ItensPage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Page, Locator } from '@playwright/test';
22

3-
export class InventoryPage {
3+
export class ItensPage {
44
readonly page: Page;
55
readonly backpackAddToCartBtn: Locator;
66
readonly cartBadge: Locator;
@@ -22,6 +22,5 @@ export class InventoryPage {
2222
await this.backpackAddToCartBtn.click();
2323
await this.bikeLightAddToCartBtn.click();
2424
await this.boltTshirtAddToCartBtn.click();
25-
await this.cartLink.click();
2625
}
2726
}

tests/e2e/checkout.spec.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { test, expect } from '@playwright/test';
22
import { CartFlows } from '../../fluxos/cartilhaFluxos';
3-
import { CheckoutPage } from '../../pages/checkoutPage';
3+
import { CheckoutPage } from '../../pages/CheckoutPage';
4+
import { LoginPage } from '../../pages/LoginPage';
45

5-
test('Deve validar valor total com kit de 3 itens', async ({ page }) => {
6-
const cartFlow = new CartFlows(page);
7-
const checkout = new CheckoutPage(page);
6+
test.describe('Cenários de Checkout', () => {
7+
// Setup de Login obrigatório para acessar o inventário
8+
test.beforeEach(async ({ page }) => {
9+
const loginPage = new LoginPage(page);
10+
await loginPage.acessarPagina();
11+
await loginPage.realizarLogin('standard_user', 'secret_sauce');
12+
});
813

9-
await cartFlow.adicionarKitBasicoAoCarrinho();
14+
test('Deve validar valor total com kit de 3 itens', async ({ page }) => {
15+
const cartFlow = new CartFlows(page);
16+
const checkout = new CheckoutPage(page);
1017

11-
await page.locator('[data-test="checkout"]').click();
12-
await checkout.preencherDadosEContinuar('Mariana', 'Machado', '30000-000');
18+
await cartFlow.adicionarKitBasicoAoCarrinho();
1319

14-
await expect(checkout.subtotalLabel).toContainText('55.97');
20+
await page.locator('[data-test="checkout"]').click();
21+
await checkout.preencherDadosEContinuar('Marcus', 'Machado', '30000-000');
22+
23+
await expect(checkout.subtotalLabel).toContainText('55.97');
24+
});
1525
});

tests/e2e/itensCarrinho.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from '@playwright/test';
22
import { LoginPage } from '../../pages/LoginPage';
3-
import { InventoryPage } from '../../pages/ItensPage';
3+
import { ItensPage } from '../../pages/ItensPage';
44

55
test.describe('Cenários de adicionar itens no Carrinho', () => {
66
test.beforeEach(async ({ page }) => {
@@ -10,11 +10,11 @@ test.describe('Cenários de adicionar itens no Carrinho', () => {
1010
});
1111

1212
test('Deve adicionar a mochila ao carrinho com sucesso', async ({ page }) => {
13-
const inventory = new InventoryPage(page);
13+
const item = new ItensPage(page);
1414

15-
await inventory.adicionarBackpackAoCarrinho();
15+
await item.adicionarBackpackAoCarrinho();
1616

17-
await expect(inventory.cartBadge).toHaveText('1');
17+
await expect(item.cartBadge).toHaveText('3');
1818
await expect(page.locator('[data-test="remove-sauce-labs-backpack"]')).toBeVisible();
1919
});
2020
});

tests/e2e/login.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from '@playwright/test';
22
import { LoginPage } from '../../pages/LoginPage';
3-
// Importando a massa de dados
3+
44
import usuarios from '../../data/users.json';
55

66
test.describe('Cenários de Login - Swag Labs', () => {
@@ -11,7 +11,6 @@ test.describe('Cenários de Login - Swag Labs', () => {
1111
await loginPage.acessarPagina();
1212
});
1313

14-
// Loop usando os dados do JSON
1514
for (const usuario of usuarios.valid_users) {
1615
test(`Deve realizar login com sucesso para o perfil: ${usuario}`, async ({ page }) => {
1716
await loginPage.realizarLogin(usuario, usuarios.default_password);

0 commit comments

Comments
 (0)