import { test, expect } from '@playwright/test'; test.describe('User Settings', () => { test('can access user settings page', async ({ page }) => { await page.goto('/users/settings'); // May require sudo verification if ((await page.url()).includes('sudo-verify')) { // Skip if sudo verification required return; } await expect(page).toHaveURL(/\/users\/settings/); await expect(page.locator('body')).toBeVisible(); }); test('shows user profile information', async ({ page }) => { await page.goto('/users/settings'); // Look for email or profile fields const emailField = page.locator('input[type="email"], :has-text("@")').first(); if (await emailField.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(emailField).toBeVisible(); } }); test('can change password section exists', async ({ page }) => { await page.goto('/users/settings'); // Look for password change section const passwordSection = page.locator( ':has-text("Password"), :has-text("Change Password"), input[type="password"]' ).first(); if (await passwordSection.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(passwordSection).toBeVisible(); } }); test('can access TOTP/2FA settings', async ({ page }) => { await page.goto('/users/settings'); // Look for TOTP/2FA section const totpSection = page.locator( ':has-text("Two-Factor"), :has-text("2FA"), :has-text("TOTP"), :has-text("Authentication")' ).first(); if (await totpSection.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(totpSection).toBeVisible(); } }); test('can access API tokens section', async ({ page }) => { await page.goto('/users/settings'); // Look for API tokens section const apiTokenSection = page.locator( ':has-text("API Token"), :has-text("API Key"), button:has-text("Generate Token")' ).first(); if (await apiTokenSection.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(apiTokenSection).toBeVisible(); } }); test('can view active sessions', async ({ page }) => { await page.goto('/users/settings'); // Look for sessions section const sessionsSection = page.locator( ':has-text("Sessions"), :has-text("Active Sessions"), :has-text("Devices")' ).first(); if (await sessionsSection.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(sessionsSection).toBeVisible(); } }); test('can access account activity', async ({ page }) => { await page.goto('/account/activity'); // May require sudo verification if ((await page.url()).includes('sudo-verify')) { // Skip if sudo verification required return; } await expect(page).toHaveURL(/\/account\/activity/); await expect(page.locator('body')).toBeVisible(); }); test('can access my data page', async ({ page }) => { await page.goto('/users/my-data'); // May require sudo verification if ((await page.url()).includes('sudo-verify')) { // Skip if sudo verification required return; } await expect(page).toHaveURL(/\/users\/my-data/); await expect(page.locator('body')).toBeVisible(); }); });