1 # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
21 use Test::More tests => 35;
24 AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
28 $page = update_page('Test', 'Can edit page by default');
29 test_page($page, 'Can edit page by default');
31 '//a[@class="comment local"][@href="http://localhost/wiki.pl/Comments_on_Test"][text()="Comments on Test"]',
32 '//a[@class="edit"][@href="http://localhost/wiki.pl?action=edit;id=Test"][text()="Edit this page"]');
33 $page = update_page('Comments_on_Test', 'Can edit comment by default');
34 test_page($page, 'Can edit comment by default');
36 '//a[@class="original local"][@href="http://localhost/wiki.pl/Test"][text()="Test"]',
37 '//a[@class="edit"][@href="http://localhost/wiki.pl?action=edit;id=Comments_on_Test"][text()="Edit this page"]',
38 '//textarea[@name="aftertext"]');
40 AppendStringToFile($ConfigFile, "\$EditAllowed = 0;\n");
42 $page = update_page('Test', 'Cannot edit page with edit allowed eq 0');
43 test_page($page, 'Can edit page by default');
45 '//a[@class="password"][@href="http://localhost/wiki.pl?action=password"][text()="This page is read-only"]');
46 $page = update_page('Comments_on_Test', 'Cannot edit comments with edit allowed eq 0');
47 test_page($page, 'Can edit comment by default');
49 '//a[@class="password"][@href="http://localhost/wiki.pl?action=password"][text()="This page is read-only"]');
50 negative_xpath_test($page, '//textarea[@name="aftertext"]');
52 AppendStringToFile($ConfigFile, "\$EditAllowed = 2;\n");
54 $page = update_page('Test', 'Cannot edit page with edit allowed eq 2');
55 test_page($page, 'Can edit page by default');
57 '//a[@class="password"][@href="http://localhost/wiki.pl?action=password"][text()="This page is read-only"]');
58 $page = update_page('Comments_on_Test', 'Can edit comments with edit allowed eq 2');
59 test_page($page, 'Can edit comments with edit allowed eq 2');
61 '//a[@class="original local"][@href="http://localhost/wiki.pl/Test"][text()="Test"]',
62 '//a[@class="edit"][@href="http://localhost/wiki.pl?action=edit;id=Comments_on_Test"][text()="Edit this page"]',
63 '//textarea[@name="aftertext"]');
65 AppendStringToFile($ConfigFile, "\$EditAllowed = 3;\n");
67 $page = update_page('Test', 'Cannot edit page with edit allowed = 3');
68 test_page($page, 'Can edit page by default');
70 '//a[@class="password"][@href="http://localhost/wiki.pl?action=password"][text()="This page is read-only"]');
71 $page = update_page('Comments_on_Test', 'Can edit comments with edit allowed eq 3');
72 test_page($page, 'Can edit comments with edit allowed eq 2');
74 '//a[@class="original local"][@href="http://localhost/wiki.pl/Test"][text()="Test"]',
75 '//a[@class="password"][@href="http://localhost/wiki.pl?action=password"][text()="This page is read-only"]',
76 '//textarea[@name="aftertext"]');
77 $page = update_page('Comments_on_Test', '', '', '', '', 'aftertext=Can%20add%20comments%20with%20edit%20allowed%20eq%203');
78 test_page($page, 'Can add comments with edit allowed eq 3');
82 AppendStringToFile($ConfigFile, "\$EditAllowed = 1;\n");
84 get_page('title=Yadda', 'aftertext=This%20is%20my%20comment.', 'username=Alex');
85 test_page(get_page('Yadda'), 'This is my comment.');
87 get_page('title=Comments_on_Yadda', 'aftertext=This%20is%20my%20comment.', 'username=Alex');
88 test_page(get_page('Comments_on_Yadda'), 'This is my comment\.', '-- Alex');
89 test_page(get_page('action=rc raw=1'), 'title: Comments on Yadda',
90 'description: This is my comment.', 'generator: Alex');
92 get_page('title=Comments_on_Yadda', 'aftertext=This%20is%20another%20comment.',
93 'username=Alex', 'homepage=http%3a%2f%2fwww%2eoddmuse%2eorg%2f');
94 xpath_test(get_page('Comments_on_Yadda'),
95 '//p[contains(text(),"This is my comment.")]',
96 '//a[@class="url http outside"][@href="http://www.oddmuse.org/"][text()="Alex"]');
98 my $textarea = '//textarea[@name="aftertext"][@id="aftertext"]';
99 xpath_test(get_page('Comments_on_Yadda'), $textarea);
100 get_page('action=pagelock set=1 id=Comments_on_Yadda pwd=foo');
101 negative_xpath_test(get_page('Comments_on_Yadda'), $textarea);