fix(printers): order the fan badges to match the physical layout

Place the left auxiliary fan badge before the right-hand auxiliary badge so
the row reads part cooling -> left aux -> aux -> chamber/exhaust, matching
the printer's physical left-to-right arrangement.

Adds a test asserting the rendered badge order.
This commit is contained in:
Gabe
2026-07-28 11:16:23 -05:00
parent 15ec0bf1c5
commit 03c35e06ce
2 changed files with 32 additions and 8 deletions
@@ -373,6 +373,28 @@ describe('PrintersPage', () => {
expect(screen.queryByTitle('Left Auxiliary Fan')).not.toBeInTheDocument();
});
it('orders the fan badges left-to-right: part, left aux, aux, exhaust', async () => {
// The two aux badges should read in the same order as the physical
// hardware, so the left fan sits before the right one.
renderWithStatus(
{ ...mockPrinters[0], model: 'P2S' },
{ ...statusWithFans, left_aux_fan_speed: 80, exhaust_fan_present: true },
);
await waitFor(() => {
expect(screen.getByTitle('Left Auxiliary Fan')).toBeInTheDocument();
});
const order = ['Part Cooling Fan', 'Left Auxiliary Fan', 'Auxiliary Fan', 'Exhaust'].map(
(title) => screen.getByTitle(title),
);
for (let i = 1; i < order.length; i++) {
// Node.compareDocumentPosition returns FOLLOWING (4) when the argument
// comes after the reference node in document order.
expect(order[i - 1].compareDocumentPosition(order[i])).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
}
});
it('shows left aux fan badge when the accessory is installed (P2S)', async () => {
renderWithStatus(
{ ...mockPrinters[0], model: 'P2S' },
+10 -8
View File
@@ -3923,16 +3923,11 @@ function PrinterCard({
Icon: Fan,
activeClass: 'text-cyan-600 dark:text-cyan-400',
},
{
key: 'aux',
label: t('printers.fans.auxiliary'),
value: status.big_fan1_speed ?? 0,
Icon: Wind,
activeClass: 'text-blue-600 dark:text-blue-400',
},
// Left auxiliary part cooling fan (optional P2S/X2D accessory).
// Only reported (non-null) when the firmware lists airduct part
// id 10, i.e. when the fan is physically installed.
// id 10, i.e. when the fan is physically installed. Placed
// before the right-hand auxiliary fan so the two aux badges read
// left-to-right in the same order as the physical hardware.
...(status.left_aux_fan_speed != null
? [
{
@@ -3944,6 +3939,13 @@ function PrinterCard({
},
]
: []),
{
key: 'aux',
label: t('printers.fans.auxiliary'),
value: status.big_fan1_speed ?? 0,
Icon: Wind,
activeClass: 'text-blue-600 dark:text-blue-400',
},
...(showChamberFan
? [
{