// 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('C. Admin Panel - Block/Unblock User', async ({ page }) => { // 1. Log in as an 'ADMIN' user. await page.goto('http://192.168.50.234: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. (using user1@gymflow.ai from seed) // 5. Click the 'Block' icon for that user. await page.locator('div').filter({ hasText: /^user1@gymflow\.aiUSERBlockDelete$/ }).getByRole('button', { name: 'Block' }).click(); // 6. Verify the user's status changes to 'Blocked'. await expect(page.locator('div').filter({ hasText: /^user1@gymflow\.aiUSERBlockedUnblockDelete$/ }).getByRole('button', { name: 'Unblock' })).toBeVisible(); // 7. Click the 'Unblock' icon for the same user. await page.locator('div').filter({ hasText: /^user1@gymflow\.aiUSERBlockedUnblockDelete$/ }).getByRole('button', { name: 'Unblock' }).click(); // Expected Results: // - User is blocked and unblocked successfully. await expect(page.locator('div').filter({ hasText: /^user1@gymflow\.aiUSERBlockDelete$/ }).getByRole('button', { name: 'Block' })).toBeVisible(); // - Status updates are reflected in the user list. await expect(page.locator('text=Error')).not.toBeVisible(); // Cleanup: Delete the seeded users. await page.locator('div').filter({ hasText: /^user1@gymflow\.aiUSERBlockDelete$/ }).getByRole('button', { name: 'Delete' }).click(); await page.getByRole('button', { name: 'Delete' }).click(); // Confirm deletion await page.locator('div').filter({ hasText: /^user2@gymflow\.aiUSERBlockDelete$/ }).getByRole('button', { name: 'Delete' }).click(); await page.getByRole('button', { name: 'Delete' }).click(); // Confirm deletion await page.locator('div').filter({ hasText: /^blocked@gymflow\.aiUSERBlockedUnblockDelete$/ }).getByRole('button', { name: 'Delete' }).click(); await page.getByRole('button', { name: 'Delete' }).click(); // Confirm deletion }); });