Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Wait for vite to serve before the titlebar, find, shortcuts and settings smokes navigate (#12501)

Daniel Handa07ae04cbb7
diff --git a/tests/studio/playwright_find_in_page.py b/tests/studio/playwright_find_in_page.py
index dd752ffe89c..42df3459fef 100644
--- a/tests/studio/playwright_find_in_page.py
+++ b/tests/studio/playwright_find_in_page.py
@@ -24,6 +24,7 @@ from _playwright_robust import ( # noqa: E402
chromium_launch_args,
start_vite,
stop_process,
+ wait_for_smoke_page,
)
PORT = int(os.environ.get("SMOKE_PORT", "5419"))
@@ -1107,6 +1108,7 @@ def main() -> int:
server = start_vite(PORT)
try:
+ wait_for_smoke_page(URL, "smoke-find-in-page-main.tsx", proc = server)
with sync_playwright() as pw:
for engine in ENGINES:
run_engine(pw, engine)
diff --git a/tests/studio/playwright_keyboard_shortcuts.py b/tests/studio/playwright_keyboard_shortcuts.py
index 18ebb98217f..335cc0e3bf1 100644
--- a/tests/studio/playwright_keyboard_shortcuts.py
+++ b/tests/studio/playwright_keyboard_shortcuts.py
@@ -28,6 +28,7 @@ from _playwright_robust import ( # noqa: E402
chromium_launch_args,
start_vite,
stop_process,
+ wait_for_smoke_page,
)
PORT = int(os.environ.get("SMOKE_PORT", "5407"))
@@ -663,6 +664,7 @@ def run_engine(pw, engine: str) -> None:
def main() -> int:
server = start_vite(PORT)
try:
+ wait_for_smoke_page(URL, "smoke-shortcuts-main.tsx", proc = server)
with sync_playwright() as pw:
for engine in ENGINES:
run_engine(pw, engine)
diff --git a/tests/studio/playwright_settings_tabs.py b/tests/studio/playwright_settings_tabs.py
index 2ba84dba308..7f45d1a11d0 100644
--- a/tests/studio/playwright_settings_tabs.py
+++ b/tests/studio/playwright_settings_tabs.py
@@ -27,6 +27,7 @@ from _playwright_robust import ( # noqa: E402
chromium_launch_args,
start_vite,
stop_process,
+ wait_for_smoke_page,
click_forced,
)
@@ -664,6 +665,7 @@ def main() -> int:
vite = start_vite(PORT)
try:
url = f"http://127.0.0.1:{PORT}/smoke-settings.html"
+ wait_for_smoke_page(url, "smoke-settings-main.tsx", proc = vite)
with sync_playwright() as pw:
launcher = getattr(pw, ENGINE)
kwargs: dict = {"headless": True}
diff --git a/tests/studio/playwright_titlebar_blur.py b/tests/studio/playwright_titlebar_blur.py
index 6e706bd8b96..445bfb8af75 100644
--- a/tests/studio/playwright_titlebar_blur.py
+++ b/tests/studio/playwright_titlebar_blur.py
@@ -17,7 +17,7 @@ from pathlib import Path
from playwright.sync_api import sync_playwright, expect
sys.path.insert(0, str(Path(__file__).resolve().parent))
-from _playwright_robust import chromium_launch_args, start_vite, stop_process
+from _playwright_robust import chromium_launch_args, start_vite, stop_process, wait_for_smoke_page
PORT = int(os.environ.get("SMOKE_PORT", "5491"))
URL = os.environ.get("SMOKE_URL", f"http://127.0.0.1:{PORT}/smoke-titlebar-blur.html")
@@ -234,6 +234,10 @@ def run():
if __name__ == "__main__":
server = None if os.environ.get("SMOKE_URL") else start_vite(PORT)
try:
+ if server is not None:
+ # start_vite returns as soon as npm is spawned; navigating before vite listens is a
+ # connection refused (#12475's run), so wait for the page that names this scene's entry.
+ wait_for_smoke_page(URL, "smoke-titlebar-blur-main.tsx", proc = server)
run()
finally:
if server is not None:
diff --git a/tests/studio/test_playwright_server_lifecycle.py b/tests/studio/test_playwright_server_lifecycle.py
index e683169084e..c8f02df3100 100644
--- a/tests/studio/test_playwright_server_lifecycle.py
+++ b/tests/studio/test_playwright_server_lifecycle.py
@@ -294,3 +294,37 @@ def test_an_external_smoke_base_url_is_still_honoured(harness, monkeypatch) -> N
finally:
monkeypatch.delenv("SMOKE_BASE_URL", raising = False)
importlib.reload(module)
+
+
+_READINESS_WAITS = frozenset({"wait_for_smoke_page", "wait_for_health"})
+
+
+def _calls(tree, names):
+ import ast
+ return [
+ node
+ for node in ast.walk(tree)
+ if isinstance(node, ast.Call)
+ and (getattr(node.func, "id", None) in names or getattr(node.func, "attr", None) in names)
+ ]
+
+
+def test_every_driver_that_starts_vite_waits_for_it_to_serve() -> None:
+ """start_vite returns once npm is spawned, not once vite listens. A driver that navigates
+ straight away races the dev server, and loses as a connection refused on a slow runner."""
+ import ast
+
+ here = Path(__file__).resolve().parent
+ unwaited = []
+ starters = 0
+ for path in sorted(here.glob("playwright_*.py")):
+ tree = ast.parse(path.read_text(encoding = "utf-8"))
+ if not _calls(tree, {"start_vite"}):
+ continue
+ starters += 1
+ if not _calls(tree, _READINESS_WAITS):
+ unwaited.append(path.name)
+ assert (
+ starters >= 5
+ ), "found almost no start_vite callers; the scan is not looking where they live"
+ assert not unwaited, f"these drivers start vite and never wait for it to serve: {unwaited}"