Commit c27fbc0
committed
test: add comprehensive testing infrastructure and 166 tests
Add complete testing framework for Web application with 166 passing tests
covering all critical paths, security controls, and business logic.
Test Infrastructure:
- Vitest + @testing-library/svelte + happy-dom setup
- Mock D1 database with datetime comparison support
- Test fixtures and helpers for common test patterns
- Enhanced D1 mock supporting UPDATE literals and INSERT datetime functions
New Test Files (166 tests total):
- src/lib/test/setup.test.ts (4 tests) - test infrastructure verification
- src/lib/test/migration-0006.test.ts (9 tests) - migration logic
- src/routes/[username]/[slug]/install/server.test.ts (10 tests) - install script visibility
- src/routes/[username]/[slug]/config/server.test.ts (7 tests) - config JSON visibility
- src/routes/api/configs/server.test.ts (21 tests) - config CRUD (list)
- src/routes/api/configs/[slug]/server.test.ts (25 tests) - config CRUD (single)
- src/routes/api/auth/cli/start/server.test.ts (9 tests) - CLI auth start
- src/routes/api/auth/cli/poll/server.test.ts (9 tests) - CLI auth polling
- src/routes/api/auth/cli/approve/server.test.ts (10 tests) - CLI auth approval
- src/lib/server/install-script.test.ts (33 tests) - install script generation
- src/lib/server/validation.test.ts (29 tests) - input validation functions
Key Coverage:
- OAuth flow (start/poll/approve) with Bearer token auth
- 3-tier visibility model (public/unlisted/private)
- Private config access control and error handling
- Install script generation (public and private variants)
- Custom script and dotfiles integration
- Input validation (XSS, open redirect, shell injection prevention)
- Migration logic (is_public → visibility field)
- Rate limiting and error scenarios
CI/CD:
- Add test step to deploy workflow (.github/workflows/deploy.yml)
- Tests run before every deployment
All tests passing. Build verified.1 parent c1e8187 commit c27fbc0
File tree
19 files changed
+5031
-1
lines changed- .github/workflows
- src
- lib
- server
- test
- routes
- [username]/[slug]
- config
- install
- api
- auth/cli
- approve
- poll
- start
- configs
- [slug]
19 files changed
+5031
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
0 commit comments