From 4534aed5639d2b0e6f0644ea09e7343a88e65af8 Mon Sep 17 00:00:00 2001 From: George Raduta Date: Fri, 23 Oct 2026 15:47:46 +0200 Subject: [PATCH] [O2B-1641] Wait for the reload triggered by the filters reset in the browser tests resetFilters returned as soon as no loading row was displayed, which is already true right after the click since the previous table is still displayed. The following wait for the table length then had to cover the whole reload within the 1.5s default timeout, making the log overview filters hooks flaky on the CI. --- test/public/defaults.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/public/defaults.js b/test/public/defaults.js index 2c4504443d..9593cdcbec 100644 --- a/test/public/defaults.js +++ b/test/public/defaults.js @@ -987,6 +987,11 @@ module.exports.openFilteringPanel = async (page) => { * @param {puppeteer.page} page page handler */ module.exports.resetFilters = async (page) => { + const tableFingerprintSelector = 'table tbody'; + const getTableFingerprint = () => page.$eval(tableFingerprintSelector, (tbody) => tbody.innerHTML).catch(() => null); + const wasFilterActive = await page.$eval('#reset-filters', (button) => !button.disabled).catch(() => false); + const oldTableFingerprint = await getTableFingerprint(); + await page.waitForSelector('#reset-filters', { visible: true }) .then(() => this.pressElement(page, '#reset-filters', true)) .catch(async () => { @@ -995,7 +1000,20 @@ module.exports.resetFilters = async (page) => { await this.pressElement(page, '#openFilterToggle', true); }); + /* + * The reload triggered by the reset starts asynchronously: the table displayed before the click is still there when no loading row is displayed + * yet. Wait for the table content to change (when some filter was active), then for the loading to be over + */ + if (wasFilterActive && oldTableFingerprint) { await page.waitForFunction( + (selector, fingerprint) => document.querySelector(selector)?.innerHTML !== fingerprint, + { timeout: 1500 }, + tableFingerprintSelector, + oldTableFingerprint, + ).catch(() => {}); + } + + await page.waitForFunction( () => document.querySelectorAll('table tbody tr.loading-row').length === 0, { timeout: 5000 }, );