test: remediate test suite, enable skipped frontend/SSE tests, and add comprehensive unit tests
Build and Push Docker Image / build (push) Successful in 53s
Docs Check / Markdown lint (push) Successful in 1m36s
Licence Check / Licence compatibility and copyright header verification (push) Failing after 2m31s
CI / Security audit (push) Successful in 2m55s
Docs Check / Mermaid diagram parse check (push) Successful in 3m24s
CI / Swagger Validation & Coverage (push) Successful in 3m30s
CI / Tests & coverage (push) Successful in 3m50s
Build and Push Docker Image / build (push) Successful in 53s
Docs Check / Markdown lint (push) Successful in 1m36s
Licence Check / Licence compatibility and copyright header verification (push) Failing after 2m31s
CI / Security audit (push) Successful in 2m55s
Docs Check / Mermaid diagram parse check (push) Successful in 3m24s
CI / Swagger Validation & Coverage (push) Successful in 3m30s
CI / Tests & coverage (push) Successful in 3m50s
- Deleted redundant unit test file tests/unit/dashboard.test.js - Enabled skipped frontend DOM state and API tests in tests/frontend/state.test.js - Fixed Supertest client socket abort exception in SSE stream integration tests using new graceful testClose parameter - Consolidated duplicate helpers in server/routes/history.js and server/utils/arrRetrievers.js to unified services TagMatcher and DownloadAssembler - Added comprehensive unit tests for loadSecrets.js, PollingSonarrRetriever.js, PollingRadarrRetriever.js, and ombiHelpers.js - Achieved a 100% Vitest pass rate (834/834 tests) with robust code coverage
This commit is contained in:
@@ -840,17 +840,102 @@ describe('POST /api/dashboard/blocklist-search', () => {
|
||||
// GET /api/dashboard/stream (SSE)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe.skip('GET /api/dashboard/stream — SSE with Ombi showAll filtering', () => {
|
||||
const OMBI_STREAM_FIXTURE = {
|
||||
movie: [
|
||||
{ id: 1, title: 'Movie 1', requestedUser: { userName: 'alice' } },
|
||||
{ id: 2, title: 'Movie 2', requestedUser: { userName: 'bob' } }
|
||||
],
|
||||
tv: [
|
||||
{ id: 3, title: 'TV 1', requestedUser: { userName: 'alice' } },
|
||||
{ id: 4, title: 'TV 2', requestedUser: { userName: 'bob' } }
|
||||
]
|
||||
};
|
||||
|
||||
describe('GET /api/dashboard/stream — SSE with Ombi showAll filtering', () => {
|
||||
let appInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
appInstance = createApp({ skipRateLimits: true });
|
||||
// Seed basic cached values to prevent on-demand poll
|
||||
cache.set('poll:sab-queue', { slots: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:radarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:qbittorrent', [], CACHE_TTL);
|
||||
cache.set('poll:ombi-requests', OMBI_STREAM_FIXTURE, CACHE_TTL);
|
||||
});
|
||||
|
||||
it('filters Ombi requests by user when showAll is false', async () => {
|
||||
// SSE endpoint requires EventSource or manual SSE handling for proper testing
|
||||
// The showAll flag logic for Ombi filtering is the same as GET /api/ombi/requests
|
||||
// which is tested in ombi.test.js (though skipped due to arrRetrieverRegistry complexity)
|
||||
// This test is skipped due to the complexity of testing SSE with supertest
|
||||
// TODO: Implement SSE testing with EventSource or manual chunk parsing
|
||||
const { cookies } = await loginAs(appInstance);
|
||||
|
||||
// Explicitly seed the cache to ensure we have the fixtures in memory
|
||||
cache.set('poll:sab-queue', { slots: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:radarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:qbittorrent', [], CACHE_TTL);
|
||||
cache.set('poll:ombi-requests', OMBI_STREAM_FIXTURE, CACHE_TTL);
|
||||
|
||||
const res = await request(appInstance)
|
||||
.get('/api/dashboard/stream')
|
||||
.query({ testClose: 'true' })
|
||||
.set('Cookie', cookies);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
const text = res.text;
|
||||
expect(text).toContain('data:');
|
||||
|
||||
// Parse the data payload
|
||||
const dataStr = text.substring(text.indexOf('{'));
|
||||
const data = JSON.parse(dataStr.trim());
|
||||
|
||||
expect(data.user).toBe('alice');
|
||||
expect(data.ombiRequests.movie).toHaveLength(1);
|
||||
expect(data.ombiRequests.movie[0].title).toBe('Movie 1');
|
||||
expect(data.ombiRequests.tv).toHaveLength(1);
|
||||
expect(data.ombiRequests.tv[0].title).toBe('TV 1');
|
||||
});
|
||||
|
||||
it('returns all Ombi requests when admin with showAll is true', async () => {
|
||||
// Same as above - SSE testing is complex
|
||||
// TODO: Implement SSE testing with EventSource or manual chunk parsing
|
||||
const { cookies } = await loginAs(appInstance, EMBY_ADMIN_USER, EMBY_ADMIN_AUTH);
|
||||
|
||||
// Explicitly seed the cache to ensure we have the fixtures in memory
|
||||
cache.set('poll:sab-queue', { slots: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:sonarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:radarr-queue', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-history', { records: [] }, CACHE_TTL);
|
||||
cache.set('poll:radarr-tags', [], CACHE_TTL);
|
||||
cache.set('poll:qbittorrent', [], CACHE_TTL);
|
||||
cache.set('poll:ombi-requests', OMBI_STREAM_FIXTURE, CACHE_TTL);
|
||||
|
||||
nock(EMBY_BASE)
|
||||
.get('/Users')
|
||||
.reply(200, [EMBY_USER, EMBY_ADMIN_USER]);
|
||||
|
||||
const res = await request(appInstance)
|
||||
.get('/api/dashboard/stream')
|
||||
.query({ showAll: 'true', testClose: 'true' })
|
||||
.set('Cookie', cookies);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
const text = res.text;
|
||||
expect(text).toContain('data:');
|
||||
|
||||
// Parse the data payload
|
||||
const dataStr = text.substring(text.indexOf('{'));
|
||||
const data = JSON.parse(dataStr.trim());
|
||||
|
||||
expect(data.user).toBe('admin');
|
||||
expect(data.ombiRequests.movie).toHaveLength(2);
|
||||
expect(data.ombiRequests.tv).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user