blob: 95015d597e1670bf42c0de0fcd981902b8c74be9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
"""Tests that page rendering respects the configured language consistently."""
from __future__ import annotations
import pytest
from starlette.testclient import TestClient
from ollama_web.app import create_app
from ollama_web.config import settings
from ollama_web.i18n import get_messages, t
@pytest.fixture
def reset_language():
"""Reset language to the initial value after each test."""
original = settings.language
yield
settings.language = original
if hasattr(get_messages, "cache_clear"):
get_messages.cache_clear()
def _render_index() -> str:
"""Render index.html and return the HTML body."""
app = create_app()
with TestClient(app) as client:
response = client.post("/api/auth/login", json={"pin": settings.pin})
assert response.status_code == 200
response = client.get("/")
return response.text
def test_english_language_consistency(reset_language):
"""When settings.language='en', all UI text including MCP must be English."""
settings.language = "en"
html = _render_index()
# HTML-side labels
assert 'lang="en"' in html
assert "MCP Settings" in html
assert "MCP Server Settings" in html
assert "+ Add server" in html
# Japanese labels must not appear anywhere
assert "MCP設定" not in html
assert "MCPサーバー設定" not in html
assert "+ サーバー追加" not in html
assert "セッション" not in html
assert "モデル:" not in html
def test_japanese_language_consistency(reset_language):
"""When settings.language='ja', all UI text including MCP must be Japanese."""
settings.language = "ja"
html = _render_index()
# HTML-side labels
assert 'lang="ja"' in html
assert "MCP設定" in html
assert "MCPサーバー設定" in html
assert "+ サーバー追加" in html
# English labels must not appear anywhere
assert "MCP Settings" not in html
assert "MCP Server Settings" not in html
assert "+ Add server" not in html
assert "Sessions" not in html
assert "Model:" not in html
def test_t_helper_respects_language_override():
"""The t() helper must return the requested language string."""
assert t("common.send", lang="en") == "Send"
assert t("common.send", lang="ja") == "送信"
assert t("mcp.server_settings", lang="en") == "MCP Server Settings"
assert t("mcp.server_settings", lang="ja") == "MCPサーバー設定"
|