Browse Source

Fixed frontend/backend tests

maziggy 4 months ago
parent
commit
576734c897

+ 8 - 8
backend/app/api/routes/support.py

@@ -212,7 +212,7 @@ def _read_log_entries(
                 if parsed:
                 if parsed:
                     # Found a new log entry start
                     # Found a new log entry start
                     if current_entry:
                     if current_entry:
-                        # Apply filters and add previous entry
+                        # Apply filters and add previous entry (without multi_line_buffer - it belongs to new entry)
                         should_include = True
                         should_include = True
 
 
                         # Level filter
                         # Level filter
@@ -229,21 +229,23 @@ def _read_log_entries(
                                 should_include = False
                                 should_include = False
 
 
                         if should_include:
                         if should_include:
-                            # Append any multi-line content
-                            if multi_line_buffer:
-                                current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer))
                             entries.append(current_entry)
                             entries.append(current_entry)
 
 
                             if len(entries) >= limit:
                             if len(entries) >= limit:
                                 break
                                 break
 
 
+                    # Set new entry and attach any accumulated multi-line content to it
+                    # (in reverse order, continuation lines come before their parent entry)
                     current_entry = parsed
                     current_entry = parsed
+                    if multi_line_buffer:
+                        current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer))
                     multi_line_buffer = []
                     multi_line_buffer = []
-                elif current_entry and line.strip():
-                    # Continuation of multi-line log entry
+                elif line.strip():
+                    # Continuation of multi-line log entry (will be attached to next parsed entry)
                     multi_line_buffer.append(line.rstrip())
                     multi_line_buffer.append(line.rstrip())
 
 
             # Don't forget the last (oldest) entry
             # Don't forget the last (oldest) entry
+            # Note: any remaining multi_line_buffer would be orphaned lines before the first entry
             if current_entry and len(entries) < limit:
             if current_entry and len(entries) < limit:
                 should_include = True
                 should_include = True
                 if level_filter and current_entry.level.upper() != level_filter.upper():
                 if level_filter and current_entry.level.upper() != level_filter.upper():
@@ -256,8 +258,6 @@ def _read_log_entries(
                     ):
                     ):
                         should_include = False
                         should_include = False
                 if should_include:
                 if should_include:
-                    if multi_line_buffer:
-                        current_entry.message += "\n" + "\n".join(reversed(multi_line_buffer))
                     entries.append(current_entry)
                     entries.append(current_entry)
 
 
     except Exception as e:
     except Exception as e:

+ 5 - 4
frontend/src/__tests__/components/PrintModal.test.tsx

@@ -454,7 +454,7 @@ describe('PrintModal', () => {
       expect(mockOnClose).toHaveBeenCalled();
       expect(mockOnClose).toHaveBeenCalled();
     });
     });
 
 
-    it('shows printer dropdown for single selection', async () => {
+    it('shows printer selector for single selection', async () => {
       const item = createMockQueueItem();
       const item = createMockQueueItem();
 
 
       render(
       render(
@@ -467,8 +467,9 @@ describe('PrintModal', () => {
         />
         />
       );
       );
 
 
+      // PrinterSelector shows printer names directly
       await waitFor(() => {
       await waitFor(() => {
-        expect(screen.getByText('Printer')).toBeInTheDocument();
+        expect(screen.getByText('P1S')).toBeInTheDocument();
       });
       });
     });
     });
   });
   });
@@ -489,7 +490,7 @@ describe('PrintModal', () => {
       });
       });
     });
     });
 
 
-    it('shows info message when multiple printers selected', async () => {
+    it('shows selected count when multiple printers selected', async () => {
       const user = userEvent.setup();
       const user = userEvent.setup();
       render(
       render(
         <PrintModal
         <PrintModal
@@ -507,7 +508,7 @@ describe('PrintModal', () => {
       await user.click(screen.getByText('Select all'));
       await user.click(screen.getByText('Select all'));
 
 
       await waitFor(() => {
       await waitFor(() => {
-        expect(screen.getByText(/Slot mapping below applies to all/)).toBeInTheDocument();
+        expect(screen.getByText(/2 printers selected/)).toBeInTheDocument();
       });
       });
     });
     });