ソースを参照

test: close the coroutines that mocked create_task, wait_for, run_coroutine_threadsafe, spawn_background_task and AsyncMock sessions left unawaited (reported as unraisable warnings in unrelated later tests); the Spoolman recovery tests archive under their own tmp_path instead of the shared archive/; the bulk mocks' HA sensor and queue single routes are mocked, so the batched-reads test no longer falls back to per-printer requests, and it waits for the batches to settle before checking

maziggy 1 日 前
親
コミット
9c61a52727

+ 4 - 0
frontend/src/__tests__/mocks/handlers.ts

@@ -541,6 +541,10 @@ export const handlers = [
   http.get('/api/v1/printers/:id/slot-presets', () => HttpResponse.json([])),
   http.get('/api/v1/smart-plugs/by-printer/:id', () => HttpResponse.json([])),
   http.get('/api/v1/smart-plugs/by-printer/:id/scripts', () => HttpResponse.json([])),
+  // Asked by the bulk mocks above for each id: without them the fan-out fails
+  // and the client falls back to one request per printer.
+  http.get('/api/v1/ha-sensors/by-printer/:id/readings', () => HttpResponse.json([])),
+  http.get('/api/v1/queue/', () => HttpResponse.json([])),
   http.get('/api/v1/spoolbuddy/devices', () => HttpResponse.json([])),
   http.get('/api/v1/spoolman/inventory/filaments', () => HttpResponse.json([])),
   http.get('/api/v1/spoolman/spools/linked', () => HttpResponse.json([])),

+ 4 - 0
frontend/src/__tests__/pages/PrintersPageBatchedReads.test.tsx

@@ -10,6 +10,7 @@ import { describe, it, expect, beforeEach } from 'vitest';
 import { waitFor } from '@testing-library/react';
 import { http, HttpResponse } from 'msw';
 import { server } from '../mocks/server';
+import { batchesSettled } from '../../api/batch';
 import { render } from '../utils';
 import { PrintersPage } from '../../pages/PrintersPage';
 
@@ -82,6 +83,9 @@ describe('PrintersPage — batched per-printer reads', () => {
         expect(paths.some((p) => p.startsWith(`/api/v1/bulk/${route}?ids=1,2,3`))).toBe(true);
       }
     });
+    // A bulk request that fails falls back to one request per printer, sent
+    // after it: wait for those too, or they land after the check.
+    await batchesSettled();
     const perPrinter = paths.filter((p) =>
       /^\/api\/v1\/(printers\/\d+\/(slot-presets|ams-labels)|smart-plugs\/by-printer\/\d+|ha-sensors\/by-printer\/\d+)/.test(p),
     );