import { test, expect } from '@playwright/test' test.describe('Order Management E2E Tests', () => { test.beforeEach(async ({ page }) => { // Navigate to app await page.goto('http://localhost:5173') }) test('should complete full order workflow', async ({ page }) => { // Navigate to orders await page.click('a[href="/orders"]') await expect(page).toHaveURL(/orders/) // Create new order await page.click('button:has-text("New Order")') await expect(page).toHaveTitle(/Create Order/) // Select customer await page.selectOption('select[name="customerId"]', 'cust-001') // Set dates await page.fill('input[name="orderDate"]', '2026-08-01') await page.fill('input[name="dueDate"]', '2026-08-15') // Add items await page.click('button:has-text("Add Item")') await page.fill('input[name="productSku"]', 'SKU-12345') await page.fill('input[name="quantity"]', '100') await page.fill('input[name="unitPrice"]', '50') // Verify totals const subtotal = await page.locator('text=Subtotal: $5000').isVisible() expect(subtotal).toBeTruthy() // Save order await page.click('button:has-text("Create Order")') // Verify order created await expect(page).toHaveURL(/orders\//) const orderNumber = await page.locator('h1').textContent() expect(orderNumber).toMatch(/ORD-/) }) test('should filter orders by status', async ({ page }) => { await page.click('a[href="/orders"]') // Open filter await page.click('button:has-text("Filter")') // Select status await page.selectOption('select[name="status"]', 'CONFIRMED') // Apply await page.click('button:has-text("Apply")') // Verify filtered results const rows = await page.locator('table tbody tr') const count = await rows.count() expect(count).toBeGreaterThan(0) }) test('should edit order', async ({ page }) => { await page.click('a[href="/orders"]') // Find and click first order await page.click('table tbody tr:first-child') await page.click('button:has-text("Edit")') // Update status await page.selectOption('select[name="status"]', 'SHIPPED') // Save await page.click('button:has-text("Save")') // Verify update await expect(page.locator('text=Order updated successfully')).toBeVisible() }) test('should delete order with confirmation', async ({ page }) => { await page.click('a[href="/orders"]') const initialCount = await page.locator('table tbody tr').count() // Find and click first order await page.click('table tbody tr:first-child') await page.click('button:has-text("Delete")') // Confirm deletion await page.click('button:has-text("Confirm")') // Verify deletion await expect(page.locator('text=Order deleted successfully')).toBeVisible() const finalCount = await page.locator('table tbody tr').count() expect(finalCount).toBe(initialCount - 1) }) test('should calculate order totals correctly', async ({ page }) => { await page.click('a[href="/orders"]') await page.click('button:has-text("New Order")') await page.selectOption('select[name="customerId"]', 'cust-001') await page.fill('input[name="orderDate"]', '2026-08-01') await page.fill('input[name="dueDate"]', '2026-08-15') // Add multiple items await page.click('button:has-text("Add Item")') await page.fill('input[name="productSku"]', 'SKU-001') await page.fill('input[name="quantity"]', '100') await page.fill('input[name="unitPrice"]', '50') // 5000 await page.click('button:has-text("Add Item")') const skuInputs = await page.locator('input[name="productSku"]') await skuInputs.nth(1).fill('SKU-002') await page.locator('input[name="quantity"]').nth(1).fill('50') await page.locator('input[name="unitPrice"]').nth(1).fill('30') // 1500 // Verify totals: 6500 subtotal, 650 tax, 7150 total await expect(page.locator('text=Subtotal: $6500')).toBeVisible() await expect(page.locator('text=Tax: $650')).toBeVisible() await expect(page.locator('text=Total: $7150')).toBeVisible() }) })