Regenerated README and fixed tests for bootstrapped checkouts.
[catagits/Gitalist.git] / t / app-mech-rootpage.t
1 #!/usr/bin/env perl
2 use FindBin qw/$Bin/;
3 BEGIN {
4     my $env = "$FindBin::Bin/../script/env";
5     if (-r $env) {
6         do $env or die $@;
7     }
8 }
9
10 use lib "$Bin/lib";
11 use TestGitalist;
12 plan 'skip_all' => "One or more of the following modules aren't present: Test::WWW::Mechanize::Catalyst WWW::Mechanize::TreeBuilder HTML::TreeBuilder::XPath" unless MECH();
13
14 MECH->get_ok('/');
15 {
16     my $nodeset = MECH->findnodes('/html/body//tr[@class="reposrow"]');
17     foreach my $row ($nodeset->get_nodelist) {
18         my $uri = $row->findnodes('.//a')->[0]->attr('href');
19         my ($repos_name) = $uri =~ m{^http://localhost/([\w\.]+)$};
20         ok $repos_name, "Repos name $repos_name";
21         like $row->findnodes('.//a')->[1]->as_text, qr{^[\w\s/;',\.]+$}, 'Have description'
22             unless $repos_name eq 'nodescription';
23         like $row->findnodes('.//td[@class="time-since"')->[0]->as_text, qr/^(never|\d\s+(years|months)\s+ago)$/,
24             'Last change looks ok';
25         my ($summary, $shortlog, $log, $tree) = $row->findnodes('.//td[@class="link"]/a')->get_nodelist;
26         like $summary->as_text, qr/summary/i, 'summary text ok';
27         is $summary->attr('href'), $uri, 'summary href correct';
28         like $shortlog->as_text, qr/shortlog/i, 'shortlog text ok';
29         is $shortlog->attr('href'), "$uri/shortlog", 'shortlog href ok';
30         like $log->as_text, qr/log/, 'log text ok';
31         is $log->attr('href'), "$uri/log", 'log href ok';
32         like $tree->as_text, qr/tree/, 'tree text ok';
33         TODO: {
34             local $TODO = 'Bork';
35             is $tree->attr('href'), "$uri/tree", 'tree href ok';
36         }
37     }
38 }
39
40 done_testing;