use warnings;
use strict;
+use FindBin;
+use lib ("$FindBin::Bin/lib");
+
+use stemmaweb::Test::Common;
+
use stemmaweb;
use LWP::Protocol::PSGI;
use Test::WWW::Mechanize;
use HTML::TreeBuilder;
use Data::Dumper;
-use FindBin;
-use lib ("$FindBin::Bin/lib");
-
use stemmaweb::Test::DB;
stemmaweb::Test::DB->new_db;
LWP::Protocol::PSGI->register(stemmaweb->psgi_app);
-use stemmaweb::Test::Common;
-
my $ua = Test::WWW::Mechanize->new;
$ua->get_ok('http://localhost/register');
confirm_password => 'UserPass',
});
-warn $ua->content;
+$ua->content_contains('You are now registered.', 'Registration worked');
+
+$ua->get('/');
+$ua->content_contains('Hello! user2@example.org', 'We are logged in.');
+
+$ua->get('/logout');
+
+$ua->get_ok('http://localhost/login');
+$response = $ua->submit_form(
+ fields => {
+ username => 'user2@example.org',
+ password => 'UserPass'
+ });
+
+$ua->content_contains('Stemmaweb - Logged in', 'Log in with new account works');
+
+$ua->get('/');
+$ua->content_contains('Hello! user2@example.org', 'We are logged in with new account');
+
+$ua->get('/logout');
-=cut
+$ua->get_ok('http://localhost/register');
-$ua->content_contains('Stemmaweb - Logged in', 'Log in successful.');
+$response = $ua->submit_form(
+ fields => {
+ username => 'user2@example.org',
+ password => 'UserPass',
+ confirm_password => 'UserPass',
+ });
-my $content = $ua->get('/');
-$ua->content_contains('Hello! user@example.org', 'We are logged in.');
+$ua->content_contains('That username already exists.', 'We cannot register an already
+ existing username');
-=cut
done_testing;