Files
smoothschedule/frontend/tests/e2e/auth.spec.ts
poduck 2e111364a2 Initial commit: SmoothSchedule multi-tenant scheduling platform
This commit includes:
- Django backend with multi-tenancy (django-tenants)
- React + TypeScript frontend with Vite
- Platform administration API with role-based access control
- Authentication system with token-based auth
- Quick login dev tools for testing different user roles
- CORS and CSRF configuration for local development
- Docker development environment setup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 01:43:20 -05:00

61 lines
2.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
/**
* Authentication Flow Tests
* Tests login, logout, and authentication state management
*/
test.describe('Authentication', () => {
test('should display login page', async ({ page }) => {
await page.goto('/');
// Check if login form elements are present
await expect(page.getByRole('heading', { name: /login|sign in/i })).toBeVisible();
await expect(page.getByLabel(/username/i)).toBeVisible();
await expect(page.getByLabel(/password/i)).toBeVisible();
await expect(page.getByRole('button', { name: /login|sign in/i })).toBeVisible();
});
test('should show error on invalid credentials', async ({ page }) => {
await page.goto('/');
await page.getByLabel(/username/i).fill('invaliduser');
await page.getByLabel(/password/i).fill('wrongpassword');
await page.getByRole('button', { name: /login|sign in/i }).click();
// Should show error message
await expect(page.getByText(/invalid|error|incorrect/i)).toBeVisible();
});
test('should login successfully with valid credentials', async ({ page }) => {
await page.goto('/');
// Fill in credentials (these would be test user credentials)
await page.getByLabel(/username/i).fill('testowner');
await page.getByLabel(/password/i).fill('testpass123');
await page.getByRole('button', { name: /login|sign in/i }).click();
// Should redirect to dashboard
await expect(page).toHaveURL(/dashboard|\/$/);
// Should show user menu or profile
await expect(page.getByRole('button', { name: /profile|account|menu/i })).toBeVisible();
});
test('should logout successfully', async ({ page }) => {
// Login first
await page.goto('/');
await page.getByLabel(/username/i).fill('testowner');
await page.getByLabel(/password/i).fill('testpass123');
await page.getByRole('button', { name: /login|sign in/i }).click();
await expect(page).toHaveURL(/dashboard|\/$/);
// Click logout
await page.getByRole('button', { name: /logout|sign out/i }).click();
// Should redirect to login
await expect(page).toHaveURL(/login|\/$/);
});
});