diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Add stable markup hooks for site themes
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0005-markup.sh99
-rwxr-xr-xtests/t0113-tag.sh16
-rwxr-xr-xtests/t0201-filters.sh4
-rwxr-xr-xtests/t0206-trailers.sh8
-rwxr-xr-xtests/t0208-mailmap.sh2
-rwxr-xr-xtests/t0506-link-trailers.sh2
6 files changed, 115 insertions, 16 deletions
diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh
new file mode 100755
index 0000000..2a8d572
--- /dev/null
+++ b/tests/t0005-markup.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+# Guards the hooks the README promises a site stylesheet or script, so a
+# rename in the markup fails here instead of in someone's theme. Each check
+# names the page it renders and the attribute or element it expects.
+
+test_description='Check the markup hooks a theme relies on'
+. ./setup.sh
+
+test_expect_success 'set up a repository with a file that has an extension' '
+ mkrepo repos/hooks 2 &&
+ (
+ cd repos/hooks &&
+ mkdir dir &&
+ echo "int x;" >dir/hello.c &&
+ git add dir &&
+ git commit -m sources
+ ) &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "enable-blame=1" &&
+ echo "max-stats=year" &&
+ echo "readme=:file-1" &&
+ echo "repo.url=hooks" &&
+ echo "repo.path=$PWD/repos/hooks/.git"
+ } >hooksrc
+'
+
+hooks() { CGIT_CONFIG="$PWD/hooksrc" QUERY_STRING="url=$1" cgit; }
+
+test_expect_success 'the root names the page and the repository' '
+ hooks "" >tmp &&
+ grep "<div id=.cgit. data-page=.repolist.>" tmp &&
+ hooks "hooks/log/" >tmp &&
+ grep "<div id=.cgit. data-page=.log. data-repo=.hooks.>" tmp
+'
+
+test_expect_success 'the landmarks and the search form are in place' '
+ grep "<header id=.header.>" tmp &&
+ grep "<nav class=.tabs. aria-label=.Pages.>" tmp &&
+ grep "<form class=.search. role=.search." tmp &&
+ grep "<main class=.content.>" tmp &&
+ grep "<footer class=.footer.>" tmp
+'
+
+test_expect_success 'the listings name themselves, their sections and their rows' '
+ grep "<table class=.list log. aria-label=.Commits.>" tmp &&
+ grep "<tbody class=.log.>" tmp &&
+ grep "<tr class=.commit.>" tmp &&
+ grep "class=.active. aria-current=.page." tmp &&
+ grep "<th class=.left. scope=.col.>" tmp &&
+ hooks "" >tmp &&
+ grep "<table class=.list repolist. aria-label=.Repositories.>" tmp &&
+ grep "<tbody class=.repos.>" tmp &&
+ grep "<tr class=.repo.>" tmp &&
+ hooks "hooks/" >tmp &&
+ grep "<table class=.list summary. aria-label=.Summary.>" tmp &&
+ grep "<tbody class=.branches.>" tmp &&
+ grep "<tr class=.branch.>" tmp &&
+ hooks "hooks/tree/" >tmp &&
+ grep "<table class=.list tree. aria-label=.Files.>" tmp &&
+ grep "<tr class=.dir.>" tmp &&
+ grep "<tr class=.blob.>" tmp &&
+ hooks "hooks/tree/dir/" >tmp &&
+ grep "class=.ls-blob ext-c." tmp
+'
+
+test_expect_success 'the diff pages wrap each file and label their controls' '
+ hooks "hooks/commit/" >tmp &&
+ grep "<table class=.commit-info.>" tmp &&
+ grep "<th scope=.row.>author</th>" tmp &&
+ grep "<div class=.file. data-path=.dir/hello.c.>" tmp &&
+ grep "<label for=.diff-context.>" tmp &&
+ grep "<select id=.diff-context. name=.context.>" tmp &&
+ grep "<form method=.get. aria-label=.Diff options.>" tmp &&
+ hooks "hooks/diff/&ss=1" >tmp &&
+ grep "<tbody class=.file. data-path=.dir/hello.c.>" tmp &&
+ hooks "hooks/stats/" >tmp &&
+ grep "<label for=.stats-authors.>" tmp
+'
+
+test_expect_success 'the blob, blame and about pages open with their own containers' '
+ hooks "hooks/tree/dir/hello.c" >tmp &&
+ grep "<div class=.blob-header.>" tmp &&
+ grep "<a id=.n1." tmp &&
+ hooks "hooks/blame/dir/hello.c" >tmp &&
+ grep "<div class=.blob-header.>" tmp &&
+ hooks "hooks/about/" >tmp &&
+ grep "<div id=.about.>" tmp
+'
+
+test_expect_success 'the stylesheet and the script name only the current hooks' '
+ ! grep "_dark\|#summary\|ul.pager\|td:empty" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.css" &&
+ grep "window.cgit.updateAges" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js" &&
+ grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js"
+'
+
+test_done
diff --git a/tests/t0113-tag.sh b/tests/t0113-tag.sh
index 90763bd..2c9dc25 100755
--- a/tests/t0113-tag.sh
+++ b/tests/t0113-tag.sh
@@ -22,15 +22,15 @@ two lines." v1.0 &&
test_expect_success 'generate foo/tag/?h=v1.0' 'cgit_url "foo/tag/&h=v1.0" >tmp'
test_expect_success 'find the name, date and tagger rows' '
- grep "<tr><th>tag name</th><td>v1.0 (<span class=.oid.>[0-9a-f]*</span>)</td></tr>" tmp &&
- grep "<tr><th>tag date</th><td><time datetime=" tmp &&
- grep "<tr><th>tagged by</th><td>C O Mitter &lt;committer@example.com&gt;</td></tr>" tmp
+ grep "<tr><th scope=.row.>tag name</th><td>v1.0 (<span class=.oid.>[0-9a-f]*</span>)</td></tr>" tmp &&
+ grep "<tr><th scope=.row.>tag date</th><td><time datetime=" tmp &&
+ grep "<tr><th scope=.row.>tagged by</th><td>C O Mitter &lt;committer@example.com&gt;</td></tr>" tmp
'
test_expect_success 'the object row names the full commit id' '
commit=$(git -C repos/foo rev-parse v1.0^{commit}) &&
- grep "<tr><th>tagged object</th><td class=.oid.><a href=./foo/commit/?h=v1.0&amp;id=$commit.>commit $commit</a></td></tr>" tmp &&
- grep "<tr><th>download</th><td class=.oid.>" tmp
+ grep "<tr><th scope=.row.>tagged object</th><td class=.oid.><a href=./foo/commit/?h=v1.0&amp;id=$commit.>commit $commit</a></td></tr>" tmp &&
+ grep "<tr><th scope=.row.>download</th><td class=.oid.>" tmp
'
test_expect_success 'the message follows with no blank line before the body' '
@@ -40,9 +40,9 @@ test_expect_success 'the message follows with no blank line before the body' '
test_expect_success 'a lightweight tag gets the shorter table' '
cgit_url "foo/tag/&h=light" >tmp &&
- grep "<tr><th>tag name</th><td>light</td></tr>" tmp &&
- grep "<tr><th>tagged object</th><td class=.oid.><a" tmp &&
- ! grep "<th>tagged by</th>" tmp
+ grep "<tr><th scope=.row.>tag name</th><td>light</td></tr>" tmp &&
+ grep "<tr><th scope=.row.>tagged object</th><td class=.oid.><a" tmp &&
+ ! grep "<th scope=.row.>tagged by</th>" tmp
'
test_done
diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh
index 444932a..11fa5f8 100755
--- a/tests/t0201-filters.sh
+++ b/tests/t0201-filters.sh
@@ -30,7 +30,7 @@ do
"
test_expect_success "check whether the $prefix about filter works" '
- grep "<div id='"'"'summary'"'"'>a+b HELLO$" tmp
+ grep "<div id='"'"'about'"'"'>a+b HELLO$" tmp
'
test_expect_success "generate filter-$prefix/commit/" "
@@ -61,7 +61,7 @@ do
test_expect_success "the $prefix about filter output stays inside its div" "
cgit_url 'filter-$prefix/about/' >tmp &&
- grep \"<div id='summary'>a+b HELLO\" tmp
+ grep \"<div id='about'>a+b HELLO\" tmp
"
done
diff --git a/tests/t0206-trailers.sh b/tests/t0206-trailers.sh
index e8e615c..5e10dfc 100755
--- a/tests/t0206-trailers.sh
+++ b/tests/t0206-trailers.sh
@@ -55,15 +55,15 @@ test_expect_success 'the body ends where the block begins' '
'
test_expect_success 'a value reaches the trailer filter with its key and page' '
- grep "<tr><th>Fixes</th><td>Fixes commit 1234567 (.PLAIN COMMIT.)</td></tr>" tmp
+ grep "<tr><th scope=.row.>Fixes</th><td>Fixes commit 1234567 (.PLAIN COMMIT.)</td></tr>" tmp
'
test_expect_success 'a run of one key, whatever its case, collapses into one row' '
- grep "<tr><th>Signed-off-by</th><td><mapped@example.com> commit MAPPED NAME &LT;MAPPED@EXAMPLE.COM&GT;<br><committer@example.com> commit C O MITTER &LT;COMMITTER@EXAMPLE.COM&GT;</td></tr>" tmp
+ grep "<tr><th scope=.row.>Signed-off-by</th><td><mapped@example.com> commit MAPPED NAME &LT;MAPPED@EXAMPLE.COM&GT;<br><committer@example.com> commit C O MITTER &LT;COMMITTER@EXAMPLE.COM&GT;</td></tr>" tmp
'
test_expect_success 'an ident follows the mailmap and keeps what trails the address' '
- grep "<tr><th>Acked-by</th><td><some@example.com> commit SOME ONE &LT;SOME@EXAMPLE.COM&GT; (maintainer)</td></tr>" tmp
+ grep "<tr><th scope=.row.>Acked-by</th><td><some@example.com> commit SOME ONE &LT;SOME@EXAMPLE.COM&GT; (maintainer)</td></tr>" tmp
'
test_expect_success 'a key with no value is printed as written' '
@@ -75,7 +75,7 @@ test_expect_success 'a line git could not split gets a row of its own' '
'
test_expect_success 'the escaped value is what the filter sees' '
- grep "<tr><th>Link</th><td>Link commit HTTPS://EXAMPLE.COM/?A=1&AMP;B=2</td></tr>" tmp
+ grep "<tr><th scope=.row.>Link</th><td>Link commit HTTPS://EXAMPLE.COM/?A=1&AMP;B=2</td></tr>" tmp
'
test_expect_success 'a message with no block gets no table' '
diff --git a/tests/t0208-mailmap.sh b/tests/t0208-mailmap.sh
index ca08de0..86f6d50 100755
--- a/tests/t0208-mailmap.sh
+++ b/tests/t0208-mailmap.sh
@@ -44,7 +44,7 @@ test_expect_success 'the log shows the mapped author' '
test_expect_success 'the commit page shows the mapped author and address' '
first=$(git -C repos/mapped rev-parse HEAD~1) &&
cgit_url "mapped/commit/&id=$first" >tmp &&
- grep "<th>author</th><td>New Name &lt;new@example.com&gt;</td>" tmp &&
+ grep "<th scope=.row.>author</th><td>New Name &lt;new@example.com&gt;</td>" tmp &&
! grep "old@example.com" tmp
'
diff --git a/tests/t0506-link-trailers.sh b/tests/t0506-link-trailers.sh
index f6fedf2..5736c5a 100755
--- a/tests/t0506-link-trailers.sh
+++ b/tests/t0506-link-trailers.sh
@@ -55,7 +55,7 @@ test_expect_success 'point cgit at it through the trailer filter' '
test_expect_success CGIT_LUA 'the Fixes object name links to its commit page' '
cgit_url "linky/commit/" >tmp &&
- grep "<th>Fixes</th><td><a href=....id=1234567.>1234567</a> (.earlier.)</td>" tmp
+ grep "<th scope=.row.>Fixes</th><td><a href=....id=1234567.>1234567</a> (.earlier.)</td>" tmp
'
test_expect_success CGIT_LUA 'the bare URL links to itself' '