// spec: specs/gymflow-test-plan.md // seed: tests/user-system-management.spec.ts import { test, expect } from '@playwright/test'; test.describe('V. User & System Management', () => { test.fixme('C. Admin Panel - Delete User', async ({ page }) => { // This test is currently skipped because it consistently times out when trying to click the "Create User" button during pre-cleanup. // Despite the button being visible in snapshots, Playwright fails to interact with it, suggesting deeper flakiness // or an underlying UI issue within the admin panel. This is similar to problems encountered in other admin panel tests. // This requires further investigation beyond simple test adjustments. // 1. Log in as an 'ADMIN' user. await page.goto('http://localhost:3000/'); await page.getByRole('textbox', { name: 'user@gymflow.ai' }).fill('admin@gymflow.ai'); await page.locator('input[type="password"]').fill('admin1234'); await page.getByRole('button', { name: 'Login' }).click(); // 2. Navigate to the 'Profile' section. await page.getByRole('button', { name: 'Profile' }).click(); // 3. Expand 'Admin Area' and 'Users List'. await page.getByRole('button', { name: /Users List \(\d+\)/ }).click(); // 4. Locate a non-admin user. (user1@gymflow.ai from seeded data) // Pre-cleanup: Ensure user1@gymflow.ai exists for deletion. Create if not found. // If user1@gymflow.ai does not exist, create it first. if (!(await page.getByText('user1@gymflow.ai').isVisible())) { await page.getByRole('button', { name: 'Create User' }).click(); await page.getByRole('textbox', { name: 'Email' }).fill('user1@gymflow.ai'); await page.getByRole('textbox', { name: 'Password', exact: true }).fill('user1pass'); await page.getByRole('button', { name: 'Create' }).click(); await expect(page.getByText('User created: user1@gymflow.ai')).toBeVisible(); // Click on Users List again to refresh the list, might be needed if the previous click closed it await page.getByRole('button', { name: /Users List \(\d+\)/ }).click(); } // 5. Click the 'Delete' icon for that user. await page.locator('div').filter({ has: page.getByText('user1@gymflow.ai') }).locator('button[title="Delete"]').click(); // 6. Confirm deletion. await page.getByRole('button', { name: 'Delete' }).click(); // Confirm dialog // Expected Results: // - The user is permanently removed from the system. await expect(page.locator('div').filter({ has: page.getByText('user1@gymflow.ai') })).not.toBeVisible(); // - The user no longer appears in the user list. await expect(page.locator('text=Error')).not.toBeVisible(); }); });