|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | + |
| 3 | +test.describe('Traces Settings', () => { |
| 4 | + test.beforeEach(async ({ page }) => { |
| 5 | + await page.goto('/app/traces') |
| 6 | + // Wait for settings panel to load |
| 7 | + await expect(page.locator('text=Tracing is')).toBeVisible({ timeout: 10_000 }) |
| 8 | + }) |
| 9 | + |
| 10 | + test('settings panel is visible on page load', async ({ page }) => { |
| 11 | + await expect(page.locator('text=Tracing is')).toBeVisible() |
| 12 | + }) |
| 13 | + |
| 14 | + test('expand and collapse settings', async ({ page }) => { |
| 15 | + // The test server starts with tracing enabled, so the panel starts collapsed |
| 16 | + const settingsHeader = page.locator('button', { hasText: 'Tracing is' }) |
| 17 | + |
| 18 | + // Click to expand |
| 19 | + await settingsHeader.click() |
| 20 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 21 | + |
| 22 | + // Click to collapse |
| 23 | + await settingsHeader.click() |
| 24 | + await expect(page.locator('text=Enable Tracing')).not.toBeVisible() |
| 25 | + }) |
| 26 | + |
| 27 | + test('toggle tracing on and off', async ({ page }) => { |
| 28 | + // Expand settings |
| 29 | + const settingsHeader = page.locator('button', { hasText: 'Tracing is' }) |
| 30 | + await settingsHeader.click() |
| 31 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 32 | + |
| 33 | + // The Toggle component is a <label> wrapping a hidden checkbox. |
| 34 | + // Target the checkbox within the settings panel. |
| 35 | + const checkbox = page.locator('input[type="checkbox"]') |
| 36 | + |
| 37 | + // Initially enabled (server starts with tracing on) |
| 38 | + await expect(checkbox).toBeChecked() |
| 39 | + |
| 40 | + // Click the label (parent) to toggle off |
| 41 | + await checkbox.locator('..').click() |
| 42 | + await expect(checkbox).not.toBeChecked() |
| 43 | + |
| 44 | + // Click again to re-enable |
| 45 | + await checkbox.locator('..').click() |
| 46 | + await expect(checkbox).toBeChecked() |
| 47 | + }) |
| 48 | + |
| 49 | + test('set max items value', async ({ page }) => { |
| 50 | + // Expand settings |
| 51 | + await page.locator('button', { hasText: 'Tracing is' }).click() |
| 52 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 53 | + |
| 54 | + const maxItemsInput = page.locator('input[type="number"]') |
| 55 | + await maxItemsInput.fill('500') |
| 56 | + await expect(maxItemsInput).toHaveValue('500') |
| 57 | + }) |
| 58 | + |
| 59 | + test('save shows toast', async ({ page }) => { |
| 60 | + // Expand settings |
| 61 | + await page.locator('button', { hasText: 'Tracing is' }).click() |
| 62 | + |
| 63 | + // Click save |
| 64 | + await page.locator('button', { hasText: 'Save' }).click() |
| 65 | + |
| 66 | + // Verify toast appears |
| 67 | + await expect(page.locator('text=Tracing settings saved')).toBeVisible({ timeout: 5_000 }) |
| 68 | + }) |
| 69 | + |
| 70 | + test('panel collapses after save when tracing is enabled', async ({ page }) => { |
| 71 | + // Expand settings |
| 72 | + await page.locator('button', { hasText: 'Tracing is' }).click() |
| 73 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 74 | + |
| 75 | + // Tracing is already enabled; save |
| 76 | + await page.locator('button', { hasText: 'Save' }).click() |
| 77 | + |
| 78 | + // Panel should collapse |
| 79 | + await expect(page.locator('text=Enable Tracing')).not.toBeVisible() |
| 80 | + }) |
| 81 | + |
| 82 | + test('panel stays expanded after save when tracing is off', async ({ page }) => { |
| 83 | + // Expand settings |
| 84 | + await page.locator('button', { hasText: 'Tracing is' }).click() |
| 85 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 86 | + |
| 87 | + // Toggle tracing off |
| 88 | + await page.locator('input[type="checkbox"]').locator('..').click() |
| 89 | + |
| 90 | + // Save |
| 91 | + await page.locator('button', { hasText: 'Save' }).click() |
| 92 | + |
| 93 | + // Panel should stay expanded since tracing is now disabled |
| 94 | + await expect(page.locator('text=Enable Tracing')).toBeVisible() |
| 95 | + }) |
| 96 | +}) |
0 commit comments