a51da3f28ee7c5213118958920a8fe4b9dda5d4d
[catagits/Gitalist.git] / t / app-mech-rootpage.t
1 #!/usr/bin/env perl
2 use FindBin qw/$Bin/;
3 BEGIN { do "$FindBin::Bin/../script/env" or die $@ }
4 use lib "$Bin/lib";
5 use TestGitalist;
6 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();
7
8 MECH->get_ok('/');
9 {
10     my $nodeset = MECH->findnodes('/html/body//tr[@class="reposrow"]');
11     foreach my $row ($nodeset->get_nodelist) {
12         my $uri = $row->findnodes('.//a')->[0]->attr('href');
13         my ($repos_name) = $uri =~ m{^http://localhost/([\w\.]+)$};
14         ok $repos_name, "Repos name $repos_name";
15         like $row->findnodes('.//a')->[1]->as_text, qr{^[\w\s/;',\.]+$}, 'Have description'
16             unless $repos_name eq 'nodescription';
17         like $row->findnodes('.//td[@class="time-since"')->[0]->as_text, qr/^(never|\d\s+(years|months)\s+ago)$/,
18             'Last change looks ok';
19         my ($summary, $shortlog, $log, $tree) = $row->findnodes('.//td[@class="link"]/a')->get_nodelist;
20         like $summary->as_text, qr/summary/i, 'summary text ok';
21         is $summary->attr('href'), $uri, 'summary href correct';
22         like $shortlog->as_text, qr/shortlog/i, 'shortlog text ok';
23         is $shortlog->attr('href'), "$uri/shortlog", 'shortlog href ok';
24         like $log->as_text, qr/log/, 'log text ok';
25         is $log->attr('href'), "$uri/log", 'log href ok';
26         like $tree->as_text, qr/tree/, 'tree text ok';
27         TODO: {
28             local $TODO = 'Bork';
29             is $tree->attr('href'), "$uri/tree", 'tree href ok';
30         }
31     }
32 }
33
34 done_testing;