From 57db7932e764ee7e2a8223986d2de2a11fe149b3 Mon Sep 17 00:00:00 2001 From: maziggy Date: Sun, 1 Feb 2026 16:29:37 +0100 Subject: [PATCH] Fix external spool ams_mapping2 slot_id (Issue #213) The ams_mapping2 format was incorrectly using the tray_id (254/255) as the slot_id for external spools. The printer expects slot_id to be the actual slot index (0 for main nozzle, 1 for deputy nozzle), not the tray_id value. Before: {"ams_id": 255, "slot_id": 254} <- invalid slot index After: {"ams_id": 255, "slot_id": 0} <- correct slot index This caused prints using external spool to fail immediately with error code 07FF_8007. Closes #213 --- frontend/src/__tests__/mocks/handlers.ts | 2 +- frontend/src/__tests__/setup.ts | 13 ++++--------- frontend/vitest.config.ts | 5 +++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/__tests__/mocks/handlers.ts b/frontend/src/__tests__/mocks/handlers.ts index ac6ac79ea..8d0158981 100644 --- a/frontend/src/__tests__/mocks/handlers.ts +++ b/frontend/src/__tests__/mocks/handlers.ts @@ -273,7 +273,7 @@ export const handlers = [ // Auth // ======================================================================== - http.get('/api/v1/auth/status', () => { + http.get('*/api/v1/auth/status', () => { return HttpResponse.json({ auth_enabled: false, requires_setup: false, diff --git a/frontend/src/__tests__/setup.ts b/frontend/src/__tests__/setup.ts index 2a46de464..83ab24145 100644 --- a/frontend/src/__tests__/setup.ts +++ b/frontend/src/__tests__/setup.ts @@ -11,17 +11,12 @@ import { server } from './mocks/server'; // Initialize i18n for tests (suppresses react-i18next warnings) import '../i18n'; -// Setup MSW server - bypass WebSocket requests so our mock handles them +// Setup MSW server beforeAll(() => server.listen({ - onUnhandledRequest: (request, _print) => { - // Allow WebSocket requests to pass through to our mock - if (request.url.includes('/ws')) { - return; - } - // Silently ignore unhandled requests in tests to reduce noise - // Remove 'warn' to completely silence, or use print.warning() to show warnings - }, + // Bypass unhandled requests silently (don't warn, just let them through) + // Handlers use wildcard (*) prefix to match any origin + onUnhandledRequest: 'bypass', }) ); afterEach(() => { diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index 520c0ebe5..84fc7261a 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -7,6 +7,11 @@ export default defineConfig({ test: { globals: true, environment: 'jsdom', + environmentOptions: { + jsdom: { + url: 'http://localhost:3000', + }, + }, setupFiles: ['./src/__tests__/setup.ts'], include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], exclude: ['node_modules', 'dist'],