blob: b2ec8137a8e04bdfb5133c5dd60fcaf99b1c1d64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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 ">summary</a><a class=.button. href=./foo/log/.>log</a>" tmp &&
	grep "href=./foo/log/.>log</a><a class=.button. href=./foo/tree/.>tree<" 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 "<link rel=.stylesheet. href=./a.css.>" tmp &&
	grep "<link rel=.stylesheet. href=./b.css.>" tmp &&
	grep "<script src=" tmp >scripts &&
	test_line_count = 2 scripts &&
	grep "/a.js" scripts &&
	grep "/b.js" scripts
'

test_done