#!/bin/sh
# The index page, one row per repository in cgitrc. The checks look for each
# fixture repository and its description, for the escaping a name with a
# plus or a space needs in a link, and for the absence of the tree and log
# links that belong to a repository's own pages unless enable-index-links
# asks for them. The page's head also stands in for every page's, with one
# link per css and js entry.
test_description='Check content on index page'
. ./setup.sh
test_expect_success 'generate index page' 'cgit_url "" >tmp'
test_expect_success 'find foo repo' 'grep ">foo" tmp'
test_expect_success 'find foo description' 'grep "\[no description\]" tmp'
test_expect_success 'find bar repo' 'grep ">bar" tmp'
test_expect_success 'find bar description' 'grep "the bar repo" tmp'
test_expect_success 'find foo+bar repo' 'grep ">foo+bar<" tmp'
test_expect_success 'verify foo+bar links' 'test $(grep -o "href=./foo%2Bbar/." tmp | wc -l) = 2'
test_expect_success 'verify "with%20space" links' 'test $(grep -o "href=./with%20space/." tmp | wc -l) = 2'
test_expect_success 'no tree-link' '! grep "foo/tree" tmp'
test_expect_success 'no log-link' '! grep "foo/log" tmp'
test_expect_success 'index links lead to the summary, log and tree' '
cgitrc_copy links-cgitrc enable-index-links=1 &&
cgit_rc links-cgitrc "url=" >tmp &&
grep ">summarylog" tmp &&
grep "href=./foo/log/.>logtree<" tmp
'
test_expect_success 'each css and js entry gets a link of its own' '
cgitrc_copy headrc css=/a.css css=/b.css js=/a.js js= js=/b.js &&
cgit_rc headrc "url=" >tmp &&
grep "" tmp &&
grep "" tmp &&
grep "