6 use SGN::Test qw/validate_urls/;
9 use SGN::Test::WWW::Mechanize;
10 use CXGN::GEM::Schema;
16 my $base_url = $ENV{SGN_TEST_SERVER};
17 my $mech = SGN::Test::WWW::Mechanize->new;
19 ## This test are local test, so it will use the with_test_level function
21 $mech->with_test_level( local => sub {
23 ## First take variables for the test from the database ##
25 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
26 my $schema_list = join(',', @schema_list);
27 my $set_path = "SET search_path TO $schema_list";
29 my $dbh = $mech->context()->dbc()->dbh();
31 my $schema = CXGN::GEM::Schema->connect( sub { $dbh },
32 {on_connect_do => $set_path} );
38 ## WWW. GEM SEARCH TEST ###
40 $urls{"gem search page for templates"} = "/search/direct_search.pl?search=template";
41 $urls{"gem search page for experiments"} = "/search/direct_search.pl?search=experiment";
42 $urls{"gem search page for platforms"} = "/search/direct_search.pl?search=platform";
44 ## WWW. RESULT AND DETAIL PAGES ###
47 ## Take a template, an experiment name and a platform name
49 my ($template_row) = $schema->resultset('GeTemplate')
52 order_by => {-asc => 'template_id'},
57 ## Now it will test the expected gem result web-page if there is at least one row
58 ## in the database. If not, it will test the error page
60 if (defined $template_row) {
62 my $template_id = $template_row->get_column('template_id');
63 my $template_name = $template_row->get_column('template_name');
65 $urls{'gem results page for templates'} = "/search/gem_template_search.pl?w616_template_parameters=$template_name";
66 $urls{'gem template page'} = "/gem/template.pl?id=$template_id";
67 $urls{'gem template page (name)'} = "/gem/template.pl?name=$template_name";
72 my ($experiment_row) = $schema->resultset('GeExperiment')
75 order_by => {-asc => 'experiment_id'},
80 ## Now it will test the expected gem result web-page if there is at least one row
81 ## in the database. If not, it will test the error page
83 if (defined $experiment_row) {
85 my $experiment_id = $experiment_row->get_column('experiment_id');
86 my $experiment_name = $experiment_row->get_column('experiment_name');
88 my @exp_frags = split(/ /, $experiment_name);
89 my $partial_name = $exp_frags[0];
91 $urls{'gem results page for experiments'} = "/search/gem_experiment_search.pl?w932_experiment_parameters=$partial_name";
92 $urls{'gem experiment page'} = "/gem/experiment.pl?id=$experiment_id";
93 $urls{'gem experiment page (name)'} = "/gem/experiment.pl?name=$experiment_name";
98 my ($platform_row) = $schema->resultset('GePlatform')
101 order_by => {-asc => 'platform_id'},
106 if (defined $platform_row) {
108 my $platform_id = $platform_row->get_column('platform_id');
109 my $platform_name = $platform_row->get_column('platform_name');
111 my @plat_frags = split(/ /, $platform_name);
112 my $plat_partial_name = $plat_frags[0];
114 $urls{'gem results page for platform'} = "/search/gem_experiment_search.pl?w932_template_parameters=$plat_partial_name";
115 $urls{'gem platform page'} = "/gem/platform.pl?id=$platform_id";
116 $urls{'gem platform page (name)'} = "/gem/platform.pl?name=$platform_name";
119 ## EXPERIMENTAL DESIGN ##
121 my ($experimental_design_row) = $schema->resultset('GeExperimentalDesign')
124 order_by => {-asc => 'experimental_design_id'},
129 if (defined $experimental_design_row) {
131 my $expdesign_id = $experimental_design_row->get_column('experimental_design_id');
132 my $expdesign_name = $experimental_design_row->get_column('experimental_design_name');
134 $urls{'gem detail page for experimental design'} = "/gem/experimental_design.pl?id=$expdesign_id";
135 $urls{'gem detail page for experimental design (name)'} = "/gem/experimental_design.pl?name=$expdesign_name";
140 my ($target_row) = $schema->resultset('GeTarget')
143 order_by => {-asc => 'target_id'},
148 if (defined $target_row) {
150 my $target_id = $target_row->get_column('target_id');
151 my $target_name = $target_row->get_column('target_name');
153 $urls{'gem detail page for target'} = "/gem/target.pl?id=$target_id";
154 $urls{'gem detail page for target (name)'} = "/gem/target.pl?name=$target_name";
156 validate_urls(\%urls, $ENV{ITERATIONS} || 1 );