5 use SGN::Test::WWW::WebDriver;
6 use SGN::Test::Fixture;
8 my $f = SGN::Test::Fixture->new();
9 my $t = SGN::Test::WWW::WebDriver->new();
11 $t->while_logged_in_as("submitter", sub {
13 for my $extension ("xls", "xlsx") {
16 $t->get_ok('/breeders/trials');
19 $t->find_element_ok("refresh_jstree_html", "name", "click on upload_trial_link ")->click();
22 $t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
26 $t->find_element_ok('next_step_upload_intro_button', 'id', 'go to next screen - Intro')->click();
29 # SCREEN 2 /File formating/
30 $t->find_element_ok("upload_single_trial_design_tab", "id", "choose a single trial design tab (default)");
31 $t->find_element_ok('next_step_file_formatting_button', 'id', 'go to next screen - Intro')->click();
34 # SCREEN 3 /Enter trial information/
35 my $trial_name = $t->find_element_ok("trial_upload_name", "id", "find trial name input");
36 $trial_name->send_keys('test_trial_upload');
38 $t->find_element_ok("trial_upload_breeding_program", "id", "find breeding program select")->click();
40 $t->find_element_ok('//select[@id="trial_upload_breeding_program"]/option[@value="test"]', 'xpath', "Select 'test' as value for breeding program")->click();
42 $t->find_element_ok("trial_upload_location", "id", "find location select")->click();
44 $t->find_element_ok('//select[@id="trial_upload_location"]/option[@value="test_location"]', 'xpath', "Select 'test_location' as value for trial location")->click();
46 $t->find_element_ok("trial_upload_trial_type", "id", "find trial type select")->click();
49 $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();
51 $t->find_element_ok("trial_upload_year", "id", "find trial year input")->click();
53 $t->find_element_ok('//select[@id="trial_upload_year"]/option[@value="2016"]', 'xpath', "Select '2016' as value for year")->click();
55 $t->find_element_ok('trial_upload_plot_width', 'id', "find trial plot width input")->send_keys("10");
56 $t->find_element_ok('trial_upload_plot_length', 'id', "find trial plot length input")->send_keys("10");
57 $t->find_element_ok('trial_upload_field_size', 'id', "find trial field size input")->send_keys("5");
58 $t->find_element_ok('trial_upload_plant_entries', 'id', "find trial plants per plot input")->send_keys("10");
60 my $trial_description = $t->find_element_ok("trial_upload_description", "id", "find trial description input");
61 $trial_description->send_keys('Test derived traits trial test description');
63 $t->find_element_ok("trial_upload_trial_stock_type", "id", "find trial design select")->click();
65 $t->find_element_ok('//select[@id="trial_upload_trial_stock_type"]/option[@value="accession"]', 'xpath', "Select 'accession' as value for stock type")->click();
67 $t->find_element_ok("trial_upload_design_method", "id", "find trial design select")->click();
69 $t->find_element_ok('//select[@id="trial_upload_design_method"]/option[@value="CRD"]', 'xpath', "Select 'CRD' as value for design method")->click();
71 my $upload_input = $t->find_element_ok("trial_uploaded_file", "id", "find file input");
72 my $filename = $f->config->{basepath} . "/t/data/trial/trial_layout_example.$extension";
74 $t->driver()->upload_file($filename);
75 $upload_input->send_keys($filename);
78 $t->find_element_ok('next_step_trial_information_button', 'id', 'go to next screen - Intro')->click();
79 # SCREEN 4 /Trial Linkage/
81 $t->find_element_ok("upload_trial_trial_sourced", "id", "find trial sourced select")->click();
83 $t->find_element_ok('//select[@id="upload_trial_trial_sourced"]/option[@value="no"]', 'xpath', "Select 'no' as value for trial sourced")->click();
85 $t->find_element_ok("upload_trial_trial_will_be_genotyped", "id", "find 'trial will be genotyped' select")->click();
87 $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();
89 $t->find_element_ok("upload_trial_trial_will_be_crossed", "id", "find 'trial will be crossed' select")->click();
91 $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();
93 $t->find_element_ok("upload_trial_validate_form_button", "id", "find and click trial validate form button")->click();
96 $t->find_element_ok("upload_trial_submit_first", "name", "find and click upload trial submit button")->click();
98 # important sleep 60 seconds for a functionality - it can take ages to save a trail depend of the machine
101 $t->find_element_ok("close_trial_upload_dialog", "id", "find and click close trial upload button")->click();
106 # SCREEN 5 /Fix missing accessions problem/
107 # maybe in a future - not connected with basic functionality - but worth to think about it in test coverage
108 # SCREEN 6 /Fix missing seedlots problem/
109 # maybe in a future - not connected with basic functionality - but worth to think about it in test coverage
110 # SCREEN 7 /Try submitting trial again/
111 # maybe in a future - not connected with basic functionality - but worth to think about it in test coverage
114 # FROM HERE TEST MAKES NO SENSE ANYMORE. DERIVED FUNCTIONALITY DOES NOT SEEMS TO WORK.
115 # PROBABLY WE SHOULD WRITE THE REST OF THE TEST ONCE A FUNCTIONALITY IS SET UP WITH THE CORRECT UPLOAD FILE FOR THE
119 # $t->get_ok('/breeders/phenotyping');
123 # $t->find_element_ok("upload_spreadsheet_phenotypes_link", "id", "submit upload phenotype file ")->click();
126 # $t->find_element_ok("upload_spreadsheet_phenotype_file_format", "id", "find spreadsheet file format select")->click();
128 # $t->find_element_ok('//select[@id="upload_spreadsheet_phenotype_file_format"]/option[@value="simple"]', 'xpath', "Select 'simple' as file format")->click();
130 # my $upload_input = $t->find_element_ok("upload_spreadsheet_phenotype_file_input", "id", "find file input");
131 # my $filename = $f->config->{basepath}."/t/data/trial/trial_phenotype_upload_file_simple.xls";
132 # $t->driver()->upload_file($filename);
133 # $upload_input->send_keys($filename);
136 # $t->find_element_ok("upload_spreadsheet_phenotype_submit_verify", "id", "submit upload trial file ")->click();
139 # $t->find_element_ok("upload_spreadsheet_phenotype_submit_store", "id", "submit upload trial file ")->click();
142 # $t->get_ok('/breeders/trials');
145 # $t->find_element_ok("refresh_jstree_html", "name", "click on upload_trial_link ")->click();
148 # $t->find_element_ok("test", "partial_link_text", "check program in tree")->click();
150 # $t->find_element_ok("jstree-icon", "class", "view drop down for program")->click();
153 # $t->find_element_ok("test_trial_upload", "partial_link_text", "check program in tree")->click();
156 # $t->get_ok('/breeders/trial/145'); # ???
159 # $t->find_element_ok("compute_derived_traits_onswitch", "id", "click on compute trait link ")->click();
162 # $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
165 # my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
167 # $trait_select->send_keys('sprouting|CO_334:0000008');
169 # $t->find_element_ok("button", "id", "submit compute trait ")->click();
173 # $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
177 # $t->find_element_ok("derived_trait_saved_dialog_message", "id", "ok compute trait saved dialog")->click();
181 # $t->driver->accept_alert();
185 # $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
189 # my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
191 # $trait_select->send_keys('specific gravity|CO_334:0000163');
194 # $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
198 # $t->driver->accept_alert();
202 # $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
206 # my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
208 # $trait_select->send_keys('starch content|CO_334:0000071');
210 # $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
214 # $t->driver->accept_alert();
218 # $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
222 # my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
224 # $trait_select->send_keys('dry matter content by specific gravity method|CO_334:0000160');
226 # $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
229 # $t->driver->accept_alert();
232 # #$t->get_ok('/breeders/trial/145');
236 # $t->find_element_ok("trial_detail_traits_assayed_onswitch", "id", "view uploaded traits ")->click();