From 63f81714fba398f1ff21c20052ffa3cced5a0c21 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 23 Sep 2026 22:09:50 +0930 Subject: [PATCH] Test result bug (#12918) * [UI] Fix for test results * Display all results in expanded table row * Fix uni ttest --- .../tables/stock/StockItemTestResultTable.tsx | 36 +++++++++++-------- src/frontend/tests/pui_settings.spec.ts | 7 ++++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx index 39119e9ad2..41fa549e51 100644 --- a/src/frontend/src/tables/stock/StockItemTestResultTable.tsx +++ b/src/frontend/src/tables/stock/StockItemTestResultTable.tsx @@ -113,20 +113,26 @@ export default function StockItemTestResultTable({ // Iterate through the returned records // Sort test results using the same priority as the backend: // finished_datetime -> started_datetime -> date -> pk - records.toSorted(compareTestResults).forEach((record) => { - // Find matching template - const idx = results.findIndex( - (r: any) => r.templateId == record.template - ); - if (idx >= 0) { - results[idx] = { - ...results[idx], - ...record - }; + // Note: compareTestResults sorts newest-first, but we need to iterate + // oldest-first here, so that the most recent result is processed last + // and ends up displayed as the primary result for its template. + records + .toSorted(compareTestResults) + .toReversed() + .forEach((record) => { + // Find matching template + const idx = results.findIndex( + (r: any) => r.templateId == record.template + ); + if (idx >= 0) { + results[idx] = { + ...results[idx], + ...record + }; - results[idx].results.push(record); - } - }); + results[idx].results.push(record); + } + }); return results; }, @@ -464,7 +470,7 @@ export default function StockItemTestResultTable({ return null; } - const results = record?.results ?? []; + const results = record?.results?.toReversed() ?? []; return ( ); } diff --git a/src/frontend/tests/pui_settings.spec.ts b/src/frontend/tests/pui_settings.spec.ts index ae5e4f5035..56c646213c 100644 --- a/src/frontend/tests/pui_settings.spec.ts +++ b/src/frontend/tests/pui_settings.spec.ts @@ -441,12 +441,19 @@ test('Settings - Admin - Parameter', async ({ browser }) => { await loadTab(page, 'Selection Lists'); // Check for expected entry + await page + .getByRole('textbox', { name: 'table-search-input' }) + .fill('Animals'); await page.getByRole('cell', { name: 'Animals', exact: true }).waitFor(); await page.getByText('Various animals and descriptions thereof').waitFor(); await page.waitForLoadState('networkidle'); await page.waitForTimeout(250); + await page.getByRole('textbox', { name: 'table-search-input' }).fill('some'); + await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); + // Clean old list data if exists await page .getByRole('cell', { name: 'some list' })