/** * E2E Tests for Moderation Lock Management * * Browser-based tests for lock UI and interactions */ import { test, expect } from '@playwright/test'; test.describe('Moderation Lock Management UI', () => { test.beforeEach(async ({ page }) => { // Login as moderator (assumes auth state is set up) await page.goto('/login'); // Add login steps here based on your auth setup await page.goto('/moderation/queue'); await page.waitForLoadState('networkidle'); }); test('moderator can see claim button on pending submissions', async ({ page }) => { // Wait for queue to load await page.waitForSelector('[data-testid="queue-item"]', { timeout: 10000 }); // Find first pending submission const firstItem = page.locator('[data-testid="queue-item"]').first(); // Look for claim button const claimButton = firstItem.locator('button:has-text("Claim Submission")'); // Verify button is visible await expect(claimButton).toBeVisible(); }); test('claim button shows loading state when clicked', async ({ page }) => { await page.waitForSelector('[data-testid="queue-item"]', { timeout: 10000 }); const firstItem = page.locator('[data-testid="queue-item"]').first(); const claimButton = firstItem.locator('button:has-text("Claim Submission")'); // Click claim button await claimButton.click(); // Verify loading state await expect(firstItem.locator('button:has-text("Claiming...")')).toBeVisible(); }); test('claimed submission shows lock badge', async ({ page }) => { await page.waitForSelector('[data-testid="queue-item"]', { timeout: 10000 }); const firstItem = page.locator('[data-testid="queue-item"]').first(); const claimButton = firstItem.locator('button:has-text("Claim Submission")'); // Claim submission await claimButton.click(); // Wait for lock badge to appear await expect(firstItem.locator('text=Claimed by You')).toBeVisible({ timeout: 5000 }); }); test('approve and reject buttons are enabled after claiming', async ({ page }) => { await page.waitForSelector('[data-testid="queue-item"]', { timeout: 10000 }); const firstItem = page.locator('[data-testid="queue-item"]').first(); const claimButton = firstItem.locator('button:has-text("Claim Submission")'); // Claim submission await claimButton.click(); await page.waitForTimeout(1000); // Verify action buttons are enabled const approveButton = firstItem.locator('button:has-text("Approve")'); const rejectButton = firstItem.locator('button:has-text("Reject")'); await expect(approveButton).toBeEnabled(); await expect(rejectButton).toBeEnabled(); }); test('submission locked by another moderator shows lock warning', async ({ page }) => { // This test would require setting up a multi-user scenario // For now, verify the UI element exists await page.goto('/moderation/queue'); // Check if any submission has the "Locked by Another Moderator" badge const lockedBadge = page.locator('text=Locked by Another Moderator'); // If no locked submissions, this test is informational only const count = await lockedBadge.count(); expect(count).toBeGreaterThanOrEqual(0); }); });