import { test, expect } from '@playwright/test'; test.describe('Agents', () => { test('can view agents list', async ({ page }) => { await page.goto('/agents'); await expect(page).toHaveURL(/\/agents/); await expect(page.locator('body')).toBeVisible(); }); test('can view agent details', async ({ page }) => { await page.goto('/agents'); // Find first agent link const firstAgent = page.locator('a[href*="/agents/"]').first(); if (await firstAgent.isVisible()) { await firstAgent.click(); await expect(page).toHaveURL(/\/agents\/[^\/]+/); } }); test('can edit agent settings', async ({ page }) => { await page.goto('/agents'); // Navigate to first agent const firstAgent = page.locator('a[href*="/agents/"]').first(); if (await firstAgent.isVisible()) { await firstAgent.click(); // Look for edit button const editButton = page.locator( 'a[href*="/edit"], button:has-text("Edit"), a:has-text("Edit")' ).first(); if (await editButton.isVisible()) { await editButton.click(); await expect(page).toHaveURL(/\/agents\/[^\/]+\/edit/); } } }); test('can view agent assignments', async ({ page }) => { await page.goto('/agents'); // Navigate to first agent details const firstAgent = page.locator('a[href*="/agents/"]').first(); if (await firstAgent.isVisible()) { await firstAgent.click(); // Look for assigned devices section const assignmentsSection = page.locator( ':has-text("Assigned"), :has-text("Devices")' ).first(); if (await assignmentsSection.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(assignmentsSection).toBeVisible(); } } }); test('shows agent status', async ({ page }) => { await page.goto('/agents'); // Look for status indicators (Online, Offline, etc.) const statusIndicator = page.locator( ':has-text("Online"), :has-text("Offline"), [data-status]' ).first(); if (await statusIndicator.isVisible({ timeout: 2000 }).catch(() => false)) { await expect(statusIndicator).toBeVisible(); } }); });