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