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/t0005-markup.sh')
-rwxr-xr-xtests/t0005-markup.sh99
1 file changed, 99 insertions, 0 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