From 7d8a8fb0fc4126a1da41a39ff0ece198565c58eb Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Wed, 25 Mar 2026 01:12:11 +0300 Subject: [PATCH] feat(phase3): phase 7 - integration & polish Fix all build/type/lint errors, write 46 new tests (222 total across 20 files), regenerate Prisma client, update seed with user preferences. Fix SvelteSet usage, add {#each} keys, clean unused imports. --- plans/phase-3-advanced-features/CONTEXT.md | 9 +- plans/phase-3-advanced-features/PLAN.md | 4 +- .../phase-7-integration.md | 32 ++- prisma/seed.ts | 24 +- .../components/admin/DiscoveryPanel.svelte | 29 +- src/lib/components/app/SparklineChart.svelte | 2 +- .../settings/ThemeCustomizer.svelte | 3 +- src/lib/components/widget/AppWidget.svelte | 1 - .../__tests__/discoveryService.test.ts | 265 ++++++++++++++++++ .../services/__tests__/exportService.test.ts | 186 ++++++++++++ .../services/__tests__/importService.test.ts | 222 +++++++++++++++ src/lib/utils/__tests__/broadcastSync.test.ts | 137 +++++++++ .../apps/quick-add/__tests__/quickAdd.test.ts | 152 ++++++++++ .../preferences/__tests__/preferences.test.ts | 191 +++++++++++++ 14 files changed, 1223 insertions(+), 34 deletions(-) create mode 100644 src/lib/server/services/__tests__/discoveryService.test.ts create mode 100644 src/lib/server/services/__tests__/exportService.test.ts create mode 100644 src/lib/server/services/__tests__/importService.test.ts create mode 100644 src/lib/utils/__tests__/broadcastSync.test.ts create mode 100644 src/routes/api/apps/quick-add/__tests__/quickAdd.test.ts create mode 100644 src/routes/api/users/me/preferences/__tests__/preferences.test.ts diff --git a/plans/phase-3-advanced-features/CONTEXT.md b/plans/phase-3-advanced-features/CONTEXT.md index 914ad53..31c2574 100644 --- a/plans/phase-3-advanced-features/CONTEXT.md +++ b/plans/phase-3-advanced-features/CONTEXT.md @@ -1,7 +1,7 @@ # Feature Context: Phase 3 — Advanced Features ## Current State -Phase 2 is complete and merged. 176 tests, full build passes. Phase 3 in progress. Phase 1 (Import/Export), Phase 2 (Sparklines), and Phase 3 (User Theme Overrides) are complete. +Phase 7 (Integration & Polish) is complete. 222 tests across 20 test files, full build passes, `npm run check` 0 errors, `npm run lint` 0 errors. All phases 1-7 are done. ### Phase 1 (Import/Export) Summary exportService, importService, admin API endpoints, ImportExportPanel UI, Zod validation schema, i18n EN/RU translations. @@ -23,6 +23,13 @@ exportService, importService, admin API endpoints, ImportExportPanel UI, Zod val - Header user menu includes "Settings" link - i18n keys: `settings.title`, `settings.theme`, `settings.primary_color`, `settings.hue`, `settings.saturation`, `settings.background`, `settings.language`, `settings.save`, `settings.saving`, `settings.saved` (EN/RU) +### Phase 7 (Integration & Polish) Summary +- Prisma client regenerated with user preference fields +- Fixed lint errors: SvelteSet for reactive Set in DiscoveryPanel, `{#each}` keys in DiscoveryPanel/SparklineChart, unused vars in ThemeCustomizer/AppWidget +- 46 new tests: exportService (4), importService (9), discoveryService (10), preferences API (11), quick-add API (8), broadcastSync (4) +- Seed script updated: user preferences on admin/regular user, quick-add style Wiki.js app +- Final state: 222 tests, 0 build errors, 0 type errors, 0 lint errors + ## Cross-Phase Dependencies - Phases 1-3 are independent (import/export, sparklines, user themes) - Phase 4 (PWA) is independent diff --git a/plans/phase-3-advanced-features/PLAN.md b/plans/phase-3-advanced-features/PLAN.md index 895fe97..5136c90 100644 --- a/plans/phase-3-advanced-features/PLAN.md +++ b/plans/phase-3-advanced-features/PLAN.md @@ -25,7 +25,7 @@ Add import/export, ping history sparklines, user theme overrides, PWA support, D - [ ] Phase 4: PWA Support [frontend] → [subplan](./phase-4-pwa.md) - [ ] Phase 5: Auto-Discovery Docker/Traefik [backend] → [subplan](./phase-5-autodiscovery.md) - [ ] Phase 6: Bookmarklet & Multi-Tab Sync [fullstack] → [subplan](./phase-6-bookmarklet-sync.md) -- [ ] Phase 7: Integration & Polish [fullstack] → [subplan](./phase-7-integration.md) +- [x] Phase 7: Integration & Polish [fullstack] → [subplan](./phase-7-integration.md) ## Phase Progress Log @@ -37,7 +37,7 @@ Add import/export, ping history sparklines, user theme overrides, PWA support, D | Phase 4: PWA | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ | | Phase 5: Auto-Discovery | backend | ⬜ Not Started | ⬜ | ⬜ | ⬜ | | Phase 6: Bookmarklet/Sync | fullstack | ⬜ Not Started | ⬜ | ⬜ | ⬜ | -| Phase 7: Integration | fullstack | ⬜ Not Started | ⬜ | ⬜ | ⬜ | +| Phase 7: Integration | fullstack | ✅ Complete | ✅ | ✅ | ⬜ | ## Final Review - [ ] Comprehensive code review diff --git a/plans/phase-3-advanced-features/phase-7-integration.md b/plans/phase-3-advanced-features/phase-7-integration.md index 081d042..d659fc3 100644 --- a/plans/phase-3-advanced-features/phase-7-integration.md +++ b/plans/phase-3-advanced-features/phase-7-integration.md @@ -1,21 +1,29 @@ # Phase 7: Integration & Polish -**Status:** ⬜ Not Started +**Status:** ✅ Complete **Parent plan:** [PLAN.md](./PLAN.md) **Domain:** fullstack ## Tasks -- [ ] Task 1: Fix all TypeScript/build errors -- [ ] Task 2: Verify `npm run build` succeeds -- [ ] Task 3: Verify `npm run check` passes -- [ ] Task 4: Verify `npm run lint` passes -- [ ] Task 5: Write tests for export/import services -- [ ] Task 6: Write tests for discovery service -- [ ] Task 7: Write tests for user preferences API -- [ ] Task 8: Write tests for quick-add API -- [ ] Task 9: Update seed script with sample data -- [ ] Task 10: Verify all existing tests pass -- [ ] Task 11: Run Prisma migrations +- [x] Task 1: Fix all TypeScript/build errors +- [x] Task 2: Verify `npm run build` succeeds +- [x] Task 3: Verify `npm run check` passes (0 errors, warnings only) +- [x] Task 4: Verify `npm run lint` passes (0 errors) +- [x] Task 5: Write tests for export/import services +- [x] Task 6: Write tests for discovery service (mocked Docker/Traefik) +- [x] Task 7: Write tests for user preferences API +- [x] Task 8: Write tests for quick-add API +- [x] Task 9: Write tests for broadcastSync utility +- [x] Task 10: Update seed script with sample data (user preferences, quick-add style app) +- [x] Task 11: Run Prisma generate (migrations already applied) +- [x] Task 12: Verify all 222 tests pass across 20 test files + +## Changes Made + +- `prisma generate` — regenerated client with user preference fields +- Fixed lint: SvelteSet for reactive Set in DiscoveryPanel, `{#each}` keys, unused vars +- New tests: exportService (4), importService (9), discoveryService (10), preferences API (11), quick-add API (8), broadcastSync (4) = 46 new tests +- Updated seed.ts: user preferences on admin/regular user, quick-add style Wiki.js app ## Handoff diff --git a/prisma/seed.ts b/prisma/seed.ts index f5164cf..61b5e3c 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -36,7 +36,12 @@ async function main() { password: adminPassword, displayName: 'Administrator', role: 'admin', - authProvider: 'local' + authProvider: 'local', + themeMode: 'dark', + primaryHue: 240, + primarySaturation: 80, + backgroundType: 'aurora', + locale: 'en' } }); console.log(' Created admin user:', admin.email); @@ -51,7 +56,12 @@ async function main() { password: userPassword, displayName: 'Demo User', role: 'user', - authProvider: 'local' + authProvider: 'local', + themeMode: 'light', + primaryHue: 150, + primarySaturation: 60, + backgroundType: 'mesh', + locale: 'ru' } }); console.log(' Created regular user:', regularUser.email); @@ -168,6 +178,16 @@ async function main() { category: 'Network', tags: 'dns,adblock,network,privacy', healthcheckEnabled: true + }, + { + name: 'Wiki.js', + url: 'http://wiki.local:3000', + icon: 'http://wiki.local:3000/favicon.ico', + iconType: 'url', + description: 'Quick-added wiki service (demonstrates favicon URL icon)', + category: 'Productivity', + tags: 'wiki,docs,knowledge', + healthcheckEnabled: true } ]; diff --git a/src/lib/components/admin/DiscoveryPanel.svelte b/src/lib/components/admin/DiscoveryPanel.svelte index 19cfe67..205dd1b 100644 --- a/src/lib/components/admin/DiscoveryPanel.svelte +++ b/src/lib/components/admin/DiscoveryPanel.svelte @@ -1,5 +1,6 @@