Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Test that every copy of the background matches
Diffstat (limited to 'tests/t0005-markup.sh')
-rwxr-xr-xtests/t0005-markup.sh16
1 file changed, 16 insertions, 0 deletions
diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh
index 5d802a7..740a4f8 100755
--- a/tests/t0005-markup.sh
+++ b/tests/t0005-markup.sh
@@ -104,6 +104,22 @@ test_expect_success 'the stylesheet and the script name only the current hooks'
grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js"
'
+# The background is set as --bg, again on html.cgit-standalone for the canvas
+# around div#cgit, and in the theme-color tags that colour the browser's own
+# bar. None of the three can read the others, so they are compared here.
+test_expect_success 'the page background is the same everywhere it is set' '
+ css="$TEST_OUTPUT_DIRECTORY/../assets/cgit.css" &&
+ sed -n "s/^ --bg: *light-dark(\(#[0-9a-f]*\), \(#[0-9a-f]*\));\$/\1 \2/p" "$css" >expect &&
+ test_line_count = 1 expect &&
+ sed -n "/^html.cgit-standalone {\$/,/^}/s/^ background: light-dark(\(#[0-9a-f]*\), \(#[0-9a-f]*\));\$/\1 \2/p" "$css" >actual &&
+ test_cmp expect actual &&
+ hooks "hooks/" >tmp &&
+ light=$(sed -n "s/.*theme-color. media=.(prefers-color-scheme: light). content=.\(#[0-9a-f]*\).*/\1/p" tmp) &&
+ dark=$(sed -n "s/.*theme-color. media=.(prefers-color-scheme: dark). content=.\(#[0-9a-f]*\).*/\1/p" tmp) &&
+ echo "$light $dark" >actual &&
+ test_cmp expect actual
+'
+
# The rest of the hooks need a tag, a symlink, a submodule, a trailer, a lone
# carriage return, clone urls, an empty repository and a second page of
# repositories, so they get a commit and a config of their own after the checks