trying to fix the stock search test
[sgn.git] / t / integration / stock / stock_search.t
blob278547460e673408c671d6502148bdb49c70472f
1 =head1 NAME
3 stock_search.t - tests for /stock/search/
5 =head1 DESCRIPTION
7 Tests for stock search page
9 =head1 AUTHORS
11 Naama Menda  <nm249@cornell.edu>
13 =cut
15 use Modern::Perl;
16 use Test::More;
18 use lib 't/lib';
20 BEGIN { $ENV{SGN_SKIP_CGI} = 1 } #< can skip compiling cgis, not using them here
21 use SGN::Test::Data qw/create_test/;
22 use SGN::Test::WWW::Mechanize;
25     my $mech = SGN::Test::WWW::Mechanize->new;
27     $mech->get_ok("/stock/search/");
28     $mech->dbh_leak_ok;
29     $mech->content_contains("Stock name");
30     $mech->content_contains("Stock type");
31     $mech->content_contains("Organism");
32     $mech->html_lint_ok('empty stock search valid html');
34     $mech->with_test_level( local => sub {
35         my $stock = create_test('Stock::Stock', {
36             description => "LALALALA3475",
37                                 });
38         my $person = $mech->create_test_user(
39             first_name => 'testfirstname',
40             last_name  => 'testlastname',
41             user_name  => 'testusername',
42             password   => 'testpassword',
43             user_type  => 'submitter',
44             );
45         my $sp_person_id = $person->{id};
47         $stock->create_stockprops( {'sp_person_id' => $sp_person_id} , {cv_name => 'local'} );
48         #######
49         $mech->submit_form_ok({
50             form_name => 'stock_search_form',
51               fields    => {
52                   stock_name => $stock->name,
53                   person =>  $person->{first_name} . ', ' . $person->{last_name},
54               },
55                               }, 'submitted stock search form');
57         $mech->html_lint_ok('valid html after stock search');
59         $mech->content_contains( $stock->name );
60         $mech->content_contains("results");
62         #go to the stock detail page
63         $mech->follow_link_ok( { url => '/stock/'.$stock->stock_id.'/view' }, 'go to the stock detail page' );
64         $mech->dbh_leak_ok;
65         $mech->html_lint_ok( 'stock detail page html ok' );
66     });
70 done_testing;