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.

Settings contract tests: follow MonitorLink into the API page's access group (#15500)

Daniel Han8a1edb406ab0
diff --git a/tests/studio/test_settings_compact_overflow_contract.py b/tests/studio/test_settings_compact_overflow_contract.py
index 36de6453e60..add2f90b724 100644
--- a/tests/studio/test_settings_compact_overflow_contract.py
+++ b/tests/studio/test_settings_compact_overflow_contract.py
@@ -52,8 +52,19 @@ def test_settings_monitor_link_can_shrink():
assert "flex w-full min-w-0 items-center gap-3" in source
assert '<span className="truncate text-sm font-semibold text-foreground">' in source
assert '<span className="min-h-[1lh] truncate text-xs text-muted-foreground">' in source
- # The monitor has a section heading of its own, not a card dropped among other sections.
- assert '<SettingsSection title={t("settings.resources.liveMonitor.apiTitle")}>' in source
+ # The monitor has a section of its own, not a card dropped among other sections.
+ assert re.search(
+ r'<SettingsSection\s+title=\{t\("settings\.resources\.liveMonitor\.apiTitle"\)\}', source
+ ), "MonitorLink no longer renders its own titled SettingsSection"
+ # Where a page hides that heading (the API tab, #15467), the link must sit inside a titled section there.
+ for tsx in SETTINGS.rglob("*.tsx"):
+ page = tsx.read_text(encoding = "utf-8")
+ for use in re.finditer(r"<MonitorLink\b[^>]*\bhideHeading\b", page):
+ before = page[: use.start()]
+ opened = before.rfind("<SettingsSection")
+ assert (
+ opened != -1 and "</SettingsSection>" not in before[opened:]
+ ), f"{tsx.name}: MonitorLink hides its heading outside a titled SettingsSection"
def test_remote_access_card_can_shrink():
diff --git a/tests/studio/test_usage_examples_model_source_contract.py b/tests/studio/test_usage_examples_model_source_contract.py
index 0e28f9d6fb4..6cfd4505a3d 100644
--- a/tests/studio/test_usage_examples_model_source_contract.py
+++ b/tests/studio/test_usage_examples_model_source_contract.py
@@ -153,11 +153,18 @@ def test_api_monitor_renders_lifecycle_rows():
def test_auto_switch_section_sits_below_the_monitor_link():
- # #14455 moved the usage examples up, under the key form (api-settings-tab.test.ts pins that);
- # the auto-switch section still follows the monitor link.
+ # #14455 moved the usage examples up, under the key form (api-settings-tab.test.ts pins that), and
+ # #15467 put them behind ApiExamplesPanel's tab row; the auto-switch section still follows the
+ # monitor link, whatever props the link takes.
tab = API_KEYS_TAB_TSX.read_text(encoding = "utf-8")
- assert tab.index("<UsageExamples") < tab.index("<MonitorLink />")
- assert tab.index("<MonitorLink />") < tab.index("<ModelAutoSwitchSection />")
+
+ def at(pattern):
+ match = re.search(pattern, tab)
+ assert match, f"{pattern} not found in {API_KEYS_TAB_TSX.name}"
+ return match.start()
+
+ assert at(r"<(?:UsageExamples|ApiExamplesPanel)\b") < at(r"<MonitorLink\b")
+ assert at(r"<MonitorLink\b") < at(r"<ModelAutoSwitchSection\b")
AUTO_SWITCH_TSX = SETTINGS / "components/model-auto-switch-section.tsx"