Files
odysseus/tests/test_background_chat_completion_ui_static.py
T
Léo 1323fab0bd refactor(tests): read the whole cascade instead of style.css alone
static/style.css no longer holds every rule. 79 rules for the document,
gallery and editor panels now live in static/css/, yet 27 browser tests still
built their synthetic page with a single <link> to style.css, and 51 more read
that one file as though it were the whole cascade. Those tests kept passing
while covering less: a rule that moved became invisible to the assertion that
was meant to pin it.

Python readers now call tests.helpers.stylesheets.app_css(), and synthetic
pages are built from stylesheet_link_tags() so they load exactly what
index.html loads, in the same order. The helper already existed; this moves
the remaining callers onto it.

test_portal_dropdown_z_js parametrised over a file list including style.css to
assert an absence. Checking a negative against one file of a split stylesheet
is how a moved rule escapes, so the CSS case now checks the concatenation.

Two guards keep it from coming back: one fails on any test reading
static/style.css directly, the other on any synthetic page linking it alone.
Both name the helper to use.

No production code changes. Suite is unchanged at 6 pre-existing failures.
2026-09-29 17:05:29 +02:00

51 lines
2.3 KiB
Python

from pathlib import Path
from tests.helpers.stylesheets import app_css
ROOT = Path(__file__).resolve().parents[1]
CHAT = (ROOT / "static/js/chat.js").read_text()
SESSIONS = (ROOT / "static/js/sessions.js").read_text()
CSS = app_css()
def test_queued_prompts_are_persisted_per_session_and_restored_on_return():
assert "odysseus-queued-agent-requests-v1" in CHAT
assert "function _persistQueuedRequests()" in CHAT
assert "function _restoreQueuedRequestsForCurrentSession()" in CHAT
assert "_restoreQueuedRequestsForCurrentSession();" in CHAT
assert "_drainQueuedAgentRequests();" in CHAT
def test_background_completion_survives_rerender_and_hidden_selected_chat():
assert "odysseus-completed-chat-sessions-v1" in SESSIONS
assert "_persistCompletedSessions();" in SESSIONS
assert "document.visibilityState === 'visible'" in SESSIONS
assert "markStreamComplete(streamSessionId, { force: true })" in CHAT
assert "active.wasAway = true" in CHAT
def test_sidebar_has_clear_working_and_done_states():
assert "session-run-state" in SESSIONS
assert "Agent finished while you were away" in SESSIONS
assert ".session-run-state.is-working" in CSS
assert ".session-run-state.is-done" in CSS
assert ".session-star.notify::after" in CSS
assert "content: '\\2713'" in CSS
assert ".session-star.notify {\n animation: none;" in CSS
assert "spinnerModule.createWhirlpool(12)" in SESSIONS
assert "session-run-whirlpool" in CSS
assert "state.textContent = 'Working'" not in SESSIONS
def test_every_registered_stream_marks_sidebar_working_immediately():
registration = CHAT[CHAT.index("_activeStreams.set(streamSessionId") : CHAT.index("_syncForegroundStreamGlobals();", CHAT.index("_activeStreams.set(streamSessionId"))]
assert "sessionModule.markStreaming(streamSessionId)" in registration
assert ".session-star.provider-logo.processing svg" in CSS
assert ".session-star.provider-logo.processing svg {\n animation: none;" in CSS
def test_selected_chat_that_finished_while_away_notifies():
done = CHAT[CHAT.index("const _completedWhileAway") : CHAT.index("// Force-close thinking", CHAT.index("const _completedWhileAway"))]
assert "markStreamComplete(streamSessionId, { force: true })" in done
assert "_notifyStreamComplete(streamSessionId, streamQuery)" in done