fix: update stale test assertions — version check, remoteId routing
This commit is contained in:
@@ -1231,7 +1231,7 @@ def test_instance_info_returns_200(client):
|
|||||||
|
|
||||||
|
|
||||||
def test_instance_info_returns_name_and_version(client, tmp_path, monkeypatch):
|
def test_instance_info_returns_name_and_version(client, tmp_path, monkeypatch):
|
||||||
"""GET /api/instance-info returns name='test-host' and version='0.1.0' when hostname is mocked."""
|
"""GET /api/instance-info returns name='test-host' and a non-empty version string when hostname is mocked."""
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import muxplex.settings as settings_mod
|
import muxplex.settings as settings_mod
|
||||||
@@ -1243,7 +1243,7 @@ def test_instance_info_returns_name_and_version(client, tmp_path, monkeypatch):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
data = response.json()
|
data = response.json()
|
||||||
assert data["name"] == "test-host"
|
assert data["name"] == "test-host"
|
||||||
assert data["version"] == "0.1.0"
|
assert "version" in data and isinstance(data["version"], str) and data["version"]
|
||||||
|
|
||||||
|
|
||||||
def test_instance_info_uses_explicit_device_name(client, tmp_path, monkeypatch):
|
def test_instance_info_uses_explicit_device_name(client, tmp_path, monkeypatch):
|
||||||
@@ -1260,7 +1260,7 @@ def test_instance_info_uses_explicit_device_name(client, tmp_path, monkeypatch):
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
data = response.json()
|
data = response.json()
|
||||||
assert data["name"] == "My Workstation"
|
assert data["name"] == "My Workstation"
|
||||||
assert data["version"] == "0.1.0"
|
assert "version" in data and isinstance(data["version"], str) and data["version"]
|
||||||
|
|
||||||
|
|
||||||
def test_instance_info_no_auth_required(tmp_path, monkeypatch):
|
def test_instance_info_no_auth_required(tmp_path, monkeypatch):
|
||||||
|
|||||||
@@ -2759,12 +2759,12 @@ def test_update_favicon_badge_filters_through_visible_sessions() -> None:
|
|||||||
# ─── Task 11: Frontend — Change Session Key Format to `device_id:name` ────────
|
# ─── Task 11: Frontend — Change Session Key Format to `device_id:name` ────────
|
||||||
|
|
||||||
|
|
||||||
def test_build_tile_html_prefers_device_id_for_data_remote_id() -> None:
|
def test_build_tile_html_uses_remote_id_for_data_remote_id() -> None:
|
||||||
"""buildTileHTML must use session.deviceId (falling back to session.remoteId) for data-remote-id.
|
"""buildTileHTML must use session.remoteId (not session.deviceId) for data-remote-id.
|
||||||
|
|
||||||
The backend now sends deviceId (device_id string) alongside remoteId on every session.
|
v0.4.1 hotfix changed this from deviceId to remoteId because deviceId is non-null for
|
||||||
The tile's data-remote-id must prefer deviceId so the click handler passes the correct
|
local sessions, which caused them to route through federation endpoints and 404.
|
||||||
device_id to openSession(), enabling federation API calls with the new device_id format.
|
remoteId is null for local sessions, so only remote sessions get routed via federation.
|
||||||
"""
|
"""
|
||||||
match = re.search(
|
match = re.search(
|
||||||
r"function buildTileHTML\s*\(.*?\)\s*\{(.*?)(?=\nfunction |\n// |\n/\*\*)",
|
r"function buildTileHTML\s*\(.*?\)\s*\{(.*?)(?=\nfunction |\n// |\n/\*\*)",
|
||||||
@@ -2773,17 +2773,23 @@ def test_build_tile_html_prefers_device_id_for_data_remote_id() -> None:
|
|||||||
)
|
)
|
||||||
assert match, "buildTileHTML function not found"
|
assert match, "buildTileHTML function not found"
|
||||||
body = match.group(1)
|
body = match.group(1)
|
||||||
assert "session.deviceId" in body, (
|
assert "session.remoteId" in body, (
|
||||||
"buildTileHTML must use session.deviceId for data-remote-id attribute "
|
"buildTileHTML must use session.remoteId for data-remote-id attribute — "
|
||||||
"(with fallback to session.remoteId for backward compatibility with old servers)"
|
"deviceId is intentionally NOT used because it is non-null for local sessions, "
|
||||||
|
"which would incorrectly route them through federation endpoints"
|
||||||
|
)
|
||||||
|
assert "session.deviceId" not in body, (
|
||||||
|
"buildTileHTML must NOT use session.deviceId for data-remote-id — "
|
||||||
|
"deviceId is non-null for local sessions and causes federation 404s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_build_sidebar_html_prefers_device_id_for_data_remote_id() -> None:
|
def test_build_sidebar_html_uses_remote_id_for_data_remote_id() -> None:
|
||||||
"""buildSidebarHTML must use session.deviceId (falling back to session.remoteId) for data-remote-id.
|
"""buildSidebarHTML must use session.remoteId (not session.deviceId) for data-remote-id.
|
||||||
|
|
||||||
The sidebar click handler reads data-remote-id and passes it to openSession().
|
v0.4.1 hotfix changed this from deviceId to remoteId because deviceId is non-null for
|
||||||
Must prefer deviceId so federation API calls use the new device_id:name format.
|
local sessions, which caused them to route through federation endpoints and 404.
|
||||||
|
remoteId is null for local sessions, so only remote sessions get routed via federation.
|
||||||
"""
|
"""
|
||||||
match = re.search(
|
match = re.search(
|
||||||
r"function buildSidebarHTML\s*\(.*?\)\s*\{(.*?)(?=\nfunction |\n// |\n/\*\*)",
|
r"function buildSidebarHTML\s*\(.*?\)\s*\{(.*?)(?=\nfunction |\n// |\n/\*\*)",
|
||||||
@@ -2792,9 +2798,14 @@ def test_build_sidebar_html_prefers_device_id_for_data_remote_id() -> None:
|
|||||||
)
|
)
|
||||||
assert match, "buildSidebarHTML function not found"
|
assert match, "buildSidebarHTML function not found"
|
||||||
body = match.group(1)
|
body = match.group(1)
|
||||||
assert "session.deviceId" in body, (
|
assert "session.remoteId" in body, (
|
||||||
"buildSidebarHTML must use session.deviceId for data-remote-id attribute "
|
"buildSidebarHTML must use session.remoteId for data-remote-id attribute — "
|
||||||
"(with fallback to session.remoteId for backward compatibility with old servers)"
|
"deviceId is intentionally NOT used because it is non-null for local sessions, "
|
||||||
|
"which would incorrectly route them through federation endpoints"
|
||||||
|
)
|
||||||
|
assert "session.deviceId" not in body, (
|
||||||
|
"buildSidebarHTML must NOT use session.deviceId for data-remote-id — "
|
||||||
|
"deviceId is non-null for local sessions and causes federation 404s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user