Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hold the summary tests to a working page
The summary requests passed on any answer short of a crash, and the
checks for no tags and no commit 45 read a page another test wrote.
The log checks also matched the branch row, which shows the newest
subject too. Two checks under a title about the clone rows matched the
vcs-git links in the head instead, and the dots in the [...] count
matched any three characters.
Diffstat (limited to 'tests/t0102-summary.sh')
| -rwxr-xr-x | tests/t0102-summary.sh | 68 |
1 file changed, 44 insertions, 24 deletions
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh index c623202..019c8e6 100755 --- a/tests/t0102-summary.sh +++ b/tests/t0102-summary.sh @@ -8,22 +8,36 @@ test_description='Check content on summary page' . ./setup.sh -test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp' -test_expect_success 'find commit 1' 'grep "commit 1" tmp' -test_expect_success 'find commit 5' 'grep "commit 5" tmp' +# The branch row shows the newest subject as well, so the log rows are looked +# for in the log's own section. +test_expect_success 'generate foo summary' ' + cgit_ok_url "foo" >tmp && + sed -n "/<tbody class=.log.>/,/<\/tbody>/p" tmp >log +' +test_expect_success 'find commit 1' 'test_grep ">commit 1<" log' +test_expect_success 'find commit 5' 'test_grep ">commit 5<" log' test_expect_success 'find branch master' 'grep "<tr class=.branch.><td><a[^>]*>master</a>" tmp' -test_expect_success 'no tags' '! grep "Tag</th>" tmp' +test_expect_success 'a repository without tags draws no tag table' ' + cgit_ok_url "foo" >tmp && + test_grep "<tbody class=.branches.>" tmp && + test_grep ! "Tag</th>" tmp +' test_expect_success 'clone-url expanded correctly' ' grep "git://example.org/foo.git" tmp ' -test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp' +test_expect_success 'generate bar summary' ' + cgit_ok_url "bar" >tmp && + sed -n "/<tbody class=.log.>/,/<\/tbody>/p" tmp >log +' test_expect_success 'repo description reaches the meta tag' ' grep "<meta name=.description. content=.the bar repo.>" tmp ' -test_expect_success 'no commit 45' '! grep "commit 45" tmp' -test_expect_success 'find commit 46' 'grep "commit 46" tmp' -test_expect_success 'find commit 50' 'grep "commit 50" tmp' +test_expect_success 'the summary log stops at summary-log commits' ' + test_grep ">commit 46<" log && + test_grep ! ">commit 45<" log +' +test_expect_success 'find commit 50' 'test_grep ">commit 50<" log' # A clone url is shown as written, but a browser cannot follow the ssh, scp # or git forms, so those rows link to the first http url in the list, or to @@ -34,10 +48,16 @@ test_expect_success 'a git clone url row falls back to the page url' ' test_expect_success 'an scp clone url row links to the http url' ' cgitrc_repo clonerc foo "repo.clone-url=git@example.org:foo https://example.org/foo" && - cgit_rc clonerc "url=foo" >tmp && - grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo</a>" tmp && - grep "vcs-git. href=.https://example.org/foo." tmp && - ! grep "vcs-git. href=.git@" tmp + cgit_ok clonerc "url=foo" >tmp && + grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo</a>" tmp +' + +# A link element's href has to hold a URI, so the scp form is left out of +# the head while the http url gets a link there. +test_expect_success 'the head links only the clone urls with a scheme' ' + cgit_ok clonerc "url=foo" >tmp && + test_grep "<link rel=.vcs-git. href=.https://example.org/foo. title=.foo Git repository.>" tmp && + test_grep ! "<link rel=.vcs-git. href=.git@" tmp ' # A repository can turn the global clone-url off with an empty one of its own. @@ -58,13 +78,13 @@ test_expect_success 'an empty clone url draws no clone heading' ' echo "repo.url=cloned" && echo "repo.path=$PWD/repos/empty.git" } >emptyrc && - cgit_rc emptyrc "url=foo" >tmp && - grep "commit 1" tmp && - ! grep "Clone</th>" tmp && - cgit_rc emptyrc "url=empty" >tmp && - grep "Repository seems to be empty" tmp && - ! grep "Clone</th>" tmp && - cgit_rc emptyrc "url=cloned" >tmp && + cgit_ok emptyrc "url=foo" >tmp && + test_grep ">commit 1<" tmp && + test_grep ! "Clone</th>" tmp && + cgit_ok emptyrc "url=empty" >tmp && + test_grep "Repository seems to be empty" tmp && + test_grep ! "Clone</th>" tmp && + cgit_ok emptyrc "url=cloned" >tmp && grep "Clone</th>" tmp && grep "https://example.org/cloned</a>" tmp ' @@ -92,7 +112,7 @@ row_widths() { # Fails unless every row of the list table at the url is as many columns wide # as the second argument says. A third names a config other than colsrc. test_widths() { - cgit_rc "${3:-colsrc}" "url=$1" >tmp && + cgit_ok "${3:-colsrc}" "url=$1" >tmp && row_widths tmp | sort -u >actual && echo "$2" >expect && test_cmp expect actual @@ -126,10 +146,10 @@ test_expect_success 'set up a repo cut short in every section' ' echo "repo.enable-log-filecount=1" && echo "repo.enable-log-linecount=1" } >colsrc && - cgit_rc colsrc "url=none" >tmp && + cgit_ok colsrc "url=none" >tmp && grep "<tbody class=.tags.>" tmp && grep "<tbody class=.clone.>" tmp && - test $(grep -c ">\[...\]</a>" tmp) = 3 + test $(grep -c ">\[\.\.\.\]</a>" tmp) = 3 ' test_expect_success 'a summary without counts fills four columns' 'test_widths none 4' @@ -149,13 +169,13 @@ test_expect_success 'a page of tags fills four columns' 'test_widths both/refs/t # The tag table's second column holds the downloads, or with no snapshot # format the object each tag points at, and is headed for what it holds. test_expect_success 'the tag table heads its second column for what it holds' ' - cgit_rc colsrc "url=none/refs/" >tmp && + cgit_ok colsrc "url=none/refs/" >tmp && grep "<th class=.left. scope=.col.>Tag</th><th class=.left. scope=.col.>Commit</th>" tmp && { echo "snapshots=tar" && cat colsrc } >snaprc && - cgit_rc snaprc "url=none/refs/" >tmp && + cgit_ok snaprc "url=none/refs/" >tmp && grep "<th class=.left. scope=.col.>Tag</th><th class=.left. scope=.col.>Download</th>" tmp ' |
