mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-30 03:25:42 -04:00
- 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>
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
// Playwright test fixture that harvests istanbul code coverage.
|
|
//
|
|
// When the app is built with COVERAGE=true (see vite.config.js), every source
|
|
// module is instrumented and exposes its counters on window.__coverage__. This
|
|
// fixture writes that object to .nyc_output/ after each test so `nyc report`
|
|
// can merge the runs into a per-file coverage report.
|
|
//
|
|
// The app is a React SPA (client-side routing), so window.__coverage__
|
|
// accumulates across in-app navigation within a single test; only a full page
|
|
// reload / fresh page.goto resets it. Specs import { test, expect } from this
|
|
// module instead of '@playwright/test' so collection is automatic.
|
|
import { test as base, expect } from '@playwright/test'
|
|
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import { randomUUID } from 'node:crypto'
|
|
import path from 'node:path'
|
|
|
|
const COVERAGE_DIR = path.resolve(process.cwd(), '.nyc_output')
|
|
|
|
export const test = base.extend({
|
|
page: async ({ page }, use) => {
|
|
await use(page)
|
|
|
|
let coverage
|
|
try {
|
|
coverage = await page.evaluate(() => window.__coverage__)
|
|
} catch {
|
|
// Page was already closed by the test — nothing to collect.
|
|
return
|
|
}
|
|
if (!coverage) return // build wasn't instrumented (COVERAGE unset)
|
|
|
|
mkdirSync(COVERAGE_DIR, { recursive: true })
|
|
writeFileSync(
|
|
path.join(COVERAGE_DIR, `playwright-${randomUUID()}.json`),
|
|
JSON.stringify(coverage),
|
|
)
|
|
},
|
|
})
|
|
|
|
export { expect }
|