From 5c263a0fc89debac8aa53004bb41f5f66de2be42 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:19:54 +0100 Subject: [PATCH 1/6] [O2B-1517] Fix table row loading check Number of rows must be different to that of the previous test otherwise waitForTable will execute and move on before the new data has been loaded. Therefore new test case added that will result in different number of rows prior. --- test/public/runs/runsPerLhcPeriod.overview.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/public/runs/runsPerLhcPeriod.overview.test.js b/test/public/runs/runsPerLhcPeriod.overview.test.js index 3a00301943..df55d6e450 100644 --- a/test/public/runs/runsPerLhcPeriod.overview.test.js +++ b/test/public/runs/runsPerLhcPeriod.overview.test.js @@ -153,10 +153,16 @@ module.exports = () => { const amountSelectorButtonSelector = `${amountSelectorId} button`; await pressElement(page, amountSelectorButtonSelector); + await fillInput(page, `${amountSelectorId} input[type=number]`, '3', ['input', 'change']); + await waitForTableLength(page, 3); + await expectInnerText(page, '.dropup button', 'Rows per page: 3 '); + + await pressElement(page, amountSelectorButtonSelector); await page.waitForSelector(`${amountSelectorId} .dropup-menu`); const amountItems5 = `${amountSelectorId} .dropup-menu .menu-item:first-child`; await pressElement(page, amountItems5, true); + // only 4 runs in LHC Period 1 await waitForTableLength(page, 4); await expectInnerText(page, '.dropup button', 'Rows per page: 5 '); From 33150afe67af50378c9b17a38e1c76597bd5c0f1 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:51:35 +0100 Subject: [PATCH 2/6] [O2B-1517] Fix order of assertions in runs per data pass test Moved the assertion for the dropup button text after waiting for the table length. --- test/public/runs/runsPerDataPass.overview.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/public/runs/runsPerDataPass.overview.test.js b/test/public/runs/runsPerDataPass.overview.test.js index 090384e0f6..0735f5bbb6 100644 --- a/test/public/runs/runsPerDataPass.overview.test.js +++ b/test/public/runs/runsPerDataPass.overview.test.js @@ -242,8 +242,8 @@ module.exports = () => { await pressElement(page, amountItems5); // Expect the amount of visible runs to reduce when the first option (5) is selected - await expectInnerText(page, '.dropup button', 'Rows per page: 5 '); await waitForTableLength(page, 4); + await expectInnerText(page, '.dropup button', 'Rows per page: 5 '); // Expect the custom per page input to have red border and text color if wrong value typed const customPerPageInput = await page.$(`${amountSelectorId} input[type=number]`); From ced51116459cc8c1618548aeda72b18fea342f17 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:19:35 +0100 Subject: [PATCH 3/6] [O2b-1517] Add table length wait in runsPerLhcPeriod overview test Inserted calls to waitForTableLength before table data validation to ensure the table is fully loaded before assertions. --- test/public/runs/runsPerLhcPeriod.overview.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/public/runs/runsPerLhcPeriod.overview.test.js b/test/public/runs/runsPerLhcPeriod.overview.test.js index df55d6e450..113aceb06a 100644 --- a/test/public/runs/runsPerLhcPeriod.overview.test.js +++ b/test/public/runs/runsPerLhcPeriod.overview.test.js @@ -110,6 +110,7 @@ module.exports = () => { ...Object.fromEntries(DETECTORS.map((detectorName) => [detectorName, (quality) => expect(quality).oneOf([...RUN_QUALITIES, ''])])), }; + await waitForTableLength(page, 4); await validateTableData(page, new Map(Object.entries(tableDataValidatorsWithDetectorQualities))); await waitForNavigation(page, () => pressElement(page, '#synchronousFlags-tab')); @@ -122,6 +123,7 @@ module.exports = () => { ])), }; + await waitForTableLength(page, 4); await validateTableData(page, new Map(Object.entries(tableDataValidatorsWithQualityFromSynchronousFlags))); await expectInnerText(page, '#row56-FT0', '83'); }); From 1f0b5d0429495d89db262fc82377a5ea05d0d2f8 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 18 Dec 2025 16:02:42 +0100 Subject: [PATCH 4/6] [O2B-1517] Add timeout option to waitForTableToLength helper The waitForTableToLength function now accepts an optional timeout parameter. Updated overview.test.js to use a 5000ms timeout when waiting for table rows in a troublesome test. --- test/public/defaults.js | 6 ++++-- test/public/envs/overview.test.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/public/defaults.js b/test/public/defaults.js index bb7ae4b811..c184c60d37 100644 --- a/test/public/defaults.js +++ b/test/public/defaults.js @@ -145,13 +145,15 @@ module.exports.waitForTimeout = waitForTimeout; * * @param {puppeteer.Page} page - The puppeteer page where the table is located. * @param {number} expectedSize - The expected number of table rows, excluding rows marked as loading or empty. + * @param {number} [timeout] - Max wait time in ms; if omitted, uses the page default timeout. * @return {Promise} Resolves once the expected number of rows is met, or the timeout is reached. */ -const waitForTableToLength = async (page, expectedSize) => { +const waitForTableToLength = async (page, expectedSize, timeout) => { try { + const waitOptions = timeout === undefined ? {} : { timeout }; await page.waitForFunction( (expectedSize) => document.querySelectorAll('table tbody tr:not(.loading-row):not(.empty-row)').length === expectedSize, - {}, + waitOptions, expectedSize, ); } catch { diff --git a/test/public/envs/overview.test.js b/test/public/envs/overview.test.js index 1b9fa872c6..e253b403ec 100644 --- a/test/public/envs/overview.test.js +++ b/test/public/envs/overview.test.js @@ -424,7 +424,7 @@ module.exports = () => { await fillInput(page, selector.fromDateSelector, fromDate, ['change']); await fillInput(page, selector.toDateSelector, toDate, ['change']); - await waitForTableLength(page, expectedIds.length); + await waitForTableLength(page, expectedIds.length, 5000); expect(await page.$$eval('tbody tr', (rows) => rows.map((row) => row.id))).to.eql(expectedIds.map(id => `row${id}`)); }; From bd03df7912d2d8f62a28443c134869b608380478 Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Thu, 18 Dec 2025 16:25:08 +0100 Subject: [PATCH 5/6] [O2B-1517] Fix selector for loading row in table test Corrects the selector for detecting loading rows. It should check for 'tbody' not body and understand that it can return an empty list and the double ! operator will treat this as a truthy value which is incorrect. --- test/public/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/public/defaults.js b/test/public/defaults.js index c184c60d37..443de2bacf 100644 --- a/test/public/defaults.js +++ b/test/public/defaults.js @@ -158,7 +158,7 @@ const waitForTableToLength = async (page, expectedSize, timeout) => { ); } catch { const actualSize = (await page.$$('tbody tr')).length; - const isThereLoadingRow = !!(await page.$$('table body tr.loading-row')) + const isThereLoadingRow = (await page.$$('table tbody tr.loading-row')).length > 0; throw new Error(`Expected table of length ${expectedSize}, but got ${actualSize} ${isThereLoadingRow ? ', loading-row' : ''}`); } }; From d147e661a33fb29600fd9fd831504dec82f038bd Mon Sep 17 00:00:00 2001 From: Isaac Hill <71404865+isaachilly@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:56:14 +0100 Subject: [PATCH 6/6] [O2B-1517] Add table length wait after filter resets in tests Confirm reset is finished before proceeding with further test actions. Issue with reset and debounce and assertions. --- test/public/envs/overview.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/public/envs/overview.test.js b/test/public/envs/overview.test.js index e253b403ec..02b5511cf2 100644 --- a/test/public/envs/overview.test.js +++ b/test/public/envs/overview.test.js @@ -442,6 +442,7 @@ module.exports = () => { ['eZF99lH6'], ); await resetFilters(page); + await waitForTableLength(page, 8, 10000); await filterOnCreatedAt( periodInputsSelectors, @@ -452,5 +453,6 @@ module.exports = () => { ['GIDO1jdkD', '8E4aZTjY', 'Dxi029djX'], ); await resetFilters(page); + await waitForTableLength(page, 8, 10000); }); };