4 use Test::More 'tests' => 178;
6 use SGN::Test::WWW::WebDriver;
7 use SGN::Test::Fixture;
8 my $t = SGN::Test::WWW::WebDriver->new();
9 my $f = SGN::Test::Fixture->new();
11 $t->while_logged_in_as("curator", sub {
14 for my $file ("T100_trial_layout.xls", "T100_trial_layout_selenium_second_file.xlsx") {
17 $t->get_ok('/breeders/trials');
20 $t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
24 $t->find_element_ok("next_step_upload_intro_button", "id", "click on next_step_upload_intro_button ")->click();
27 # SCREEN 2 /File formating/
28 $t->find_element_ok("upload_single_trial_design_tab", "id", "choose a single trial design tab (default)");
29 $t->find_element_ok('next_step_file_formatting_button', 'id', 'go to next screen - Intro')->click();
32 # SCREEN 3 /Enter trial information/
33 my $trial_name = "selenium_test_trial_detail_$file";
34 $t->find_element_ok("trial_upload_name", "id", "find trial name input")->send_keys($trial_name);
36 $t->find_element_ok("trial_upload_breeding_program", "id", "find breeding program select")->click();
38 $t->find_element_ok('//select[@id="trial_upload_breeding_program"]/option[@value="test"]', 'xpath', "Select 'test' as value for breeding program")->click();
40 $t->find_element_ok("trial_upload_location", "id", "find location select")->click();
42 $t->find_element_ok('//select[@id="trial_upload_location"]/option[@value="test_location"]', 'xpath', "Select 'test_location' as value for trial location")->click();
44 $t->find_element_ok("trial_upload_trial_type", "id", "find trial type select")->click();
47 $t->find_element_ok('//select[@id="trial_upload_trial_type"]/option[@title="phenotyping_trial"]', 'xpath', "Select 'phenotyping_trial' as value for type of trial")->click();
49 $t->find_element_ok("trial_upload_year", "id", "find trial year input")->click();
51 $t->find_element_ok('//select[@id="trial_upload_year"]/option[@value="2016"]', 'xpath', "Select '2016' as value for year")->click();
53 $t->find_element_ok('trial_upload_plot_width', 'id', "find trial plot width input")->send_keys("10");
54 $t->find_element_ok('trial_upload_plot_length', 'id', "find trial plot length input")->send_keys("10");
55 $t->find_element_ok('trial_upload_field_size', 'id', "find trial field size input")->send_keys("5");
56 $t->find_element_ok('trial_upload_plant_entries', 'id', "find trial plants per plot input")->send_keys("10");
58 $t->find_element_ok("trial_upload_description", "id", "find trial description input")->send_keys('Test trial detail selenium - description');;
60 $t->find_element_ok("trial_upload_trial_stock_type", "id", "find trial design select")->click();
62 $t->find_element_ok('//select[@id="trial_upload_trial_stock_type"]/option[@value="accession"]', 'xpath', "Select 'accession' as value for stock type")->click();
64 $t->find_element_ok("trial_upload_design_method", "id", "find trial design select")->click();
66 $t->find_element_ok('//select[@id="trial_upload_design_method"]/option[@value="CRD"]', 'xpath', "Select 'CRD' as value for design method")->click();
68 my $upload_input = $t->find_element_ok("trial_uploaded_file", "id", "find file input");
69 my $filename = $f->config->{basepath} . "/t/data/trial/$file";
71 $t->driver()->upload_file($filename);
72 $upload_input->send_keys($filename);
75 $t->find_element_ok('next_step_trial_information_button', 'id', 'go to next screen - Intro')->click();
76 # SCREEN 4 /Trial Linkage/
78 $t->find_element_ok("upload_trial_trial_sourced", "id", "find trial sourced select")->click();
80 $t->find_element_ok('//select[@id="upload_trial_trial_sourced"]/option[@value="no"]', 'xpath', "Select 'no' as value for trial sourced")->click();
82 $t->find_element_ok("upload_trial_trial_will_be_genotyped", "id", "find 'trial will be genotyped' select")->click();
84 $t->find_element_ok('//select[@id="upload_trial_trial_will_be_genotyped"]/option[@value="no"]', 'xpath', "Select 'no' as value for trial will be genotyped")->click();
86 $t->find_element_ok("upload_trial_trial_will_be_crossed", "id", "find 'trial will be crossed' select")->click();
88 $t->find_element_ok('//select[@id="upload_trial_trial_will_be_crossed"]/option[@value="no"]', 'xpath', "Select 'no' as value for trial will be crossed")->click();
90 $t->find_element_ok("upload_trial_validate_form_button", "id", "find and click trial validate form button")->click();
93 $t->find_element_ok("upload_trial_submit_first", "name", "find and click upload trial submit button")->click();
95 # important sleep 60 seconds for a functionality - it can take ages to save a trail depend of the machine
98 $t->find_element_ok("close_trial_upload_dialog", "id", "find and click close trial upload button")->click();
100 # OPEN A TRIAL AFTER CREATE TO CHECK DETAILS
102 $t->get_ok('/breeders/trials');
105 $t->find_element_ok("refresh_jstree_html_trialtree_button", "id", "refresh tree")->click();
108 $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
111 $t->find_element_ok("$trial_name", "partial_link_text", "open up tree")->click();
113 #New Trial ID from database
114 my $trial_id = $f->bcs_schema->resultset('Project::Project')->search({ name => $trial_name }, { order_by => { -desc => 'project_id' } })->first->project_id();
116 #Delete Trial Coordinates - Remove first one to upload new coordinates
117 $t->get_ok('/breeders/trial/' . $trial_id);
120 my $heatmap_onswitch = $t->find_element_ok("pheno_heatmap_onswitch", "id", "click to open pheno heatmap panel");
121 $heatmap_onswitch->click();
124 $t->find_element_ok("delete_field_map_hm_link", "id", "click on delete previous coordinate")->click();
127 $t->find_element_ok("delete_field_coords_ok_button", "id", "click on delete previous coordinate - confirm")->click();
130 $t->find_element_ok("dismiss_delete_field_map_dialog", "id", "click on confirmation of delete")->click();
133 #Upload Trial Coordinates
134 my $heatmap_onswitch = $t->find_element_ok("pheno_heatmap_onswitch", "id", "click to open pheno heatmap panel");
135 $heatmap_onswitch->click();
138 $t->find_element_ok("heatmap_upload_trial_coords_link", "id", "click on upload_trial_coords_link ")->click();
140 my $upload_input = $t->find_element_ok("trial_coordinates_uploaded_file", "id", "find file input");
142 my $filename = $f->config->{basepath} . "/t/data/trial/T100_trial_coords.csv";
143 $t->driver()->upload_file($filename);
144 $upload_input->send_keys($filename);
147 $t->find_element_ok("upload_trial_coords_ok_button", "id", "submit upload trial coords file ")->click();
150 $t->find_element_ok("trial_coord_upload_success_dialog_message_cancel", "id", "close success msg")->click();
153 $t->find_element_ok("upload_trial_coords_cancel_button", "id", "close upload modal")->click();
156 my $trial_details = $t->find_element_ok(
157 'trial_details_content',
159 "find content of trial details")->get_attribute('innerHTML');
161 ok($trial_details =~ /$trial_name/, "Verify trial name: $trial_name");
162 ok($trial_details =~ /test/, "Verify breeding program");
163 ok($trial_details =~ /test_location/, "Verify trial location");
164 ok($trial_details =~ /2016/, "Verify trial year");
165 ok($trial_details =~ /phenotyping_trial/, "Verify trial type");
166 ok($trial_details =~ /[No Planting Date]/, "Verify planting date");
167 ok($trial_details =~ /[No Harvest Date]/, "Verify harvest date");
168 ok($trial_details =~ /Test trial detail selenium - description/, "Verify description");
170 my $trial_design_onswitch = $t->find_element_ok("trial_design_section_onswitch", "id", "click to open design section");
171 $trial_design_onswitch->click();
174 $trial_details = $t->find_element_ok(
175 'trial_controls_table',
177 "find content of trial design")->get_attribute('innerHTML');
179 ok($trial_details =~ /CRD/, "Verify ");
180 ok($trial_details =~ /2/, "Verify ");
182 $t->find_element_ok("trial_stocks_onswitch", "id", "view trial accessions")->click();
185 $trial_details = $t->find_element_ok(
186 'trial_stocks_table',
188 "find content of trial accessions")->get_attribute('innerHTML');
190 ok($trial_details =~ /test_accession1/, "Verify accessions");
191 ok($trial_details =~ /test_accession2/, "Verify accessions");
192 ok($trial_details =~ /test_accession3/, "Verify accessions");
193 ok($trial_details =~ /test_accession4/, "Verify accessions");
195 $t->find_element_ok("trial_controls_onswitch", "id", "view trial controls")->click();
198 $trial_details = $t->find_element_ok(
199 'trial_controls_content',
201 "find content of trial accessions")->get_attribute('innerHTML');
203 ok($trial_details =~ /test_accession2/, "Verify controls");
204 ok($trial_details =~ /test_accession3/, "Verify controls");
206 $t->find_element_ok("trial_plots_onswitch", "id", "view trial plots")->click();
209 $t->find_element_ok("plot_select_all", "id", "select plots")->click();
212 $t->find_element_ok("plot_data_new_list_name", "id", "find add list input");
214 my $add_list_input = $t->find_element_ok("plot_data_new_list_name", "id", "find add list input test");
216 $add_list_input->send_keys("plots_list");
218 $t->find_element_ok("plot_data_add_to_new_list", "id", "find add list button")->click();
220 $t->accept_alert_ok();
223 # Open a a newly created list and check details of list
224 my $out = $t->find_element_ok("lists_link", "name", "find lists_link")->click();
227 $t->find_element_ok("view_list_plots_list", "id", "view 'plots_list' for test")->click();
230 $trial_details = $t->find_element_ok(
231 'list_item_dialog_datatable_wrapper',
233 "find content of list to check details")->get_attribute('innerHTML');
235 ok($trial_details =~ /T100_plot_01/, "Verify plots");
236 ok($trial_details =~ /T100_plot_02/, "Verify plots");
237 ok($trial_details =~ /T100_plot_03/, "Verify plots");
238 ok($trial_details =~ /T100_plot_04/, "Verify plots");
239 ok($trial_details =~ /T100_plot_05/, "Verify plots");
240 ok($trial_details =~ /T100_plot_06/, "Verify plots");
241 ok($trial_details =~ /T100_plot_07/, "Verify plots");
242 ok($trial_details =~ /T100_plot_08/, "Verify plots");