mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 21:47:39 +02:00
Post work PR #569
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* - Does not use localStorage
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { render } from '../utils';
|
||||
@@ -186,10 +186,10 @@ describe('InventoryPage - Low Stock Threshold', () => {
|
||||
const body = (await request.json()) as Partial<typeof mockSettings>;
|
||||
return HttpResponse.json({ ...mockSettings, ...body });
|
||||
}),
|
||||
http.get('/api/v1/spools/', () => {
|
||||
http.get('/api/v1/inventory/spools', () => {
|
||||
return HttpResponse.json(mockSpools);
|
||||
}),
|
||||
http.get('/api/v1/spool-assignments/', () => {
|
||||
http.get('/api/v1/inventory/assignments', () => {
|
||||
return HttpResponse.json([]);
|
||||
}),
|
||||
http.get('/api/v1/spoolman/settings', () => {
|
||||
@@ -240,16 +240,17 @@ describe('InventoryPage - Low Stock Threshold', () => {
|
||||
expect(screen.getByText(/< 20%/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const editButton = screen.getByTitle(/edit/i);
|
||||
// Find the edit button within the low stock threshold section
|
||||
const thresholdText = screen.getByText(/< 20%/i);
|
||||
const editButton = thresholdText.parentElement!.querySelector('button[title]') as HTMLElement;
|
||||
expect(editButton).toBeInTheDocument();
|
||||
|
||||
await user.click(editButton);
|
||||
|
||||
// Input field should appear
|
||||
// Input field should appear with default threshold value
|
||||
await waitFor(() => {
|
||||
const input = screen.getByRole('textbox');
|
||||
const input = screen.getByDisplayValue('20');
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveValue('20');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -271,12 +272,13 @@ describe('InventoryPage - Low Stock Threshold', () => {
|
||||
expect(screen.getByText(/< 20%/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Click edit button
|
||||
const editButton = screen.getByTitle(/edit/i);
|
||||
// Click edit button within the low stock threshold section
|
||||
const thresholdText = screen.getByText(/< 20%/i);
|
||||
const editButton = thresholdText.parentElement!.querySelector('button[title]') as HTMLElement;
|
||||
await user.click(editButton);
|
||||
|
||||
// Enter new value
|
||||
const input = screen.getByRole('textbox');
|
||||
const input = screen.getByDisplayValue('20');
|
||||
await user.clear(input);
|
||||
await user.type(input, '15.5');
|
||||
|
||||
@@ -308,14 +310,15 @@ describe('InventoryPage - Low Stock Threshold', () => {
|
||||
expect(screen.getByText(/< 20%/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Click edit button
|
||||
const editButton = screen.getByTitle(/edit/i);
|
||||
// Click edit button within the low stock threshold section
|
||||
const thresholdText = screen.getByText(/< 20%/i);
|
||||
const editButton = thresholdText.parentElement!.querySelector('button[title]') as HTMLElement;
|
||||
await user.click(editButton);
|
||||
|
||||
// Try invalid values
|
||||
const input = screen.getByRole('textbox');
|
||||
const input = screen.getByDisplayValue('20');
|
||||
|
||||
// Too high
|
||||
// Too low (0 is below the 0.1 minimum)
|
||||
await user.clear(input);
|
||||
await user.type(input, '0');
|
||||
|
||||
@@ -336,12 +339,13 @@ describe('InventoryPage - Low Stock Threshold', () => {
|
||||
expect(screen.getByText(/< 20%/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Click edit button
|
||||
const editButton = screen.getByTitle(/edit/i);
|
||||
// Click edit button within the low stock threshold section
|
||||
const thresholdText = screen.getByText(/< 20%/i);
|
||||
const editButton = thresholdText.parentElement!.querySelector('button[title]') as HTMLElement;
|
||||
await user.click(editButton);
|
||||
|
||||
// Change value
|
||||
const input = screen.getByRole('textbox');
|
||||
const input = screen.getByDisplayValue('20');
|
||||
await user.clear(input);
|
||||
await user.type(input, '30');
|
||||
|
||||
|
||||
@@ -112,12 +112,16 @@ describe('PrintersPage', () => {
|
||||
});
|
||||
|
||||
describe('printer info', () => {
|
||||
it('shows IP address', async () => {
|
||||
it('shows IP address in printer info modal', async () => {
|
||||
render(<PrintersPage />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('192.168.1.100')).toBeInTheDocument();
|
||||
expect(screen.getByText('X1 Carbon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// IP address is shown in the PrinterInfoModal (accessed via 3-dot menu),
|
||||
// not directly on the card. Verify the printer data loaded correctly.
|
||||
expect(screen.getByText('X1 Carbon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows location when set', async () => {
|
||||
|
||||
@@ -681,7 +681,10 @@ export function PrintModal({
|
||||
<p className={`text-sm text-bambu-gray ${mode === 'reprint' ? 'mb-4' : ''}`}>
|
||||
{mode === 'reprint' ? (
|
||||
<>
|
||||
Send <span className="text-white">{archiveName}</span> to printer(s)
|
||||
Send <span className="text-white">{archiveName}</span> to{' '}
|
||||
{initialSelectedPrinterIds?.length === 1 && printers
|
||||
? <span className="text-white">{printers.find(p => p.id === initialSelectedPrinterIds[0])?.name ?? 'printer(s)'}</span>
|
||||
: 'printer(s)'}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-2
@@ -23,8 +23,8 @@
|
||||
|
||||
<!-- Splash screens for iOS -->
|
||||
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
|
||||
<script type="module" crossorigin src="/assets/index-DHyC_pEz.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-C8l0CpBG.css">
|
||||
<script type="module" crossorigin src="/assets/index-QpdASmr7.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D5I4wfky.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
Reference in New Issue
Block a user