- 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
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Medication Management', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// Login as admin first
|
|
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 to load
|
|
await expect(page.locator('h1')).toContainText('Medication Reminder');
|
|
});
|
|
|
|
test('should add a new medication', async ({ page }) => {
|
|
// Click add medication button
|
|
await page.click('button:has-text("Add Medication")');
|
|
|
|
// Fill medication form
|
|
await page.fill('input[name="name"]', 'Aspirin');
|
|
await page.fill('input[name="dosage"]', '100mg');
|
|
await page.selectOption('select[name="frequency"]', 'daily');
|
|
await page.fill('input[name="times"]', '2');
|
|
|
|
// Submit form
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Should see medication in list
|
|
await expect(page.locator('text=Aspirin')).toBeVisible();
|
|
await expect(page.locator('text=100mg')).toBeVisible();
|
|
});
|
|
|
|
test('should edit existing medication', async ({ page }) => {
|
|
// First add a medication
|
|
await page.click('button:has-text("Add Medication")');
|
|
await page.fill('input[name="name"]', 'Vitamin D');
|
|
await page.fill('input[name="dosage"]', '1000 IU');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Click edit button for the medication
|
|
await page.click('[data-testid="edit-medication"]');
|
|
|
|
// Update dosage
|
|
await page.fill('input[name="dosage"]', '2000 IU');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Should see updated dosage
|
|
await expect(page.locator('text=2000 IU')).toBeVisible();
|
|
});
|
|
|
|
test('should delete medication', async ({ page }) => {
|
|
// Add a medication first
|
|
await page.click('button:has-text("Add Medication")');
|
|
await page.fill('input[name="name"]', 'Test Medicine');
|
|
await page.fill('input[name="dosage"]', '50mg');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Open manage medications modal
|
|
await page.click('button:has-text("Manage")');
|
|
|
|
// Delete the medication
|
|
await page.click('[data-testid="delete-medication"]');
|
|
await page.click('button:has-text("Delete")'); // Confirm deletion
|
|
|
|
// Should not see medication anymore
|
|
await expect(page.locator('text=Test Medicine')).not.toBeVisible();
|
|
});
|
|
|
|
test('should mark dose as taken', async ({ page }) => {
|
|
// Add a medication first
|
|
await page.click('button:has-text("Add Medication")');
|
|
await page.fill('input[name="name"]', 'Daily Vitamin');
|
|
await page.fill('input[name="dosage"]', '1 tablet');
|
|
await page.selectOption('select[name="frequency"]', 'daily');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Find and click the "Take" button for upcoming dose
|
|
await page.click('button:has-text("Take")');
|
|
|
|
// Should show as taken
|
|
await expect(page.locator('text=Taken')).toBeVisible();
|
|
await expect(page.locator('.bg-green-50')).toBeVisible();
|
|
});
|
|
|
|
test('should show medication history', async ({ page }) => {
|
|
// Open history modal
|
|
await page.click('button:has-text("History")');
|
|
|
|
// Should show history modal
|
|
await expect(page.locator('text=Medication History')).toBeVisible();
|
|
|
|
// Close modal
|
|
await page.click('button:has-text("Close")');
|
|
});
|
|
});
|