wiki.pl: Port some fixes from upstream
[Orgmuse.git] / t / sidebar.t
blob60a81bf8cce82a988a1eb5279f13380db51845b2
1 #!/usr/bin/env perl
2 # Copyright (C) 2006, 2007 Alex Schroeder <alex@emacswiki.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 require 't/test.pl';
18 package OddMuse;
19 use Test::More tests => 6;
21 clear_pages();
23 add_module('sidebar.pl');
25 test_page(update_page($SidebarName, 'mu'), '<div class="sidebar"><p>mu</p></div>');
26 test_page(get_page('HomePage'), '<div class="sidebar"><p>mu</p></div>');
28 #FIXME: Due to the recent refactoring of the Table of Contents module, the
29 #Sidebar module is now known **not** to work as expected with that module.
30 #This would appear to be an unavoidable consequence of that refactoring... The
31 #Sidebar module, as currently implemented, **cannot** be made to work with the
32 #Table of Contents module. As such, we disable all prior tests against the
33 #Table of Contents module. It's hardly ideal. (But then, what is?)
35 # with toc
37 # add_module('toc.pl');
38 # add_module('usemod.pl');
40 # AppendStringToFile($ConfigFile, "\$TocAutomatic = 0;\n");
42 # update_page($SidebarName, "bla\n\n"
43 # . "== mu ==\n\n"
44 # . "bla");
46 # test_page(update_page('test', "bla\n"
47 # . "<toc>\n"
48 # . "murks\n"
49 # . "==two=\n"
50 # . "bla\n"
51 # . "===three==\n"
52 # . "bla\n"
53 # . "=one=\n"),
54 # quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">two</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">one</a></li></ol>}),
55 # quotemeta('<h2>mu</h2>'),
56 # quotemeta(qq{<h2 id="${TocAnchorPrefix}1">two</h2>}),
57 # quotemeta(qq{<h2 id="${TocAnchorPrefix}3">one</h2>}),
58 # quotemeta('bla </p><div class="toc"><h2>Contents</h2><ol><li><a '),
59 # quotemeta('one</a></li></ol></div><p>murks'));
61 # update_page($SidebarName, "<toc>");
62 # test_page(update_page('test', "bla\n"
63 # . "murks\n"
64 # . "==two=\n"
65 # . "bla\n"
66 # . "===three==\n"
67 # . "bla\n"
68 # . "=one=\n"),
69 # quotemeta(qq{<ol><li><a href="#${TocAnchorPrefix}1">two</a><ol><li><a href="#${TocAnchorPrefix}2">three</a></li></ol></li><li><a href="#${TocAnchorPrefix}3">one</a></li></ol>}),
70 # quotemeta(qq{<h2 id="${TocAnchorPrefix}1">two</h2>}),
71 # quotemeta(qq{<h2 id="${TocAnchorPrefix}3">one</h2>}),
72 # quotemeta('<div class="content browse"><div class="sidebar"><div class="toc"><h2>Contents</h2><ol><li><a '),
73 # quotemeta('one</a></li></ol></div></div><p>'));
75 # remove_rule(\&TocRule);
76 # remove_rule(\&UsemodRule);
78 # with forms
80 add_module('forms.pl');
82 # Markup the sidebar page prior to locking the sidebar page. This should ensure
83 # that forms on that page are not interpreted.
84 test_page(update_page($SidebarName, '<form><h1>mu</h1></form>'),
85 '<div class="sidebar"><p>&lt;form&gt;&lt;h1&gt;mu&lt;/h1&gt;&lt;/form&gt;</p></div>');
87 # Lock the sidebar page, mark it up again, and ensure that forms on that page
88 # are now interpreted.
89 xpath_test(get_page("action=pagelock id=$SidebarName set=1 pwd=foo"),
90 '//p/text()[string()="Lock for "]/following-sibling::a[@href="http://localhost/wiki.pl/SideBar"][@class="local"][text()="SideBar"]/following-sibling::text()[string()=" created."]');
91 test_page(get_page("action=browse id=$SidebarName cache=0"), #update_page($SidebarName, '<form><h1>mu</h1></form>'),
92 '<div class="sidebar"><form><h1>mu</h1></form></div>');
93 # While rendering the SideBar as part of the HomePage, it should still
94 # be considered "locked", and therefore the form should render
95 # correctly.
96 test_page(get_page('HomePage'),
97 '<div class="sidebar"><form><h1>mu</h1></form></div>');