Просмотр исходного кода

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
maziggy 3 месяцев назад
Родитель
Сommit
104b9d4a25

+ 1 - 1
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,

+ 4 - 9
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(() => {

+ 5 - 0
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'],