-
+
+
+
+
-
-
diff --git a/frontend/src/components/shell/AppNav.vue b/frontend/src/components/shell/AppNav.vue
new file mode 100644
index 0000000..d25be29
--- /dev/null
+++ b/frontend/src/components/shell/AppNav.vue
@@ -0,0 +1,50 @@
+
+
+
+
+
diff --git a/frontend/src/lib/format.ts b/frontend/src/lib/format.ts
new file mode 100644
index 0000000..32493ed
--- /dev/null
+++ b/frontend/src/lib/format.ts
@@ -0,0 +1,22 @@
+const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']
+const BYTES_PER_UNIT = 1024
+
+export function formatNumber(num: number): string {
+ return new Intl.NumberFormat().format(num)
+}
+
+export function formatBytes(bytes: number): string {
+ if (bytes === 0) return '0 B'
+ const i = Math.floor(Math.log(bytes) / Math.log(BYTES_PER_UNIT))
+ return Math.round((bytes / Math.pow(BYTES_PER_UNIT, i)) * 100) / 100 + ' ' + BYTE_UNITS[i]
+}
+
+export function formatDate(date: string): string {
+ if (!date) return 'N/A'
+ const parsed = new Date(date)
+ return Number.isNaN(parsed.getTime()) ? date : parsed.toLocaleString()
+}
+
+export function withVersionPrefix(version: string): string {
+ return version.startsWith('v') ? version : 'v' + version
+}
diff --git a/frontend/src/lib/icons.ts b/frontend/src/lib/icons.ts
new file mode 100644
index 0000000..ab29366
--- /dev/null
+++ b/frontend/src/lib/icons.ts
@@ -0,0 +1,24 @@
+export {
+ faArrowLeft,
+ faBan,
+ faBox,
+ faBoxOpen,
+ faBoxesStacked,
+ faChartColumn,
+ faChartLine,
+ faChartPie,
+ faDownload,
+ faHardDrive,
+ faPen,
+ faShieldHalved,
+ faTrash,
+ faTriangleExclamation,
+} from '@fortawesome/free-solid-svg-icons'
+export {
+ faCircleCheck,
+ faMagnifyingGlass,
+ faPlus,
+ faRotateRight,
+ faChevronDown,
+ faChevronUp,
+} from '@perfect-design/ui/lib/icons'
diff --git a/frontend/src/lib/severity.ts b/frontend/src/lib/severity.ts
new file mode 100644
index 0000000..39072b7
--- /dev/null
+++ b/frontend/src/lib/severity.ts
@@ -0,0 +1,33 @@
+import type { VulnerabilityCounts } from '@/stores/packages'
+
+export type SeverityTone = 'danger' | 'warning' | 'info' | 'neutral'
+
+export const SEVERITY_TONES: Record
= {
+ critical: 'danger',
+ high: 'warning',
+ moderate: 'info',
+ medium: 'info',
+ low: 'neutral',
+}
+
+export const SEVERITY_RANK: Record = {
+ critical: 4,
+ high: 3,
+ moderate: 2,
+ medium: 2,
+ low: 1,
+}
+
+export const SEVERITY_LEVELS = ['critical', 'high', 'moderate', 'low'] as const
+export type SeverityLevel = (typeof SEVERITY_LEVELS)[number]
+
+export const NO_VULNERABILITIES: VulnerabilityCounts = { critical: 0, high: 0, moderate: 0, low: 0 }
+
+export function severityRank(severity: string): number {
+ return SEVERITY_RANK[severity.toLowerCase()] ?? 0
+}
+
+export function formatSeverityName(severity: string): string {
+ const lower = severity.toLowerCase()
+ return lower.charAt(0).toUpperCase() + lower.slice(1)
+}
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 5434785..f89edc3 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -1,9 +1,12 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
+import { configureStrictMode } from '@perfect-design/ui'
import router from './router'
import App from './App.vue'
import './styles/main.css'
+configureStrictMode(import.meta.env.DEV ? 'throw' : 'warn')
+
const app = createApp(App)
app.use(createPinia())
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 1a412cd..65658ce 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1,10 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
-import Dashboard from '../components/Dashboard.vue'
-import PackageList from '../components/PackageList.vue'
-import PackageDetails from '../components/PackageDetails.vue'
-import Stats from '../components/Stats.vue'
-import VulnerablePackages from '../components/VulnerablePackages.vue'
-import BypassManagementPanel from '../components/BypassManagementPanel.vue'
const router = createRouter({
history: createWebHistory(),
@@ -12,40 +6,40 @@ const router = createRouter({
{
path: '/',
name: 'dashboard',
- component: Dashboard,
+ component: () => import('../components/Dashboard.vue'),
},
{
path: '/packages/:registry?',
name: 'packages',
- component: PackageList,
+ component: () => import('../components/PackageList.vue'),
props: true,
},
{
// Separate route for package details - supports names with slashes (Go packages)
path: '/package/:registry/:name+/:version',
name: 'package-details',
- component: PackageDetails,
+ component: () => import('../components/PackageDetails.vue'),
props: true,
},
{
path: '/stats',
name: 'stats',
- component: Stats,
+ component: () => import('../components/Stats.vue'),
},
{
path: '/vulnerable-packages',
name: 'vulnerable-packages',
- component: VulnerablePackages,
+ component: () => import('../components/VulnerablePackages.vue'),
},
{
path: '/blocked-packages',
name: 'blocked-packages',
- component: VulnerablePackages,
+ component: () => import('../components/VulnerablePackages.vue'),
},
{
path: '/admin/bypasses',
name: 'bypasses',
- component: BypassManagementPanel,
+ component: () => import('../components/BypassManagementPanel.vue'),
},
],
})
diff --git a/frontend/src/styles/main.css b/frontend/src/styles/main.css
index 8d69c3f..5315602 100644
--- a/frontend/src/styles/main.css
+++ b/frontend/src/styles/main.css
@@ -1,83 +1,121 @@
-@import '@fortawesome/fontawesome-free/css/all.min.css';
+@import "tailwindcss";
+@import "@perfect-design/ui/theme.css";
+@import "@perfect-design/ui/packs/workbench.css";
+/* Only the library components the app imports, plus their transitive imports: scanning all of dist adds every component's classes. `pnpm sources` regenerates this list. */
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/ActivityFeed/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/BarChart/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Card/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/CodeViewer/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/CodeViewer/tokenize/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/DataTable/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/DescriptionList/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/KpiTile/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Sparkline/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/StatGroup/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/Table/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/_chart/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/data-display/_shared/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/Alert/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ConfirmDialog/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/EmptyState/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ErrorState/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/LoadingState/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/ToastItem/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/feedback/Toaster/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Checkbox/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/CheckboxCard/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Combobox/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Field/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Input/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/InputGroup/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Label/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/NativeSelect/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/SearchInput/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/SegmentedControl/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/forms/Textarea/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/layout/AppShell/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/layout/ConfigProvider/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/layout/Container/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/layout/PageHeader/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/Accordion/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/AppHeader/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/MobileNav/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/NavLink/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/Pagination/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/SidebarNav/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/navigation/ThemeToggle/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/overlays/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/overlays/AlertDialog/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/overlays/Dialog/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Avatar/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Badge/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Button/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Icon/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/IconButton/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Link/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/ScrollArea/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/Spinner/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusBadge/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/primitives/StatusDot/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/typography/Markdown/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/typography/Markdown/parse/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/components/typography/RelativeTime/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/lib/*.js";
+@source "../../node_modules/@perfect-design/ui/dist/stores/*.js";
-@import 'tailwindcss';
-@config '../../tailwind.config.js';
-@custom-variant dark (&:is(.dark *));
-
-@layer base {
- :root {
- /* Tailwind slate-50 for background */
- --background: 210 40% 98%;
- /* Tailwind slate-900 for foreground */
- --foreground: 222 47% 11%;
- /* White for cards */
- --card: 0 0% 100%;
- --card-foreground: 222 47% 11%;
- --popover: 0 0% 100%;
- --popover-foreground: 222 47% 11%;
- /* Tailwind slate-700 for primary */
- --primary: 215 25% 27%;
- --primary-foreground: 0 0% 100%;
- /* Tailwind slate-100 for secondary */
- --secondary: 210 40% 96%;
- --secondary-foreground: 222 47% 11%;
- /* Tailwind slate-100 for muted */
- --muted: 210 40% 96%;
- /* Tailwind slate-500 for muted-foreground */
- --muted-foreground: 215 20% 65%;
- --accent: 210 40% 96%;
- --accent-foreground: 222 47% 11%;
- /* Tailwind red-500 for destructive */
- --destructive: 0 84% 60%;
- --destructive-foreground: 0 0% 98%;
- /* Tailwind slate-200 for border */
- --border: 214 32% 91%;
- --input: 214 32% 91%;
- /* Tailwind slate-700 for ring */
- --ring: 215 25% 27%;
- /* Chart colors using Tailwind palette with slate base */
- --chart-1: 215 25% 27%;
- --chart-2: 200 98% 39%;
- --chart-3: 142 71% 45%;
- --chart-4: 25 95% 53%;
- --chart-5: 262 83% 58%;
- --radius: 0.75rem;
- }
-
- .dark {
- --background: 222 47% 11%;
- --foreground: 210 40% 98%;
- --card: 222 47% 11%;
- --card-foreground: 210 40% 98%;
- --popover: 222 47% 11%;
- --popover-foreground: 210 40% 98%;
- --primary: 200 98% 39%;
- --primary-foreground: 0 0% 100%;
- --secondary: 217 33% 17%;
- --secondary-foreground: 210 40% 98%;
- --muted: 217 33% 17%;
- --muted-foreground: 215 20% 65%;
- --accent: 217 33% 17%;
- --accent-foreground: 210 40% 98%;
- --destructive: 0 84% 60%;
- --destructive-foreground: 0 0% 98%;
- --border: 217 33% 17%;
- --input: 217 33% 17%;
- --ring: 200 98% 39%;
- --chart-1: 200 98% 39%;
- --chart-2: 142 71% 45%;
- --chart-3: 262 83% 58%;
- --chart-4: 25 95% 53%;
- --chart-5: 340 82% 52%;
- }
-
- * {
- @apply border-border;
- }
-
- body {
- @apply bg-background text-foreground;
- }
+/* woff2 and Latin only: one file per face the interface uses. */
+@font-face {
+ font-family: "IBM Plex Sans";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 400;
+ src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
+}
+@font-face {
+ font-family: "IBM Plex Sans";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 500;
+ src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
+}
+@font-face {
+ font-family: "IBM Plex Sans";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 600;
+ src: url("../../node_modules/@fontsource/ibm-plex-sans/files/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
+}
+@font-face {
+ font-family: "IBM Plex Mono";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 400;
+ src: url("../../node_modules/@fontsource/ibm-plex-mono/files/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
-/* Custom component styles have been replaced with shadcn-vue components */
+@theme {
+ --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
+ --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
+}
+
+/* AppHeader's bar height (its default h-14) and the sidebar's sticky offset. */
+:root {
+ --header-h: calc(var(--spacing) * 14);
+}
+
+html {
+ scroll-padding-top: calc(var(--header-h) + var(--spacing) * 2);
+}
+
+@media (prefers-reduced-motion: reduce) {
+ *,
+ *::before,
+ *::after {
+ animation-duration: 0.01ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 0.01ms !important;
+ scroll-behavior: auto !important;
+ }
+}
diff --git a/frontend/src/styles/main.spec.ts b/frontend/src/styles/main.spec.ts
new file mode 100644
index 0000000..fa2ae24
--- /dev/null
+++ b/frontend/src/styles/main.spec.ts
@@ -0,0 +1,30 @@
+// @vitest-environment node
+import { describe, expect, it } from 'vitest'
+import css from './main.css?raw'
+import { librarySources } from '../../scripts/library-sources.mjs'
+
+const root = new URL('../..', import.meta.url).pathname
+
+describe('main.css', () => {
+ it('imports the library theme and the workbench pack', () => {
+ expect(css).toContain('@import "@perfect-design/ui/theme.css"')
+ expect(css).toContain('@import "@perfect-design/ui/packs/workbench.css"')
+ })
+
+ it('scans only the library directories the app imports (run `pnpm sources` after changing imports)', () => {
+ const declared = css.split('\n').filter((line: string) => line.startsWith('@source '))
+ expect(declared).toEqual(librarySources(root))
+ expect(css).not.toMatch(/@source "[^"]*\/dist"/)
+ })
+
+ it('loads the Plex faces as Latin woff2 only', () => {
+ const urls = [...css.matchAll(/url\("([^"]+)"\)/g)].map((m) => m[1])
+ expect(urls.length).toBe(4)
+ for (const url of urls) expect(url).toMatch(/-latin-\d{3}-normal\.woff2$/)
+ })
+
+ it('shares one header height token with the scroll offset', () => {
+ expect(css).toMatch(/--header-h:/)
+ expect(css).toMatch(/scroll-padding-top:\s*calc\(var\(--header-h\)/)
+ })
+})
diff --git a/frontend/src/test/fixtures.ts b/frontend/src/test/fixtures.ts
new file mode 100644
index 0000000..c804b10
--- /dev/null
+++ b/frontend/src/test/fixtures.ts
@@ -0,0 +1,160 @@
+import type { Package, Stats } from '@/stores/packages'
+
+export const STATS: Stats = {
+ registry: '',
+ total_packages: 4,
+ total_size: 5368709120,
+ max_cache_size: 10737418240,
+ total_downloads: 120,
+ scanned_packages: 3,
+ vulnerable_packages: 2,
+ blocked_packages: 1,
+}
+
+export const REGISTRIES = {
+ npm: { count: 2, size: 2147483648, downloads: 80 },
+ pypi: { count: 1, size: 1073741824, downloads: 30 },
+ go: { count: 1, size: 2147483648, downloads: 10 },
+}
+
+export const PACKAGES: Package[] = [
+ {
+ id: 'npm-1',
+ registry: 'npm',
+ name: 'left-pad',
+ version: '1.3.0',
+ size: 2048,
+ cached_at: '2026-01-03T10:00:00Z',
+ last_accessed: '2026-01-03T10:00:00Z',
+ download_count: 40,
+ vulnerabilities: {
+ scanned: true,
+ status: 'vulnerable',
+ counts: { critical: 1, high: 2, moderate: 0, low: 1 },
+ total: 4,
+ scannedAt: '2026-01-03T10:05:00Z',
+ isBlocked: true,
+ },
+ },
+ {
+ id: 'npm-2',
+ registry: 'npm',
+ name: 'left-pad',
+ version: '1.2.0',
+ size: 1024,
+ cached_at: '2026-01-02T10:00:00Z',
+ last_accessed: '2026-01-02T10:00:00Z',
+ download_count: 40,
+ vulnerabilities: {
+ scanned: true,
+ status: 'vulnerable',
+ counts: { critical: 0, high: 0, moderate: 3, low: 0 },
+ total: 3,
+ scannedAt: '2026-01-02T10:05:00Z',
+ isBlocked: false,
+ },
+ },
+ {
+ id: 'pypi-1',
+ registry: 'pypi',
+ name: 'requests',
+ version: '2.31.0',
+ size: 4096,
+ cached_at: '2026-01-01T10:00:00Z',
+ last_accessed: '2026-01-01T10:00:00Z',
+ download_count: 30,
+ vulnerabilities: { scanned: true, status: 'clean', total: 0, scannedAt: '2026-01-01T10:05:00Z' },
+ },
+ {
+ id: 'go-1',
+ registry: 'go',
+ name: 'github.com/example/module',
+ version: 'v0.4.1',
+ size: 512,
+ cached_at: '2026-01-04T10:00:00Z',
+ last_accessed: '2026-01-04T10:00:00Z',
+ download_count: 10,
+ vulnerabilities: { scanned: false, status: 'not_scanned' },
+ },
+]
+
+export const TIMESERIES = {
+ period: '1day',
+ registry: '',
+ data_points: [
+ { timestamp: '2026-01-04T08:00:00Z', value: 3 },
+ { timestamp: '2026-01-04T09:00:00Z', value: 7 },
+ { timestamp: '2026-01-04T10:00:00Z', value: 5 },
+ ],
+}
+
+export const VULNERABILITY_REPORT = {
+ scanned: true,
+ scanner: 'trivy+osv',
+ scanned_at: '2026-01-03T10:05:00Z',
+ status: 'vulnerable',
+ vulnerability_count: 3,
+ bypassed_count: 1,
+ severity_counts: { critical: 1, high: 1, moderate: 0, low: 1 },
+ vulnerabilities: [
+ {
+ id: 'CVE-2026-0001',
+ severity: 'LOW',
+ title: 'Low severity sample',
+ description: 'A **low** severity sample description.',
+ references: ['https://example.com/advisory/1'],
+ fixed_in: '1.3.1',
+ bypassed: false,
+ },
+ {
+ id: 'CVE-2026-0002',
+ severity: 'CRITICAL',
+ title: 'Critical severity sample',
+ description: 'A critical severity sample description.',
+ references: [],
+ fixed_in: '',
+ bypassed: true,
+ bypass: {
+ id: 'bypass-1',
+ reason: 'No fix available',
+ created_by: 'admin@example.com',
+ expires_at: '2026-02-01T00:00:00Z',
+ },
+ },
+ {
+ id: 'CVE-2026-0003',
+ severity: 'HIGH',
+ title: '',
+ description: 'A high severity sample description.',
+ references: [],
+ fixed_in: '2.0.0',
+ bypassed: false,
+ },
+ ],
+}
+
+export const BYPASSES = [
+ {
+ id: 'bypass-1',
+ type: 'cve',
+ target: 'CVE-2026-0002',
+ reason: 'No fix available',
+ created_by: 'admin@example.com',
+ created_at: '2026-01-01T00:00:00Z',
+ expires_at: '2099-01-01T00:00:00Z',
+ applies_to: 'npm/left-pad@1.3.0',
+ notify_on_expiry: true,
+ active: true,
+ },
+ {
+ id: 'bypass-2',
+ type: 'package',
+ target: 'npm/left-pad',
+ reason: 'Pinned until the next release',
+ created_by: 'admin@example.com',
+ created_at: '2025-01-01T00:00:00Z',
+ expires_at: '2025-02-01T00:00:00Z',
+ notify_on_expiry: false,
+ active: false,
+ },
+]
diff --git a/frontend/src/test/mountStrict.spec.ts b/frontend/src/test/mountStrict.spec.ts
new file mode 100644
index 0000000..03f9f81
--- /dev/null
+++ b/frontend/src/test/mountStrict.spec.ts
@@ -0,0 +1,14 @@
+import { describe, expect, it } from 'vitest'
+import { defineComponent, h } from 'vue'
+import { Input } from '@perfect-design/ui'
+import { mountStrict } from './mountStrict'
+
+describe('mountStrict', () => {
+ it('reports a library contract violation, so an empty list in a smoke test means something', async () => {
+ const Unnamed = defineComponent({ render: () => h(Input) })
+ const { problems, restore } = await mountStrict(Unnamed)
+ restore()
+ expect(problems.length).toBeGreaterThan(0)
+ expect(problems.join(' ')).toMatch(/accessible name/i)
+ })
+})
diff --git a/frontend/src/test/mountStrict.ts b/frontend/src/test/mountStrict.ts
new file mode 100644
index 0000000..1797a44
--- /dev/null
+++ b/frontend/src/test/mountStrict.ts
@@ -0,0 +1,37 @@
+import { configureStrictMode } from '@perfect-design/ui'
+import { flushPromises, mount, type ComponentMountingOptions } from '@vue/test-utils'
+import { vi } from 'vitest'
+import type { Component } from 'vue'
+
+/**
+ * Mounts under strict mode 'throw' and returns every Vue warning, Vue error and library ContractError seen,
+ * so a smoke test can assert the list is empty. The library runs its contract checks from async onMounted hooks.
+ */
+export async function mountStrict(component: Component, options: ComponentMountingOptions = {}) {
+ configureStrictMode('throw')
+ const problems: string[] = []
+ const record = (kind: string) => (err: unknown) => {
+ problems.push(`${kind}: ${err instanceof Error ? err.message : String(err)}`)
+ }
+ const warn = vi.spyOn(console, 'warn').mockImplementation((...args) => record('warn')(args.join(' ')))
+ const error = vi.spyOn(console, 'error').mockImplementation((...args) => record('error')(args.join(' ')))
+
+ const wrapper = mount(component, {
+ attachTo: document.body,
+ ...options,
+ global: {
+ ...options.global,
+ config: { errorHandler: record('error'), warnHandler: record('warn') },
+ },
+ })
+ await flushPromises()
+ await new Promise((resolve) => setTimeout(resolve, 0))
+ await flushPromises()
+
+ const restore = () => {
+ wrapper.unmount()
+ warn.mockRestore()
+ error.mockRestore()
+ }
+ return { wrapper, problems, restore }
+}
diff --git a/frontend/src/test/router.ts b/frontend/src/test/router.ts
new file mode 100644
index 0000000..e21f59d
--- /dev/null
+++ b/frontend/src/test/router.ts
@@ -0,0 +1,24 @@
+import { createMemoryHistory, createRouter, type Router } from 'vue-router'
+import { defineComponent, h } from 'vue'
+
+const Stub = defineComponent({ render: () => h('div') })
+
+export const ROUTE_PATHS = [
+ '/',
+ '/packages/:registry?',
+ '/package/:registry/:name+/:version',
+ '/stats',
+ '/vulnerable-packages',
+ '/blocked-packages',
+ '/admin/bypasses',
+]
+
+export async function createTestRouter(initial = '/'): Promise {
+ const router = createRouter({
+ history: createMemoryHistory(),
+ routes: ROUTE_PATHS.map((path) => ({ path, component: Stub })),
+ })
+ await router.push(initial)
+ await router.isReady()
+ return router
+}
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 0aa1793..5593d9a 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,17 +1,25 @@
-import { defineConfig } from 'vite'
+import { defineConfig, type Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'
-import path from 'path'
+import { themeBootScript } from '@perfect-design/ui/stores/theme-boot'
// Get backend URL from environment or use default
const BACKEND_URL = process.env.VITE_BACKEND_URL || 'http://localhost:8080'
const FRONTEND_PORT = parseInt(process.env.VITE_PORT || '5173')
+// Applies the saved colour mode before first paint so a dark system never flashes light.
+function themeBoot(): Plugin {
+ return {
+ name: 'theme-boot',
+ transformIndexHtml: () => [{ tag: 'script', children: themeBootScript, injectTo: 'head' }],
+ }
+}
+
export default defineConfig({
- plugins: [vue(), tailwindcss()],
+ plugins: [vue(), tailwindcss(), themeBoot()],
resolve: {
alias: {
- '@': path.resolve(__dirname, './src'),
+ '@': import.meta.dirname + '/src',
},
},
server: {
diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts
index 3e38ccc..b469136 100644
--- a/frontend/vitest.config.ts
+++ b/frontend/vitest.config.ts
@@ -1,6 +1,5 @@
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
-import path from 'path'
export default defineConfig({
plugins: [vue()],
@@ -8,10 +7,12 @@ export default defineConfig({
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
+ // main.spec.ts reads main.css as text; vitest otherwise replaces stylesheets with an empty string.
+ css: { include: [/main\.css/] },
},
resolve: {
alias: {
- '@': path.resolve(__dirname, './src'),
+ '@': import.meta.dirname + '/src',
},
},
})