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.

Tests: the titlebar smoke treats Vite outdated pre-bundle 504 as a reload (#16130)

Daniel Hanfebcd3e88793
diff --git a/tests/studio/_playwright_robust.py b/tests/studio/_playwright_robust.py
index a97db916c52..3f116da7a50 100644
--- a/tests/studio/_playwright_robust.py
+++ b/tests/studio/_playwright_robust.py
@@ -464,6 +464,12 @@ def is_benign_console_error(msg: str) -> bool:
return any(p in msg for p in BENIGN_CONSOLE_ERROR_PATTERNS)
+def is_vite_outdated_dep(response: Any) -> bool:
+ """Vite answers 504 "Outdated Optimize Dep" for a pre-bundle it just replaced, then reloads the page,
+ so it is not a missing asset. Its other 504, "Optimize Deps Processing Error", is a real failure."""
+ return response.status == 504 and response.status_text == "Outdated Optimize Dep"
+
+
def echo_browser_errors(page: Any, info: Callable[[str], None]) -> list[str]:
"""Prints browser errors live and returns the uncaught ones, so a failure names its real cause."""
thrown: list[str] = []
diff --git a/tests/studio/playwright_titlebar_blur.py b/tests/studio/playwright_titlebar_blur.py
index 0f9b44ed24b..91e758a79b6 100644
--- a/tests/studio/playwright_titlebar_blur.py
+++ b/tests/studio/playwright_titlebar_blur.py
@@ -11,7 +11,13 @@ 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, wait_for_smoke_page
+from _playwright_robust import (
+ chromium_launch_args,
+ is_vite_outdated_dep,
+ 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")
@@ -60,6 +66,7 @@ def run():
lambda response: errors.append(f"{response.status}: {response.url}")
if response.status >= 400
and response.request.resource_type in ("script", "stylesheet", "font")
+ and not is_vite_outdated_dep(response)
else None,
)
page.goto(URL)
diff --git a/tests/studio/test_vite_outdated_dep.py b/tests/studio/test_vite_outdated_dep.py
new file mode 100644
index 00000000000..773c14d3bb0
--- /dev/null
+++ b/tests/studio/test_vite_outdated_dep.py
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+"""Only Vite's outdated pre-bundle 504 is a reload signal; every other failed asset still fails a smoke."""
+
+from __future__ import annotations
+
+import ast
+import sys
+from pathlib import Path
+from types import SimpleNamespace
+
+import pytest
+
+HERE = Path(__file__).resolve().parent
+sys.path.insert(0, str(HERE))
+
+from _playwright_robust import is_vite_outdated_dep # noqa: E402
+
+VITE_DIST = HERE.parents[1] / "studio" / "frontend" / "node_modules" / "vite" / "dist" / "node"
+
+
+ ("status", "status_text", "expected"),
+ [
+ (504, "Outdated Optimize Dep", True),
+ (504, "Optimize Deps Processing Error", False),
+ (504, "Gateway Timeout", False),
+ (404, "Not Found", False),
+ (500, "Internal Server Error", False),
+ (200, "OK", False),
+ ],
+)
+def test_only_the_outdated_pre_bundle_answer_is_a_reload(status, status_text, expected):
+ response = SimpleNamespace(status = status, status_text = status_text)
+ assert is_vite_outdated_dep(response) is expected
+
+
+def test_the_titlebar_smoke_still_fails_on_other_asset_errors():
+ tree = ast.parse((HERE / "playwright_titlebar_blur.py").read_text(encoding = "utf-8"))
+ conditions = [
+ node
+ for node in ast.walk(tree)
+ if isinstance(node, ast.BoolOp)
+ and any(
+ isinstance(v, ast.Compare)
+ and isinstance(v.left, ast.Attribute)
+ and v.left.attr == "status"
+ and isinstance(v.ops[0], ast.GtE)
+ and getattr(v.comparators[0], "value", None) == 400
+ for v in node.values
+ )
+ ]
+ assert len(conditions) == 1, "the asset response guard moved; re-point this test at it"
+ exempt = [
+ v
+ for v in conditions[0].values
+ if isinstance(v, ast.UnaryOp)
+ and isinstance(v.op, ast.Not)
+ and isinstance(v.operand, ast.Call)
+ and getattr(v.operand.func, "id", None) == "is_vite_outdated_dep"
+ ]
+ # One narrow exemption joined with `and`, so a 404 or a processing-error 504 is still recorded.
+ assert isinstance(conditions[0].op, ast.And)
+ assert len(exempt) == 1
+
+
[email protected](not VITE_DIST.is_dir(), reason = "frontend dependencies are not installed")
+def test_vite_still_names_the_outdated_answer_this_way():
+ sources = "".join(p.read_text(encoding = "utf-8") for p in VITE_DIST.rglob("*.js"))
+ assert 'res.statusMessage = "Outdated Optimize Dep"' in sources