Spaces:
Paused
Paused
| const { test, expect } = require('@playwright/test'); | |
| test.describe('Authentication Flow', () => { | |
| test('should successfully login with valid credentials', async ({ page }) => { | |
| await page.goto('/login'); | |
| await page.fill('input[name="email"]', 'admin@widgettdc.dev'); | |
| await page.fill('input[name="password"]', 'password'); | |
| await page.click('button[type="submit"]'); | |
| await expect(page).toHaveURL('/dashboard'); | |
| await expect(page.locator('text=Welcome')).toBeVisible(); | |
| }); | |
| test('should show error with invalid credentials', async ({ page }) => { | |
| await page.goto('/login'); | |
| await page.fill('input[name="email"]', 'wrong@example.com'); | |
| await page.fill('input[name="password"]', 'wrongpass'); | |
| await page.click('button[type="submit"]'); | |
| await expect(page.locator('.error-message')).toBeVisible(); | |
| await expect(page.locator('.error-message')).toContainText('Invalid credentials'); | |
| }); | |
| test('should logout successfully', async ({ page }) => { | |
| await page.goto('/login'); | |
| await page.fill('input[name="email"]', 'admin@widgettdc.dev'); | |
| await page.fill('input[name="password"]', 'password'); | |
| await page.click('button[type="submit"]'); | |
| await page.click('button[aria-label="Logout"]'); | |
| await expect(page).toHaveURL('/login'); | |
| }); | |
| }); | |