Files
LocalAI/core/http/react-ui/e2e/traces.spec.js
Richard Palethorpe 8d70855ea6 test: add Go + React UI coverage gates and fill test gaps (#9989)
- Strict monotonic Go coverage gate (make test-coverage-check, 45% baseline)
  run in CI; fixes ginkgo dropping all-but-one coverprofile across multiple
  recursive roots, builds with -tags auth, and folds in the in-process
  tests/e2e suite via --coverpkg.
- React UI e2e coverage (make test-ui-coverage: vite-plugin-istanbul + nyc,
  nix-provided Chromium) plus e2e specs for 6 previously-untested pages, and a
  UI coverage gate (make test-ui-coverage-check) with a small tolerance since
  e2e line coverage jitters ~0.5pp run-to-run.
- pre-commit hook: lint + coverage on Go changes, Playwright e2e + UI coverage
  gate on react-ui changes; install with make install-hooks.
- New Go handler tests (settings, branding), hermetic base64 download test.
- fix(ui): model editor reads vram_display (snake_case), so the VRAM estimate
  renders again; covered by a regression test.

Assisted-by: Claude:claude-opus-4-7

Signed-off-by: Richard Palethorpe <io@richiejp.com>
2026-05-26 22:06:10 +02:00

109 lines
4.0 KiB
JavaScript

import { test, expect } from './coverage-fixtures.js'
test.describe('Traces Settings', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/app/traces')
// Wait for settings panel to load
await expect(page.locator('text=Tracing is')).toBeVisible({ timeout: 10_000 })
})
test('settings panel is visible on page load', async ({ page }) => {
await expect(page.locator('text=Tracing is')).toBeVisible()
})
test('expand and collapse settings', async ({ page }) => {
// The test server starts with tracing enabled, so the panel starts collapsed
const settingsHeader = page.locator('button', { hasText: 'Tracing is' })
// Click to expand
await settingsHeader.click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
// Click to collapse
await settingsHeader.click()
await expect(page.locator('text=Enable Tracing')).not.toBeVisible()
})
test('toggle tracing on and off', async ({ page }) => {
// Expand settings
const settingsHeader = page.locator('button', { hasText: 'Tracing is' })
await settingsHeader.click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
// The Toggle component is a <label> wrapping a hidden checkbox.
// Use .first() on the checkbox to target the Enable Tracing toggle
// (it appears before the Enable Backend Logging toggle in the DOM).
const checkbox = page.locator('input[type="checkbox"]').first()
// Initially enabled (server starts with tracing on)
await expect(checkbox).toBeChecked()
// Click the label (parent) to toggle off
await checkbox.locator('..').click()
await expect(checkbox).not.toBeChecked()
// Click again to re-enable
await checkbox.locator('..').click()
await expect(checkbox).toBeChecked()
})
test('set max items value', async ({ page }) => {
// Expand settings
await page.locator('button', { hasText: 'Tracing is' }).click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
// The Tracing panel has two numeric inputs (Max Items and Max Body Bytes).
// Disambiguate by placeholder so adding a third field later doesn't break this.
const maxItemsInput = page.getByPlaceholder('100')
await maxItemsInput.fill('500')
await expect(maxItemsInput).toHaveValue('500')
})
test('set max body bytes value', async ({ page }) => {
await page.locator('button', { hasText: 'Tracing is' }).click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
const maxBodyBytesInput = page.getByPlaceholder('65536')
await maxBodyBytesInput.fill('16384')
await expect(maxBodyBytesInput).toHaveValue('16384')
})
test('save shows toast', async ({ page }) => {
// Expand settings
await page.locator('button', { hasText: 'Tracing is' }).click()
// Click save
await page.locator('button', { hasText: 'Save' }).click()
// Verify toast appears
await expect(page.locator('text=Tracing settings saved')).toBeVisible({ timeout: 5_000 })
})
test('panel collapses after save when tracing is enabled', async ({ page }) => {
// Expand settings
await page.locator('button', { hasText: 'Tracing is' }).click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
// Tracing is already enabled; save
await page.locator('button', { hasText: 'Save' }).click()
// Panel should collapse
await expect(page.locator('text=Enable Tracing')).not.toBeVisible()
})
test('panel stays expanded after save when tracing is off', async ({ page }) => {
// Expand settings
await page.locator('button', { hasText: 'Tracing is' }).click()
await expect(page.locator('text=Enable Tracing')).toBeVisible()
// Toggle tracing off (first checkbox is the Enable Tracing toggle)
await page.locator('input[type="checkbox"]').first().locator('..').click()
// Save
await page.locator('button', { hasText: 'Save' }).click()
// Panel should stay expanded since tracing is now disabled
await expect(page.locator('text=Enable Tracing')).toBeVisible()
})
})