Files
rxminder/tests/e2e/admin.spec.ts
William Valentin e48adbcb00 Initial commit: Complete NodeJS-native setup
- Migrated from Python pre-commit to NodeJS-native solution
- Reorganized documentation structure
- Set up Husky + lint-staged for efficient pre-commit hooks
- Fixed Dockerfile healthcheck issue
- Added comprehensive documentation index
2025-09-06 01:42:48 -07:00

64 lines
2.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Admin Interface', () => {
test.beforeEach(async ({ page }) => {
// Login as admin
await page.goto('/');
await page.fill('input[type="email"]', 'admin@localhost');
await page.fill('input[type="password"]', 'admin123!');
await page.click('button[type="submit"]');
// Wait for main app and open admin interface
await expect(page.locator('h1')).toContainText('Medication Reminder');
await page.click('button:has-text("Admin")');
});
test('should display admin interface', async ({ page }) => {
await expect(page.locator('text=Admin Interface')).toBeVisible();
await expect(page.locator('text=User Management')).toBeVisible();
});
test('should show list of users', async ({ page }) => {
// Should show admin user at minimum
await expect(page.locator('text=admin@localhost')).toBeVisible();
await expect(page.locator('text=Admin')).toBeVisible(); // Role
});
test('should allow changing user password', async ({ page }) => {
// Click on a user's change password button
await page.click('[data-testid="change-password"]');
// Fill new password
await page.fill('input[type="password"]', 'NewPassword123!');
// Submit password change
await page.click('button:has-text("Change Password")');
// Should show success message
await expect(page.locator('text=Password changed')).toBeVisible();
});
test('should allow suspending/activating users', async ({ page }) => {
// Look for user status controls
const statusButton = page
.locator('[data-testid="toggle-user-status"]')
.first();
await expect(statusButton).toBeVisible();
});
test('should refresh user list', async ({ page }) => {
await page.click('button:has-text("Refresh")');
// Should still show users after refresh
await expect(page.locator('text=admin@localhost')).toBeVisible();
});
test('should close admin interface', async ({ page }) => {
await page.click('button[aria-label="Close"]');
// Should return to main app
await expect(page.locator('text=Admin Interface')).not.toBeVisible();
await expect(page.locator('h1')).toContainText('Medication Reminder');
});
});