long overdue fix to last pipeline push, where scroll position did not persist across sessions

This commit is contained in:
Disco DeDisco
2026-03-24 21:36:02 -04:00
parent 588358a20f
commit 2896efa8e0
2 changed files with 20 additions and 13 deletions

View File

@@ -154,16 +154,19 @@ class BillscrollPositionTest(FunctionalTest):
)
# 2. Force the element scrollable (CSS not served by StaticLiveServerTestCase),
# set position, and dispatch scroll event to trigger the debounced save.
# JS saves scrollTop + clientHeight (bottom-of-viewport); forced height is 150px.
# set position, dispatch scroll event, and capture the position value the
# JS listener will save — all in one synchronous script so the layout
# snapshot is identical to what the scroll handler sees.
scroll_top = 100
forced_height = 150
self.browser.execute_script("""
saved_pos = self.browser.execute_script("""
var el = arguments[0];
var remPx = parseFloat(getComputedStyle(document.documentElement).fontSize);
el.style.overflow = 'auto';
el.style.height = '150px';
el.scrollTop = arguments[1];
var pos = Math.round(el.scrollTop + el.clientHeight + remPx * 2.5);
el.dispatchEvent(new Event('scroll'));
return pos;
""", scroll_el, scroll_top)
# 3. Wait for debounce (800ms) + fetch to complete
@@ -180,11 +183,8 @@ class BillscrollPositionTest(FunctionalTest):
scroll_el = self.wait_for(
lambda: self.browser.find_element(By.ID, "id_drama_scroll")
)
buffer_px = self.browser.execute_script(
"return Math.round(parseFloat(getComputedStyle(document.documentElement).fontSize) * 2.5)"
)
restored = int(scroll_el.get_attribute("data-scroll-position"))
self.assertEqual(restored, scroll_top + forced_height + buffer_px)
self.assertEqual(restored, saved_pos)
class BillboardAppletsTest(FunctionalTest):