more headless patches to address pipeline clog; 'two-browsers' may not have been doing anything before
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -38,17 +38,10 @@ def wait(fn):
|
|||||||
class FunctionalTest(StaticLiveServerTestCase):
|
class FunctionalTest(StaticLiveServerTestCase):
|
||||||
# Helper methods
|
# Helper methods
|
||||||
def _make_browser(self, width=1366, height=900):
|
def _make_browser(self, width=1366, height=900):
|
||||||
"""Create a Firefox instance sized to width×height.
|
"""Create a Firefox instance sized to width×height."""
|
||||||
In headless CI, pass --width/--height as binary args so the CSS
|
|
||||||
media query (orientation: landscape/portrait) is correct from the
|
|
||||||
first paint — set_window_size() alone is unreliable in headless mode.
|
|
||||||
"""
|
|
||||||
options = webdriver.FirefoxOptions()
|
options = webdriver.FirefoxOptions()
|
||||||
headless = os.environ.get("HEADLESS")
|
if os.environ.get("HEADLESS"):
|
||||||
if headless:
|
|
||||||
options.add_argument("--headless")
|
options.add_argument("--headless")
|
||||||
options.add_argument(f"--width={width}")
|
|
||||||
options.add_argument(f"--height={height}")
|
|
||||||
browser = webdriver.Firefox(options=options)
|
browser = webdriver.Firefox(options=options)
|
||||||
browser.set_window_size(width, height)
|
browser.set_window_size(width, height)
|
||||||
return browser
|
return browser
|
||||||
|
|||||||
@@ -41,11 +41,17 @@ class TrayTest(FunctionalTest):
|
|||||||
Applet.objects.get_or_create(slug="new-note", defaults={"name": "New Note"})
|
Applet.objects.get_or_create(slug="new-note", defaults={"name": "New Note"})
|
||||||
|
|
||||||
def _switch_to_landscape(self):
|
def _switch_to_landscape(self):
|
||||||
"""Recreate the browser at landscape dimensions (900×500).
|
"""Recreate the browser at landscape dimensions (900×500) and wait
|
||||||
Needed in headless CI where set_window_size() alone doesn't
|
until window.innerWidth > window.innerHeight confirms the CSS
|
||||||
update the CSS orientation media query reliably."""
|
orientation media query will fire correctly."""
|
||||||
self.browser.quit()
|
self.browser.quit()
|
||||||
self.browser = self._make_browser(900, 500)
|
self.browser = self._make_browser(900, 500)
|
||||||
|
self.browser.get('about:blank')
|
||||||
|
self.wait_for(lambda: self.assertTrue(
|
||||||
|
self.browser.execute_script(
|
||||||
|
'return window.innerWidth > window.innerHeight'
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
def _simulate_drag(self, btn, offset_x):
|
def _simulate_drag(self, btn, offset_x):
|
||||||
"""Dispatch JS pointer events directly — more reliable than GeckoDriver drag."""
|
"""Dispatch JS pointer events directly — more reliable than GeckoDriver drag."""
|
||||||
|
|||||||
Reference in New Issue
Block a user