Merge pull request #5205 from solgenomics/topic/generic_trial_upload
[sgn.git] / t / selenium2 / breeders / derived_trait.t
bloba9573403af1f00aff477f4a21f6a605dc98d9cdb
1 use lib 't/lib';
3 use Test::More;
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") {
14         sleep(1);
16         $t->get_ok('/breeders/trials');
17         sleep(4);
19         $t->find_element_ok("refresh_jstree_html", "name", "click on upload_trial_link ")->click();
20         sleep(5);
22         $t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
23         sleep(2);
25         # SCREEN 1 /Intro/
26         $t->find_element_ok('next_step_upload_intro_button', 'id', 'go to next screen - Intro')->click();
27         sleep(1);
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();
32         sleep(1);
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();
39         sleep(1);
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();
43         sleep(1);
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();
47         sleep(1);
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();
52         sleep(1);
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();
64         sleep(1);
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();
68         sleep(1);
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);
76         sleep(2);
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();
82         sleep(1);
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();
86         sleep(1);
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();
90         sleep(1);
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();
94         sleep(2);
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
99         sleep(60);
101         $t->find_element_ok("close_trial_upload_dialog", "id", "find and click close trial upload button")->click();
103         $f->clean_up_db();
104     }
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
116     # TEST UPLOAD TRAIL.
119     # $t->get_ok('/breeders/phenotyping');
120         #
121     # sleep(2);
122     #
123     # $t->find_element_ok("upload_spreadsheet_phenotypes_link", "id", "submit upload phenotype file ")->click();
124     # sleep(2);
125     #
126     # $t->find_element_ok("upload_spreadsheet_phenotype_file_format", "id", "find spreadsheet file format select")->click();
127     # sleep(1);
128     # $t->find_element_ok('//select[@id="upload_spreadsheet_phenotype_file_format"]/option[@value="simple"]', 'xpath', "Select 'simple' as file format")->click();
129     #
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);
134     # sleep(1);
135     #
136     # $t->find_element_ok("upload_spreadsheet_phenotype_submit_verify", "id", "submit upload trial file ")->click();
137     # sleep(3);
138     #
139     # $t->find_element_ok("upload_spreadsheet_phenotype_submit_store", "id", "submit upload trial file ")->click();
140     # sleep(10);
141     #
142     # $t->get_ok('/breeders/trials');
143     # sleep(2);
144     #
145     # $t->find_element_ok("refresh_jstree_html", "name", "click on upload_trial_link ")->click();
146     # sleep(10);
147     #
148     # $t->find_element_ok("test", "partial_link_text", "check program in tree")->click();
149     #
150     # $t->find_element_ok("jstree-icon", "class", "view drop down for program")->click();
151     # sleep(3);
152     #
153     # $t->find_element_ok("test_trial_upload", "partial_link_text", "check program in tree")->click();
154     # sleep(1);
155     #
156     # $t->get_ok('/breeders/trial/145'); # ???
157     # sleep(3);
158     #
159     # $t->find_element_ok("compute_derived_traits_onswitch", "id", "click on compute trait link ")->click();
160     # sleep(1);
161     #
162     # $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
163     # sleep(3);
164     #
165     # my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
166     #
167     # $trait_select->send_keys('sprouting|CO_334:0000008');
169    # $t->find_element_ok("button", "id", "submit compute trait ")->click();
171    # sleep(1);
173     # $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
174     #
175     # sleep(5);
177    # $t->find_element_ok("derived_trait_saved_dialog_message", "id", "ok compute trait saved dialog")->click();
179     #sleep(1);
181    #  $t->driver->accept_alert();
182    #
183    #  sleep(1);
184    #
185    #  $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
186    #
187    #  sleep(3);
188    #
189    #  my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
190    #
191    #  $trait_select->send_keys('specific gravity|CO_334:0000163');
192    #
193    #
194    #  $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
195    #
196    #  sleep(5);
197    #
198    #  $t->driver->accept_alert();
199    #
200    #  sleep(1);
201    #
202    #   $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
203    #
204    #  sleep(3);
205    #
206    #  my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
207    #
208    #  $trait_select->send_keys('starch content|CO_334:0000071');
209    #
210    #  $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
211    #
212    #  sleep(5);
213    #
214    #  $t->driver->accept_alert();
215    #
216    #  sleep(1);
217    #
218    #   $t->find_element_ok("derived_button", "id", "click on compute trait link button")->click();
219    #
220    #  sleep(3);
221    #
222    #  my $trait_select = $t->find_element_ok("derived_trait_select", "id", "find trait select dialog");
223    #
224    #  $trait_select->send_keys('dry matter content by specific gravity method|CO_334:0000160');
225    #
226    #  $t->find_element_ok("create_derived_trait_submit_button", "id", "submit compute trait ")->click();
227    #  sleep(5);
228    #
229    #  $t->driver->accept_alert();
230    #  sleep(1);
231    #
232    #  #$t->get_ok('/breeders/trial/145');
233    #
234    # # sleep(3);
235    #
236    #  $t->find_element_ok("trial_detail_traits_assayed_onswitch", "id", "view uploaded traits ")->click();
237    #  sleep(5);
238    #
239    }
242 $t->driver->close();
243 done_testing();