UNPKG

@wernerthiago/teo

Version:

Test Execution Optimizer

61 lines (43 loc) 2.38 kB
// Product management tests import { test, expect } from '@playwright/test' test.describe('Product Management', () => { test('should display product catalog', async ({ page }) => { await page.goto('/products') await expect(page.locator('[data-testid="product-grid"]')).toBeVisible() await expect(page.locator('[data-testid="product-item"]')).toHaveCount(10) }) test('should filter products by category', async ({ page }) => { await page.goto('/products') await page.selectOption('[data-testid="category-filter"]', 'electronics') await page.waitForTimeout(1000) const products = page.locator('[data-testid="product-item"]') await expect(products).toHaveCountGreaterThan(0) // Verify all products are electronics const categories = await products.locator('[data-testid="product-category"]').allTextContents() expect(categories.every(cat => cat.toLowerCase().includes('electronics'))).toBe(true) }) test('should search products by name', async ({ page }) => { await page.goto('/products') await page.fill('[data-testid="search-input"]', 'laptop') await page.click('[data-testid="search-button"]') const products = page.locator('[data-testid="product-item"]') await expect(products).toHaveCountGreaterThan(0) // Verify search results contain the search term const titles = await products.locator('[data-testid="product-title"]').allTextContents() expect(titles.some(title => title.toLowerCase().includes('laptop'))).toBe(true) }) test('should view product details', async ({ page }) => { await page.goto('/products') await page.click('[data-testid="product-item"]:first-child') await expect(page.locator('[data-testid="product-title"]')).toBeVisible() await expect(page.locator('[data-testid="product-description"]')).toBeVisible() await expect(page.locator('[data-testid="product-price"]')).toBeVisible() await expect(page.locator('[data-testid="add-to-cart-button"]')).toBeVisible() }) test('should add product to cart', async ({ page }) => { await page.goto('/products/1') await page.click('[data-testid="add-to-cart-button"]') await expect(page.locator('[data-testid="cart-notification"]')).toBeVisible() await expect(page.locator('[data-testid="cart-count"]')).toContainText('1') }) })