Diff options
| -rwxr-xr-x | tests/t0101-index.sh | 65 |
1 file changed, 65 insertions, 0 deletions
diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index e227586..bf3de8c 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -148,6 +148,71 @@ test_expect_success 'the idle column shows the date the age file holds' ' test_grep "<td class=.col-idle.><time class=.age-years. datetime=.2005-04-05T10:00:00Z." tmp ' +# Fails unless the index of the config named first, asked for with the query +# given second, lists the sections, bracketed, and the repositories under +# them in the order the rest name. A section heading spans every column, +# which comes to five with the owner and links columns both on. +test_section_order() { + cgit_ok "$1" "$2" >tmp && + sed -n -e "s/.*<td colspan=.5. class=.reposection.>\(.*\)<\/td>.*/[\1]/p" \ + -e "s/.*class=.col-name sublevel-repo.><a href=[^>]*>\([^<]*\)<\/a>.*/\1/p" tmp >order && + shift 2 && + printf "%s\n" "$@" >expect && + test_cmp expect order +} + +# The age files order the alpha section apart from both its cgitrc order and +# its names. +test_expect_success 'set up repositories in two sections' ' + for name in z1 a2 a3 a1 + do + git init -q --bare "sections/$name.git" && + mkdir "sections/$name.git/info/web" || return 1 + done && + echo "2005-04-01 10:00:00 +0000" >sections/a2.git/info/web/last-modified && + echo "2005-04-05 10:00:00 +0000" >sections/a3.git/info/web/last-modified && + echo "2005-04-03 10:00:00 +0000" >sections/a1.git/info/web/last-modified && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-index-links=1" && + echo "section=zeta" && + echo "repo.url=z1" && + echo "repo.path=$PWD/sections/z1.git" && + echo "section=alpha" && + for name in a2 a3 a1 + do + echo "repo.url=$name" && + echo "repo.path=$PWD/sections/$name.git" || return 1 + done + } >sectionrc && + { + echo "section-sort=1" && + cat sectionrc + } >sectionsortrc && + { + echo "repository-sort=age" && + cat sectionsortrc + } >sectionagerc +' + +test_expect_success 'the index keeps the cgitrc order of sections' ' + test_section_order sectionrc "url=" "[zeta]" z1 "[alpha]" a2 a3 a1 +' + +test_expect_success 'section-sort orders the sections and their repositories' ' + test_section_order sectionsortrc "url=" "[alpha]" a1 a2 a3 "[zeta]" z1 && + test_section_order sectionagerc "url=" "[alpha]" a3 a1 a2 "[zeta]" z1 +' + +# Sorted by a column, the rows no longer run section by section. +test_expect_success 'an index sorted by a column drops the sections' ' + cgit_ok sectionrc "s=name" >tmp && + test_grep "class=.col-name toplevel-repo.><a href=./a1/.>a1</a>" tmp && + test_grep ! "reposection" tmp && + test_grep ! "sublevel-repo" tmp +' + # Only the heading of the column the index is sorted by tells a screen reader # so. Idle lists the latest change first, so it is ascending like the rest. test_expect_success 'the sorted column heading says which way it runs' ' |
