generated from john/python-template
WIP theming
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
"""Tests for global UI theme registration."""
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
from fastapi import FastAPI
|
||||
|
||||
from transcription.ui import register_pages
|
||||
from transcription.ui.resources import read_css
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_page_registration_uses_vibescribe_theme(monkeypatch):
|
||||
"""Global UI registration loads the standalone VibeScribe theme in light mode."""
|
||||
registered_css: list[str] = []
|
||||
run_options: dict[str, object] = {}
|
||||
|
||||
monkeypatch.setattr("transcription.ui.ui.add_css", lambda css, **_kwargs: registered_css.append(css))
|
||||
monkeypatch.setattr("transcription.ui.register_upload_page", lambda: None)
|
||||
monkeypatch.setattr("transcription.ui.register_jobs_page", lambda: None)
|
||||
monkeypatch.setattr(
|
||||
"transcription.ui.ui.run_with",
|
||||
lambda _app, **options: run_options.update(options),
|
||||
)
|
||||
|
||||
register_pages(FastAPI())
|
||||
|
||||
theme_css = read_css("theme.css")
|
||||
assert registered_css == [theme_css]
|
||||
assert set(re.findall(r"#[0-9a-fA-F]{6}", theme_css)) == {
|
||||
"#1c2321",
|
||||
"#7d98a1",
|
||||
"#5e6572",
|
||||
"#a9b4c2",
|
||||
"#eef1ef",
|
||||
}
|
||||
assert "--q-primary" in theme_css
|
||||
assert run_options["dark"] is False
|
||||
Reference in New Issue
Block a user