feat: add persistent dashboard dark mode
CI/CD Dev / dev (push) Failing after 44s

This commit is contained in:
2026-08-15 00:53:58 +03:30
parent 675def5fe6
commit 32e7b6b749
8 changed files with 1423 additions and 1293 deletions
+16 -1
View File
@@ -72,7 +72,7 @@ func TestDashboardRendersFullTemplPage(t *testing.T) {
NewHandler(service).ServeHTTP(response, request)
body := response.Body.String()
for _, expected := range []string{"<!doctype html>", "DARANO", "1,234", "abc123", "htmx.org@2.0.10", "class=\"mark\" src=\"/favicon.ico\"", "#F5F5F5", "#DFF1F1", "#BBD5DA", "#FF0000"} {
for _, expected := range []string{"<!doctype html>", "DARANO", "1,234", "abc123", "htmx.org@2.0.10", "src=\"/theme.js\"", "data-theme-toggle", "html[data-theme=\"dark\"]", "class=\"mark\" src=\"/favicon.ico\"", "#F5F5F5", "#DFF1F1", "#BBD5DA", "#FF0000"} {
if !strings.Contains(body, expected) {
t.Fatalf("response did not contain %q", expected)
}
@@ -183,6 +183,21 @@ func TestFaviconIsServedFromEmbeddedBrandAsset(t *testing.T) {
}
}
func TestThemeScriptIsServedFromEmbeddedAsset(t *testing.T) {
request := httptest.NewRequest(http.MethodGet, "/theme.js", nil)
response := httptest.NewRecorder()
NewHandler(&explorerStub{}).ServeHTTP(response, request)
body := response.Body.String()
if response.Code != http.StatusOK || !strings.Contains(body, "localStorage") || !strings.Contains(body, "prefers-color-scheme") {
t.Fatalf("unexpected theme script response: status=%d body=%s", response.Code, body)
}
if !strings.Contains(response.Header().Get("Content-Type"), "javascript") {
t.Fatalf("unexpected theme script content type: %s", response.Header().Get("Content-Type"))
}
}
func TestTransactionHTMXRequestRendersOnlyExplorerContent(t *testing.T) {
service := &explorerStub{transaction: []ledger.Journal{{
ID: "journal-1", EffectKind: "withdrawal",