123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- require './t/test.pl';
- package OddMuse;
- use utf8;
- use Test::More tests => 52;
- AppendStringToFile($ConfigFile, "\$CommentsPrefix = 'Comments on ';\n");
- add_module('mail.pl');
- Init();
- require DB_File;
- tie %h, "DB_File", $MailFile;
- $h{'alex@gnu.org'} = 'Unregelmässige_Spieler';
- $h{'Unregelmässige_Spieler'} = 'alex@gnu.org';
- untie %h;
- test_page(get_page('action=migrate-subscriptions pwd=foo'),
- 'Migrated 2 rows');
- test_page(get_page('action=migrate-subscriptions pwd=foo'),
- 'migration not necessary');
- test_page(get_page('action=subscriptionlist pwd=foo raw=1'),
- 'alex@gnu.org Unregelmässige_Spieler',
- 'Unregelmässige_Spieler alex@gnu.org');
- test_page(get_page('title=Comments_on_%e2%98%85 aftertext=test username=Alex '
- . 'mail=berta@example.com notify=1'),
- 'Set-Cookie:.*mail%251eberta%40example.com');
- test_page(get_page('action=subscriptionlist pwd=foo raw=1'),
- 'Comments_on_★ berta@example.com',
- 'berta@example.com Comments_on_★');
- $page = get_page('Comments_on_Foo');
- xpath_test($page,
- '//label[@for="mail"][contains(text(), "Email")]',
- '//input[@name="mail"]',
- '//input[@type="checkbox"][@name="notify"][@value="1"]');
- test_page(get_page('title=Comments_on_Foo aftertext=test username=Alex '
- . 'mail=alex@example.com notify=1'),
- 'Set-Cookie:.*mail%251ealex%40example.com');
- get_page('title=Comments_on_Bar aftertext=test username=Alex '
- . 'mail=alex@example.com notify=1');
- get_page('title=Quux text=test username=Alex '
- . 'mail=alex@example.com notify=1');
- get_page('action=browse id=Comment_on_Baz username=Alex '
- . 'mail=alex@example.com notify=1');
- $page = get_page('action=admin');
- xpath_test($page, '//a[@class="subscriptions"][@href="http://localhost/wiki.pl?action=subscriptions"][text()="Your mail subscriptions"]');
- test_page_negative($page, 'All mail subscriptions');
- $page = get_page('action=admin pwd=foo');
- test_page($page, 'Your mail subscriptions');
- xpath_test($page, '//a[@class="subscriptionlist"][@href="http://localhost/wiki.pl?action=subscriptionlist"][text()="All mail subscriptions"]');
- xpath_test(get_page('action=subscriptions'),
- '//label[@for="mail"][text()="Email: "]',
- '//input[@type="text"][@name="mail"]');
- $page = get_page('action=subscriptions mail=alex@example.com');
- negative_xpath_test($page,
- '//label[@for="mail"]',
- '//input[@name="mail"]');
- test_page($page,
- 'Subscriptions for alex@example.com',
- 'Comments on Foo', 'Comments on Bar');
- test_page_negative($page, 'Comment on Baz', 'Quux');
- xpath_test($page,
- '//p/input[@type="checkbox"][@name="pages"][@value="Comments_on_Foo"]',
- '//p/input[@type="checkbox"][@name="pages"][@value="Comments_on_Bar"]');
- test_page(get_page('action=subscriptionlist pwd=foo raw=1'),
- 'Comments_on_Foo alex@example.com',
- 'Comments_on_Bar alex@example.com',
- 'alex@example.com Comments_on_Bar Comments_on_Foo');
- $page = get_page('action=unsubscribe mail=alex@example.com pages=Comments_on_Foo pages=Comments_on_Bar');
- test_page($page,
- '<h1>Subscriptions</h1>',
- 'Unsubscribed alex@example.com from the following');
- xpath_test($page,
- '//li/a[@class="local"][@href="http://localhost/wiki.pl/Comments_on_Foo"][text()="Comments on Foo"]',
- '//li/a[@class="local"][@href="http://localhost/wiki.pl/Comments_on_Bar"][text()="Comments on Bar"]');
- test_page_negative(get_page('action=subscriptionlist pwd=foo'),
- 'Comments_on_Foo',
- 'Comments_on_Bar',
- 'alex@example.com');
- $page = get_page('action=browse id=Comments_on_Foo mail=alex@example.com');
- xpath_test($page,
- '//label[@for="mail"][contains(text(), "Email")]',
- '//input[@name="mail"][@value="alex@example.com"]',
- '//input[@type="checkbox"][@name="notify"][@value="1"]',
- '//a[@class="subscribe"][@href="http://localhost/wiki.pl?action=subscribe;pages=Comments_on_Foo"][text()="subscribe"]');
- $page = get_page('action=subscribe mail=alex@example.com pages=Comments_on_Foo pages=Comments_on_Bar pages=Fail');
- test_page($page,
- 'Subscribed alex@example.com to the following pages',
- 'The remaining pages do not exist');
- xpath_test($page,
- '//li/a[@class="local"][@href="http://localhost/wiki.pl/Comments_on_Foo"][text()="Comments on Foo"]',
- '//li/a[@class="local"][@href="http://localhost/wiki.pl/Comments_on_Bar"][text()="Comments on Bar"]');
- $page = get_page('action=browse id=Comments_on_Foo mail=alex@example.com');
- xpath_test($page,
- '//label[@for="mail"][contains(text(), "Email")]',
- '//input[@name="mail"][@value="alex@example.com"]',
- '//a[@class="unsubscribe"][@href="http://localhost/wiki.pl?action=unsubscribe;pages=Comments_on_Foo"][text()="unsubscribe"]');
- negative_xpath_test($page, '//input[@type="checkbox"][@name="notify"]');
- add_module('localnames.pl');
- AppendStringToFile($ConfigFile, "\$LocalNamesCollect = 1;\n");
- get_page('title=MyPage aftertext="This is an [http://www.example.com/ Example]."'
- . ' mail=alex@example.com notify=1');
- xpath_test(get_page('MyPage'),
- '//a[@class="url http outside"][@href="http://www.example.com/"][text()="Example"]');
- xpath_test(get_page('LocalNames'),
- '//ul/li/a[@class="url http outside"][@href="http://www.example.com/"][text()="Example"]');
- $page = get_page('action=subscriptions mail=alex@example.com');
- test_page($page, 'MyPage');
- test_page_negative($page, 'LocalNames');
|