main
py 79 lines 3.01 KB
Raw
1 import sys
2 from pathlib import Path
3
4
5 PROJECT_ROOT = Path(__file__).resolve().parents[1]
6 if str(PROJECT_ROOT) not in sys.path:
7 sys.path.insert(0, str(PROJECT_ROOT))
8
9
10
11 def test_websocket_harness_entrypoint_is_present_in_developer_settings_template():
12 dev_template_path = (
13 PROJECT_ROOT
14 / "webui"
15 / "components"
16 / "settings"
17 / "developer"
18 / "dev.html"
19 )
20 content = dev_template_path.read_text(encoding="utf-8")
21 assert "websocket-tester.html" in content
22 assert "websocket-event-console.html" in content
23 assert "!$store.settings.additional?.is_dockerized" in content
24
25
26 def test_websocket_harness_template_is_gated_by_runtime():
27 template_path = PROJECT_ROOT / "webui" / "components" / "settings" / "developer" / "websocket-tester.html"
28 content = template_path.read_text(encoding="utf-8")
29 assert "window.runtimeInfo?.isDevelopment" in content
30 assert "$store.root?.isDevelopment" not in content
31
32
33 def test_timezone_settings_section_is_present():
34 store_path = PROJECT_ROOT / "webui" / "components" / "settings" / "settings-store.js"
35 agent_settings_path = PROJECT_ROOT / "webui" / "components" / "settings" / "agent" / "agent-settings.html"
36 locale_path = PROJECT_ROOT / "webui" / "components" / "settings" / "agent" / "locale.html"
37
38 store = store_path.read_text(encoding="utf-8")
39 agent_settings = agent_settings_path.read_text(encoding="utf-8")
40 assert "section-locale" in store
41 assert "section-voice" in store
42 assert "settings/agent/locale.html" in agent_settings
43 assert store.index("section-models-summary") < store.index("section-locale")
44 assert store.index("section-locale") < store.index("section-agent-plugins")
45 assert agent_settings.index("section-models-summary") < agent_settings.index("section-locale")
46 assert agent_settings.index("section-locale") < agent_settings.index("section-agent-plugins")
47 assert agent_settings.rindex("section-locale") < agent_settings.rindex("section-agent-plugins")
48 locale = locale_path.read_text(encoding="utf-8")
49 assert "Automatic (browser)" in locale
50 assert "$store.settings.settings.timezone" in locale
51 assert "12-hour (AM/PM)" in locale
52 assert "24-hour" in locale
53 assert "$store.settings.settings.time_format" in locale
54
55
56 def test_settings_secret_fields_use_masked_text_inputs():
57 auth_template = (
58 PROJECT_ROOT
59 / "webui"
60 / "components"
61 / "settings"
62 / "external"
63 / "auth.html"
64 ).read_text(encoding="utf-8")
65 dev_template = (
66 PROJECT_ROOT
67 / "webui"
68 / "components"
69 / "settings"
70 / "developer"
71 / "dev.html"
72 ).read_text(encoding="utf-8")
73 settings_css = (PROJECT_ROOT / "webui" / "css" / "settings.css").read_text(encoding="utf-8")
74
75 settings_templates = "\n".join([auth_template, dev_template])
76
77 assert 'type="password"' not in settings_templates
78 assert 'class="masked-text-input"' in settings_templates
79 assert "-webkit-text-security: disc" in settings_css