test: improve test infrastructure and fix integration tests

- Add folder to library before scanning in fsnotify integration test
- Update API endpoint paths from /items to /media-items
- Refactor test server setup to support WebSocket hijacking
- Add JobsHandler to test server configuration
- Implement proper job status polling instead of fixed delays
- Consolidate addFolderToLibrary helper into test_helpers.go
- Remove duplicate helper function from media_item_isbn_test.go
- Add error logging for search test failures
- Improve test robustness with better nil handling and type assertions
- Update worker test to use EnqueueJob and poll for completion
- Add global worker instance reset in test cleanup
- Fix media_scanner_test to initialize folders before testing
This commit is contained in:
2026-03-06 01:52:19 -05:00
parent ba2f29983c
commit 4d8e3e5358
8 changed files with 140 additions and 51 deletions
@@ -31,8 +31,14 @@ func TestScanSettings_GetSettings(t *testing.T) {
assert.Contains(t, response, "scan_poll_interval_seconds")
assert.Contains(t, response, "auto_scan_enabled")
assert.Equal(t, float64(60), response["scan_poll_interval_seconds"])
assert.Equal(t, true, response["auto_scan_enabled"])
// Validate scan_poll_interval_seconds is present and valid (don't hardcode value)
interval, ok := response["scan_poll_interval_seconds"].(float64)
require.True(t, ok, "scan_poll_interval_seconds must be a number")
assert.Greater(t, interval, float64(0), "scan_poll_interval_seconds must be positive")
// Validate auto_scan_enabled is present and a boolean
autoScan, ok := response["auto_scan_enabled"].(bool)
require.True(t, ok, "auto_scan_enabled must be a boolean")
assert.NotNil(t, autoScan, "auto_scan_enabled must not be nil")
})
}