source: trunk/t/47_navbar_placement.t @ 969

Last change on this file since 969 was 969, checked in by kake, 15 years ago

Apply content_above_navbar_in_html content option to Recent Changes page as well; and add a CSS ID for the atom/RSS feeds paragraph.

File size: 6.1 KB
Line 
1use strict;
2use OpenGuides;
3use OpenGuides::Test;
4use Test::More;
5use Wiki::Toolkit::Setup::SQLite;
6
7eval { require DBD::SQLite; };
8if ( $@ ) {
9    plan skip_all => "DBD::SQLite not installed - no database to test with";
10    exit 0;
11}
12
13eval { require Test::HTML::Content; };
14if ( $@ ) {
15    plan skip_all => "Test::HTML::Content not installed";
16    exit 0;
17}
18
19plan tests => 12;
20
21# NB These tests don't actually test the placement - but they do test that
22# we get at least one navbar where appropriate.  Better tests would be better.
23
24my ( $config, $guide, $wiki, $cookie, $output );
25
26# Clear out the database from any previous runs.
27unlink "t/node.db";
28unlink <t/indexes/*>;
29Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
30
31# Make a guide.
32$config = OpenGuides::Test->make_basic_config;
33$guide = OpenGuides->new( config => $config );
34
35# Write a node.
36OpenGuides::Test->write_data(
37                              guide => $guide,
38                              node  => "Red Lion",
39                            );
40
41# Make sure navbar shows up on node display.
42$output = $guide->display_node(
43                                id => "Red Lion",
44                                return_output => 1,
45                              );
46$output =~ s/^Content-Type.*[\r\n]+//m;
47Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
48                             "navbar included on node display" );
49
50$config->content_above_navbar_in_html( 0 );
51$output = $guide->display_node(
52                                id => "Red Lion",
53                                return_output => 1,
54                              );
55$output =~ s/^Content-Type.*[\r\n]+//m;
56Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
57                         "...ditto if content_above_navbar_in_html set to 0" );
58
59$config->content_above_navbar_in_html( 1 );
60$output = $guide->display_node(
61                                id => "Red Lion",
62                                return_output => 1,
63                              );
64$output =~ s/^Content-Type.*[\r\n]+//m;
65Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
66                         "...ditto if content_above_navbar_in_html set to 1" );
67
68# And on home node, if it's switched on.
69$config = OpenGuides::Test->make_basic_config; # get a fresh config
70$guide = OpenGuides->new( config => $config ); # make sure the guide sees it
71$config->navbar_on_home_page( 1 );
72$output = $guide->display_node(
73                                id => $config->home_name,
74                                return_output => 1,
75                              );
76$output =~ s/^Content-Type.*[\r\n]+//m;
77Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
78         "navbar included on home node when navbar_on_home_page switched on" );
79
80$config->content_above_navbar_in_html( 0 );
81$output = $guide->display_node(
82                                id => $config->home_name,
83                                return_output => 1,
84                              );
85$output =~ s/^Content-Type.*[\r\n]+//m;
86Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
87                         "...ditto if content_above_navbar_in_html set to 0" );
88
89$config->content_above_navbar_in_html( 1 );
90$output = $guide->display_node(
91                                id => $config->home_name,
92                                return_output => 1,
93                              );
94$output =~ s/^Content-Type.*[\r\n]+//m;
95Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
96                         "...ditto if content_above_navbar_in_html set to 1" );
97
98# But not on home node, if it's switched off.
99$config = OpenGuides::Test->make_basic_config; # get a fresh config
100$guide = OpenGuides->new( config => $config ); # make sure the guide sees it
101$config->navbar_on_home_page( 0 );
102$output = $guide->display_node(
103                                id => $config->home_name,
104                                return_output => 1,
105                              );
106$output =~ s/^Content-Type.*[\r\n]+//m;
107Test::HTML::Content::no_tag( $output, "div", { id => "navbar" },
108      "navbar excluded from home node when navbar_on_home_page switched off" );
109
110$config->content_above_navbar_in_html( 0 );
111$output = $guide->display_node(
112                                id => $config->home_name,
113                                return_output => 1,
114                              );
115$output =~ s/^Content-Type.*[\r\n]+//m;
116Test::HTML::Content::no_tag( $output, "div", { id => "navbar" },
117                         "...ditto if content_above_navbar_in_html set to 0" );
118
119$config->content_above_navbar_in_html( 1 );
120$output = $guide->display_node(
121                                id => $config->home_name,
122                                return_output => 1,
123                              );
124$output =~ s/^Content-Type.*[\r\n]+//m;
125Test::HTML::Content::no_tag( $output, "div", { id => "navbar" },
126                         "...ditto if content_above_navbar_in_html set to 1" );
127
128# Make sure navbar appears on recent changes.
129$config = OpenGuides::Test->make_basic_config; # get a fresh config
130$guide = OpenGuides->new( config => $config ); # make sure the guide sees it
131$output = $guide->display_recent_changes(
132                                          return_output => 1,
133                                        );
134$output =~ s/^Content-Type.*[\r\n]+//m;
135Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
136                             "navbar appears on recent changes" );
137
138$config->content_above_navbar_in_html( 0 );
139$output = $guide->display_recent_changes(
140                                          return_output => 1,
141                                        );
142$output =~ s/^Content-Type.*[\r\n]+//m;
143Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
144                         "...ditto if content_above_navbar_in_html set to 0" );
145
146$config->content_above_navbar_in_html( 1 );
147$output = $guide->display_recent_changes(
148                                          return_output => 1,
149                                        );
150$output =~ s/^Content-Type.*[\r\n]+//m;
151Test::HTML::Content::tag_ok( $output, "div", { id => "navbar" },
152                         "...ditto if content_above_navbar_in_html set to 1" );
153
Note: See TracBrowser for help on using the repository browser.