#!/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 link' 'grep "/foo+bar/" tmp'
test_expect_success 'verify "with%20space" link' 'grep "/with%20space/" tmp'
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' '
echo "enable-index-links=1" >links-cgitrc &&
sed "s/^cache-size=.*/cache-size=0/" cgitrc >>links-cgitrc &&
CGIT_CONFIG="$PWD/links-cgitrc" QUERY_STRING="url=" cgit >tmp &&
grep ">summarylog" tmp &&
grep "href=./foo/log/.>logtree<" tmp
'
test_expect_success 'each css and js entry gets a link of its own' '
{
echo "css=/a.css" &&
echo "css=/b.css" &&
echo "js=/a.js" &&
echo "js=" &&
echo "js=/b.js"
} >headrc &&
sed "s/^cache-size=.*/cache-size=0/" cgitrc >>headrc &&
CGIT_CONFIG="$PWD/headrc" QUERY_STRING="url=" cgit >tmp &&
grep "" tmp &&
grep "" tmp &&
grep "