9 use SGN::Test::WWW::Mechanize;
10 use SGN::Test qw/validate_urls/;
12 use CXGN::GEM::Schema;
18 my $mech = SGN::Test::WWW::Mechanize->new;
20 ## This test are local test, so it will use the with_test_level function
22 $mech->with_test_level( local => sub {
24 ## First take variables for the test from the database ##
26 my @schema_list = ('gem', 'biosource', 'metadata', 'public');
27 my $schema_list = join(',', @schema_list);
29 my $dbh = $mech->context()->dbc()->dbh();
31 my $schema = $mech->context->dbic_schema('CXGN::GEM::Schema');
33 ## WWW. GEM SEARCH TEST ###
35 $urls{"gem search page for templates"} = "/search/direct_search.pl?search=template";
36 $urls{"gem search page for experiments"} = "/search/direct_search.pl?search=experiment";
37 $urls{"gem search page for platforms"} = "/search/direct_search.pl?search=platform";
39 ## WWW. RESULT AND DETAIL PAGES ###
42 ## Take a template, an experiment name and a platform name
44 my ($template_row) = $schema->resultset('GeTemplate')
47 order_by => {-asc => 'template_id'},
52 ## Now it will test the expected gem result web-page if there is at least one row
53 ## in the database. If not, it will test the error page
55 if (defined $template_row) {
57 my $template_id = $template_row->get_column('template_id');
58 my $template_name = $template_row->get_column('template_name');
60 $urls{'gem results page for templates'} = "/search/gem_template_search.pl?w616_template_parameters=$template_name";
61 $urls{'gem template page'} = "/gem/template.pl?id=$template_id";
62 $urls{'gem template page (name)'} = "/gem/template.pl?name=$template_name";
67 my ($experiment_row) = $schema->resultset('GeExperiment')
70 order_by => {-asc => 'experiment_id'},
75 ## Now it will test the expected gem result web-page if there is at least one row
76 ## in the database. If not, it will test the error page
78 if (defined $experiment_row) {
80 my $experiment_id = $experiment_row->get_column('experiment_id');
81 my $experiment_name = $experiment_row->get_column('experiment_name');
83 my @exp_frags = split(/ /, $experiment_name);
84 my $partial_name = $exp_frags[0];
86 $urls{'gem results page for experiments'} = "/search/gem_experiment_search.pl?w932_experiment_parameters=$partial_name";
87 $urls{'gem experiment page'} = "/gem/experiment.pl?id=$experiment_id";
88 $urls{'gem experiment page (name)'} = "/gem/experiment.pl?name=$experiment_name";
93 my ($platform_row) = $schema->resultset('GePlatform')
96 order_by => {-asc => 'platform_id'},
101 if (defined $platform_row) {
103 my $platform_id = $platform_row->get_column('platform_id');
104 my $platform_name = $platform_row->get_column('platform_name');
106 my @plat_frags = split(/ /, $platform_name);
107 my $plat_partial_name = $plat_frags[0];
109 $urls{'gem results page for platform'} = "/search/gem_experiment_search.pl?w932_template_parameters=$plat_partial_name";
110 $urls{'gem platform page'} = "/gem/platform.pl?id=$platform_id";
111 $urls{'gem platform page (name)'} = "/gem/platform.pl?name=$platform_name";
114 ## EXPERIMENTAL DESIGN ##
116 my ($experimental_design_row) = $schema->resultset('GeExperimentalDesign')
119 order_by => {-asc => 'experimental_design_id'},
124 if (defined $experimental_design_row) {
126 my $expdesign_id = $experimental_design_row->get_column('experimental_design_id');
127 my $expdesign_name = $experimental_design_row->get_column('experimental_design_name');
129 $urls{'gem detail page for experimental design'} = "/gem/experimental_design.pl?id=$expdesign_id";
130 $urls{'gem detail page for experimental design (name)'} = "/gem/experimental_design.pl?name=$expdesign_name";
135 my ($target_row) = $schema->resultset('GeTarget')
138 order_by => {-asc => 'target_id'},
143 if (defined $target_row) {
145 my $target_id = $target_row->get_column('target_id');
146 my $target_name = $target_row->get_column('target_name');
148 $urls{'gem detail page for target'} = "/gem/target.pl?id=$target_id";
149 $urls{'gem detail page for target (name)'} = "/gem/target.pl?name=$target_name";
151 validate_urls(\%urls, $ENV{ITERATIONS} || 1 );