diff --git a/src/functional_tests/test_room_tray.py b/src/functional_tests/test_room_tray.py index 496755c..1058617 100644 --- a/src/functional_tests/test_room_tray.py +++ b/src/functional_tests/test_room_tray.py @@ -104,12 +104,29 @@ class TrayTest(FunctionalTest): tray = self.browser.find_element(By.ID, "id_tray") self.assertFalse(tray.is_displayed()) - # Clicking the closed btn adds a wobble class to the wrap + # Clicking the closed btn adds a wobble class to the wrap. + # Use a MutationObserver to capture the transient class change — in CI + # headless Firefox the 0.45s animation may complete before the first + # wait_for poll (0.5s), causing a false miss. + self.browser.execute_script(""" + window._trayWobbled = false; + var wrap = document.getElementById('id_tray_wrap'); + var obs = new MutationObserver(function(muts) { + muts.forEach(function(m) { + if (m.type === 'attributes' && m.attributeName === 'class') { + if (m.target.classList.contains('wobble')) { + window._trayWobbled = true; + obs.disconnect(); + } + } + }); + }); + obs.observe(wrap, {attributes: true, attributeFilter: ['class']}); + """) self.browser.find_element(By.ID, "id_tray_btn").click() self.wait_for( - lambda: self.assertIn( - "wobble", - self.browser.find_element(By.ID, "id_tray_wrap").get_attribute("class"), + lambda: self.assertTrue( + self.browser.execute_script("return window._trayWobbled;") ) ) # Tray still not visible — a click alone must not open it