Fix all Vitest test failures after migration
Build and Push Docker Image / build (push) Successful in 24s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 56s
CI / Security audit (push) Successful in 1m12s
CI / Tests & coverage (push) Successful in 1m25s
Docs Check / Markdown lint (pull_request) Successful in 41s
Licence Check / Licence compatibility and copyright header verification (pull_request) Successful in 1m14s
CI / Security audit (pull_request) Successful in 1m33s
Docs Check / Mermaid diagram parse check (pull_request) Successful in 1m56s
CI / Tests & coverage (pull_request) Successful in 2m3s
Build and Push Docker Image / build (push) Successful in 24s
Licence Check / Licence compatibility and copyright header verification (push) Successful in 56s
CI / Security audit (push) Successful in 1m12s
CI / Tests & coverage (push) Successful in 1m25s
Docs Check / Markdown lint (pull_request) Successful in 41s
Licence Check / Licence compatibility and copyright header verification (pull_request) Successful in 1m14s
CI / Security audit (pull_request) Successful in 1m33s
Docs Check / Mermaid diagram parse check (pull_request) Successful in 1m56s
CI / Tests & coverage (pull_request) Successful in 2m3s
- Replace vi.mock('axios') with nock for HTTP request mocking (ES/CJS interop issue)
- Fix RTorrentClient by mocking client.client.methodCall directly instead of xmlrpc module
- Fix downloadClients.test.js by manually adding mock clients to registry
- Fix qbittorrent.test.js to use getActiveDownloads() and normalized properties
- Fix integration test env var mocks and error assertions
- Fix SABnzbdClient size parsing and test fixtures
- Fix RTorrentClient ETA calculation expectation
All 261 tests now passing.
This commit is contained in:
@@ -158,9 +158,9 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Test1');
|
||||
expect(torrents[0].title).toBe('Test1');
|
||||
expect(torrents[0].instanceId).toBe('test-qbt');
|
||||
expect(torrents[0].hash).toBe('hash01');
|
||||
expect(torrents[0].id).toBe('hash01');
|
||||
expect(client.lastRid).toBe(1);
|
||||
});
|
||||
|
||||
@@ -177,7 +177,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
hash01: { name: 'Test1', state: 'downloading', size: 1000, progress: 0.5, dlspeed: 100, eta: 60, num_seeds: 5, num_leechs: 2, availability: 1.0 }
|
||||
}
|
||||
});
|
||||
await client.getTorrents();
|
||||
await client.getActiveDownloads();
|
||||
|
||||
// Second call — delta
|
||||
mockSync(1, {
|
||||
@@ -190,8 +190,8 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].dlspeed).toBe(200);
|
||||
expect(torrents[0].name).toBe('Test1');
|
||||
expect(torrents[0].speed).toBe(200);
|
||||
expect(torrents[0].title).toBe('Test1');
|
||||
expect(client.lastRid).toBe(2);
|
||||
});
|
||||
|
||||
@@ -208,7 +208,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
hash01: { name: 'Test1', state: 'downloading', size: 1000, progress: 0.5, dlspeed: 100, eta: 60, num_seeds: 5, num_leechs: 2, availability: 1.0 }
|
||||
}
|
||||
});
|
||||
await client.getTorrents();
|
||||
await client.getActiveDownloads();
|
||||
|
||||
// Server forces full refresh
|
||||
mockSync(1, {
|
||||
@@ -221,8 +221,8 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Test2');
|
||||
expect(torrents[0].hash).toBe('hash02');
|
||||
expect(torrents[0].title).toBe('Test2');
|
||||
expect(torrents[0].id).toBe('hash02');
|
||||
expect(client.lastRid).toBe(2);
|
||||
});
|
||||
|
||||
@@ -269,7 +269,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('Fallback');
|
||||
expect(torrents[0].title).toBe('Fallback');
|
||||
expect(client.fallbackThisCycle).toBe(true);
|
||||
});
|
||||
|
||||
@@ -294,7 +294,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('DirectLegacy');
|
||||
expect(torrents[0].title).toBe('DirectLegacy');
|
||||
expect(syncScope.isDone()).toBe(false);
|
||||
});
|
||||
|
||||
@@ -326,7 +326,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents).toHaveLength(1);
|
||||
expect(torrents[0].name).toBe('AfterReauth');
|
||||
expect(torrents[0].title).toBe('AfterReauth');
|
||||
});
|
||||
|
||||
it('computes completed from size and progress when missing', async () => {
|
||||
@@ -343,7 +343,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
});
|
||||
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents[0].completed).toBe(500);
|
||||
expect(torrents[0].downloaded).toBe(500);
|
||||
});
|
||||
|
||||
it('resets fallback flag when getAllTorrents resets it', async () => {
|
||||
@@ -364,7 +364,7 @@ describe('QBittorrentClient sync API', () => {
|
||||
// Simulate the reset that getAllTorrents performs
|
||||
client.fallbackThisCycle = false;
|
||||
const torrents = await client.getActiveDownloads();
|
||||
expect(torrents[0].name).toBe('ResetWorks');
|
||||
expect(torrents[0].title).toBe('ResetWorks');
|
||||
expect(client.fallbackThisCycle).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user