6 use SGN::Test::WWW::Mechanize;
8 my $m = SGN::Test::WWW::Mechanize->new();
10 plan skip_all => 'test requires at least "local" test level'
11 unless $m->can_test_level('local');
13 use_ok("CXGN::People::Person");
17 my $dbh = $m->context->dbc->dbh();
19 # generate a new user for testing purposes
20 # (to be deleted right afterwards)
22 if( my $u_id = CXGN::People::Person->get_person_by_username( $dbh, "testusername" ) ) {
23 CXGN::People::Person->new( $dbh, $u_id )->hard_delete;
26 my $p = CXGN::People::Person->new($dbh);
27 $p->set_first_name("testfirstname");
28 $p->set_last_name("testlastname");
29 $p->set_organization("testorganization");
30 my $p_id = $p->store();
32 my $login = CXGN::People::Login->new( $dbh, $p_id );
33 $login->set_username("testusername");
34 $login->set_password("testpassword");
36 $login->set_user_type("user");
40 my $u_id = CXGN::People::Person->get_person_by_username( $dbh, "testusername" );
41 my $u = CXGN::People::Person->new( $dbh, $u_id );
45 #$dbh->commit; #unless $u->get_dbh->dbh_param('AutoCommit');
49 is( $u->get_first_name(), "testfirstname", "Test first name test" );
53 $m->get_ok("/solpeople/top-level.pl");
54 $m->content_contains("Login");
59 username => 'testusername',
64 $m->submit_form_ok( \%form, "Login form submission test" );
65 $m->content_contains("testfirstname");
67 $m->get_ok('/solpeople/top-level.pl');
69 $m->follow_link_ok({ url_regex => qr/personal-info\.pl/ });
75 last_name => "manchu",
76 research_interests => "Ketchup",
78 sp_person_id => $p_id,
80 }, "Can change info on personal-info.pl",
83 # check if logout works
85 $m->get_ok( "/solpeople/login.pl?logout=yes",
86 "Request logout page" );
88 $m->content_contains("You have successfully logged out");
92 $login->set_user_type("curator");
95 $m->get("/solpeople/login.pl");
96 $m->submit_form_ok( \%form, "Login as curator form submission" );
97 $m->get_ok("/solpeople/top-level.pl");
98 $m->content_contains( "Curator Tools", "Curator tools presence test" );
100 $m->get_ok("/solpeople/login.pl?logout=yes");
101 $m->content_contains("You have successfully logged out");
103 # try logging in with wrong password
105 $form{fields}->{pd} = "blablabla"; # enter wrong password
106 $m->get_ok("/solpeople/login.pl");
107 $m->submit_form_ok( \%form, "Submit wrong password test" );
108 $m->content_contains("Incorrect username or password");
110 # delete the test user from the database (even if the test died)
113 if( $dbh and my $u_id = CXGN::People::Person->get_person_by_username( $dbh, "testusername" ) ) {
114 CXGN::People::Person->new( $dbh, $u_id )->hard_delete;