Commit Graph
15 Commits
Author SHA1 Message Date
john-okeefe f54508e4dd test: improve test isolation and setup management
Add Token and RegularToken fields to TestServerSetup for pre-authenticated
access. Update setupTestServer to create fresh users with valid tokens at
initialization time. Simplify createTestMediaItemID to use setup.Token.
Remove loginTestUser, loginRegularUser, loginAdminUser functions in favor
of setup.Token/setup.RegularToken. Update createTestUserOnce and
getTestUserID/getRegularUserID to be idempotent. Update all test files to
use setup.Token instead of calling login helpers.
2026-02-22 01:57:22 -05:00
john-okeefe 8e054bd149 fix: update test files for token handling and response parsing
- Update callers of createTestMediaItemID to not pass token
- Fix loginAdminUser to delete/recreate admin user for consistent state
- Fix TestListAllQueueItems_Admin to parse response as map with 'items' key
- Remove unused token variables from tests
- Update device_test.go with admin password hash constant
2026-02-14 00:12:28 -05:00
john-okeefe 9ec2d3c37d Phase 1: Convert device_test.go to struct-based assertions with DB verification
- Convert TestListDevices from map to handlers.DeviceListResponse
- Convert TestUpdateDevice to use handlers.DeviceUpdateRequest
- Add database verification after device update:
  * Query DB to verify sync_enabled, sync_frequency actually updated
  * Ensures data integrity - API says success, DB confirms it
- Impact: Compile-time safety for device endpoints, data integrity verification

Pattern: Replaces map[string]interface{} with type-safe structs,
ensures API changes caught at compile time, operations actually persist.
2026-02-13 17:42:06 -05:00
john-okeefe 527c406f75 test: add comprehensive device token regeneration tests
- Test successful token regeneration
- Verify old tokens are invalidated after regeneration
- Test unauthorized and forbidden access scenarios
- Test not found and device type-specific behavior
- Validate sync URLs contain new tokens
2026-02-13 16:37:58 -05:00
john-okeefe 5b32b59781 fix(tests): Fix edge cases in test file migration 2026-02-10 13:03:32 -05:00
john-okeefe 6c610465eb refactor(tests): Update all test files to use TestServerSetup pattern 2026-02-10 13:01:12 -05:00
john-okeefe 2b24dd9dd3 fix: Fix failing integration tests and update documentation
- Fix TestUpdateDevice: Use correct JSON field name and handle float64 type
- Fix TestRejectDeviceRegistration: Expect message response instead of boolean
- Update approve device docs: Add missing response fields
- Update reject device docs: Correct message text and format
- Update Bruno API: Fix example response for reject endpoint

Both integration tests now pass while maintaining API consistency.
2026-02-10 10:22:19 -05:00
john-okeefe 1413c75b26 fix: Fix device response fields and add missing approved confirmation
feat: Improve device test infrastructure with setupDeviceTest helper

refactor: Standardize pending registrations API response field names
2026-02-10 09:31:35 -05:00
john-okeefe 2ff8506718 test: update conflicts and device test signatures
- Remove handler parameter from test function calls
- Update test signatures to match new setupTestServer return values
- Fix compilation errors after test helper refactoring
- Ensure test consistency across all test files
2026-02-06 17:06:12 -05:00
john-okeefe 4e1feca124 Rename test file references: Bookmann → Bookhoard
Test file updates:
- Update import paths in test files: bookmann/internal → bookhoard/internal
- Update test helper functions and references
- Update test comments and documentation

This is part 6 of the project rename to Bookhoard.
2026-02-01 16:12:18 -05:00
john-okeefe 5a7144b98e feat: add device management and queue management routes
- Add /devices route for device management interface
- Add /conflicts route for sync conflict resolution
- Add /queue route for sync queue management
- Add comprehensive tests for device cap management
- Add test suite for queue management
2026-01-31 18:25:28 -05:00
john-okeefe a3aa9f67ac feat: add Kobo device sync support and fix device route protection
- Add Kobo sync handler with markup, bookmark, analytics, and initialization endpoints
- Add Kobo integration tests and Bruno API test collection
- Move device approve/reject routes from public to protected routes
- Enhance test infrastructure with DATABASE_URL support and helper functions
- Fix device GetDevice handler nil pointer handling
- Clean up test reports and session files
2026-01-30 23:58:34 -05:00
john-okeefe 77d683277a test: add WebSocket integration tests
Add comprehensive WebSocket test coverage:
- TestWebSocketConnection: Basic connection and JWT auth
- TestWebSocketDeviceAuth: Device token authentication
- TestWebSocketProgressBroadcast: Real-time update delivery
- TestWebSocketPingPong: Heartbeat mechanism
- TestWebSocketConnectionLimit: Multiple concurrent connections
- TestWebSocketInvalidToken: Rejection of invalid tokens
- Helper function for test media item creation

Update test helpers to create ConnectionManager for tests.
Tests verify WebSocket connection, authentication, and
real-time progress broadcast functionality.
2026-01-30 21:48:30 -05:00
john-okeefe 95fe849eeb Fix test infrastructure and device UUID handling
- Remove manual device ID generation, use database-generated IDs
- Add comprehensive test helpers (setupTestServer, loginTestUser, getTestUserID)
- Add cleanup step for existing test users in integration tests
- Fix UUID parsing from database responses
2026-01-30 20:16:19 -05:00
john-okeefe 9d32e5a0f0 Add comprehensive integration tests for Phase 2 device management
Test Files Added:
- integration_test.sh: Automated integration test script
  * Tests full user flow: register, login, library creation, scanning
  * Tests device registration and management
  * Color-coded output with pass/fail tracking
  * Generates detailed test results report

- cmd/server/tests/device_test.go: Unit tests for device endpoints
  * TestDeviceRegistrationFlow: Full registration flow test
  * TestListDevices: Device listing functionality
  * TestUpdateDevice: Device settings updates
  * TestDeleteDevice: Device removal
  * TestDeviceAuthentication: Device auth middleware test

- cmd/server/tests/phase1_integration_test.go: Phase 1 integration tests
  * Tests universal progress tracking
  * Tests format group detection
  * Tests progress conversion

Test Coverage:
- Device registration with web-based approval flow
- Device management (list, update, delete)
- Device authentication and token validation
- User authentication and authorization
- Library creation and management
- Scanner integration
- Media items listing

Notes:
- Tests designed to run against live server on localhost:8765
- Integration test script uses bash/curl for endpoint testing
- Device tests require helper functions to be implemented
2026-01-30 16:57:01 -05:00