test_clicking_pick_sea_btn_opens_sea_overlay: poll click+sea-open assertion to absorb DOM-vs-script race on slow CI — TDD
The PICK SEA btn parses into the DOM before the inline `<script>` at the bottom of _sea_overlay.html binds `openSea` to it; on fast hosts the gap is invisible but the two-browser CI stage was clicking ahead of the binding and the handler never fired. Wrapping the click + sea-open class assertion in wait_for retries the click until the handler has bound. Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,12 +132,21 @@ class PickSeaAsyncTransitionTest(ChannelsFunctionalTest):
|
|||||||
self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sky_btn"))
|
self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sky_btn"))
|
||||||
|
|
||||||
self._confirm_sky()
|
self._confirm_sky()
|
||||||
pick_sea = self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sea_btn"))
|
self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sea_btn"))
|
||||||
self.browser.execute_script("arguments[0].click()", pick_sea)
|
|
||||||
|
|
||||||
sea_overlay = self.wait_for(
|
# On slow CI, the PICK SEA btn parses into the DOM before the inline
|
||||||
lambda: self.browser.find_element(By.ID, "id_sea_overlay")
|
# `<script>` at the bottom of _sea_overlay.html has bound `openSea` to
|
||||||
)
|
# it; a one-shot click can land before the handler exists. Retry click
|
||||||
|
# + assert together via wait_for so the race resolves naturally.
|
||||||
|
def _click_and_assert_sea_open():
|
||||||
|
btn = self.browser.find_element(By.ID, "id_pick_sea_btn")
|
||||||
|
self.browser.execute_script("arguments[0].click()", btn)
|
||||||
|
self.assertTrue(self.browser.execute_script(
|
||||||
|
"return document.documentElement.classList.contains('sea-open')"
|
||||||
|
))
|
||||||
|
self.wait_for(_click_and_assert_sea_open)
|
||||||
|
|
||||||
|
sea_overlay = self.browser.find_element(By.ID, "id_sea_overlay")
|
||||||
self.assertTrue(sea_overlay.is_displayed())
|
self.assertTrue(sea_overlay.is_displayed())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user