Fix app-mech-rootpage.t test.
Dan Brook [Sat, 26 Feb 2011 15:44:57 +0000 (15:44 +0000)]
This was broken as of the Foxtons redesign as I forgot to update the
tests. With the odd tweak here and there it passes again. If I ever
find the tuits I'd like to have this test for the rest of the actions.

root/fragment/collectionofrepositories.tt2
t/app-mech-rootpage.t

index 2bd62c5..b053ea8 100755 (executable)
@@ -1,7 +1,7 @@
 <tbody>
 [% FOR p IN repositories %]
        [%- repos_link = c.uri_for_action('/repository/summary', [p.name]) -%]
-<tr [% "class='invert'" IF loop.count % 2 %]>
+<tr class="repository[% " invert" IF loop.count % 2 %]">
     <td>[% loop.count %]</td>
        <td><a href="[% repos_link %]/summary"><strong>[% p.name %]</strong></a></td>
     <td class="description"><div title="[% p.description %]">[% abridged_description(p.description) IF p.description != "Unnamed repository; edit this file to name it for gitweb." %]</div></td>
index 0bba4f4..a2b2e46 100644 (file)
@@ -13,27 +13,23 @@ plan 'skip_all' => "One or more of the following modules aren't present: Test::W
 
 MECH->get_ok('/');
 {
-    my $nodeset = MECH->findnodes('/html/body//tr[@class="reposrow"]');
+    my $nodeset = MECH->findnodes('/html/body//tr[@class="repository"]');
     foreach my $row ($nodeset->get_nodelist) {
         my $uri = $row->findnodes('.//a')->[0]->attr('href');
-        my ($repos_name) = $uri =~ m{^http://localhost/([\w\.]+)$};
+        my ($repos_name) = $uri =~ m{^http://localhost/([\w\.]+)};
         ok $repos_name, "Repos name $repos_name";
         like $row->findnodes('.//a')->[1]->as_text, qr{^[\w\s/;',\.]+$}, 'Have description'
             unless $repos_name eq 'nodescription';
-        like $row->findnodes('.//td[@class="time-since"')->[0]->as_text, qr/^(never|\d\s+(years|months)\s+ago)$/,
+        like $row->findnodes('.//td[@class="time-since"')->[0]->as_text, qr/^(never|\d+\s+(years|months)\s+ago)$/,
             'Last change looks ok';
-        my ($summary, $shortlog, $log, $tree) = $row->findnodes('.//td[@class="link"]/a')->get_nodelist;
-        like $summary->as_text, qr/summary/i, 'summary text ok';
-        is $summary->attr('href'), $uri, 'summary href correct';
-        like $shortlog->as_text, qr/shortlog/i, 'shortlog text ok';
+        my ($shortlog, $log, $tree) = $row->findnodes('.//td[@class="action-list"]/a')->get_nodelist;
+        $uri =~ s{/summary}{};
+        like $shortlog->as_text, qr/short log/i, 'shortlog text ok';
         is $shortlog->attr('href'), "$uri/shortlog", 'shortlog href ok';
         like $log->as_text, qr/log/, 'log text ok';
         is $log->attr('href'), "$uri/log", 'log href ok';
         like $tree->as_text, qr/tree/, 'tree text ok';
-        TODO: {
-            local $TODO = 'Bork';
-            is $tree->attr('href'), "$uri/tree", 'tree href ok';
-        }
+        is $tree->attr('href'), "$uri/HEAD/tree", 'tree href ok';
     }
 }