Merge pull request #5205 from solgenomics/topic/generic_trial_upload
[sgn.git] / t / selenium2 / breeders / upload_trial_file.t
blob767ba416113e74be8c6d0a37baaeb7fdde5171b9
1 use lib 't/lib';
3 # use Test::More 'tests' => 40;
4 use Test::More 'tests' => 80;
6 use SGN::Test::WWW::WebDriver;
7 use SGN::Test::Fixture;
9 my $f = SGN::Test::Fixture->new();
10 my $t = SGN::Test::WWW::WebDriver->new();
13 $t->while_logged_in_as("submitter", sub {
16     for my $extension ("xls", "xlsx") {
17         sleep(1);
19         $t->get_ok('/breeders/trials');
20         sleep(3);
22         $t->find_element_ok("refresh_jstree_html", "name", "click on refresh_jstree_html ")->click();
23         sleep(5);
25         $t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
26         sleep(2);
28         # SCREEN 1 /Intro/
29         $t->find_element_ok("next_step_upload_intro_button", "id", "click on next_step_upload_intro_button ")->click();
30         sleep(1);
32         # SCREEN 2 /File formating/
33         $t->find_element_ok("upload_single_trial_design_tab", "id", "choose a single trial design tab (default)");
34         $t->find_element_ok('next_step_file_formatting_button', 'id', 'go to next screen - Intro')->click();
35         sleep(1);
37         # SCREEN 3 /Enter trial information/
38         my $trial_name = "selenium_test_upload_trial_file";
39         $t->find_element_ok("trial_upload_name", "id", "find trial name input")->send_keys($trial_name);
41         $t->find_element_ok("trial_upload_breeding_program", "id", "find breeding program select")->click();
42         sleep(1);
43         $t->find_element_ok('//select[@id="trial_upload_breeding_program"]/option[@value="test"]', 'xpath', "Select 'test' as value for breeding program")->click();
45         $t->find_element_ok("trial_upload_location", "id", "find location select")->click();
46         sleep(1);
47         $t->find_element_ok('//select[@id="trial_upload_location"]/option[@value="test_location"]', 'xpath', "Select 'test_location' as value for trial location")->click();
49         $t->find_element_ok("trial_upload_trial_type", "id", "find trial type select")->click();
50         sleep(1);
52         $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();
54         $t->find_element_ok("trial_upload_year", "id", "find trial year input")->click();
55         sleep(1);
56         $t->find_element_ok('//select[@id="trial_upload_year"]/option[@value="2015"]', 'xpath', "Select '2016' as value for year")->click();
58         $t->find_element_ok('trial_upload_plot_width', 'id', "find trial plot width input")->send_keys("10");
59         $t->find_element_ok('trial_upload_plot_length', 'id', "find trial plot length input")->send_keys("10");
60         $t->find_element_ok('trial_upload_field_size', 'id', "find trial field size input")->send_keys("5");
61         $t->find_element_ok('trial_upload_plant_entries', 'id', "find trial plants per plot input")->send_keys("10");
63         $t->find_element_ok("trial_upload_description", "id", "find trial description input")->send_keys('Test test upload trial file - description');;
65         $t->find_element_ok("trial_upload_trial_stock_type", "id", "find trial design select")->click();
66         sleep(1);
67         $t->find_element_ok('//select[@id="trial_upload_trial_stock_type"]/option[@value="accession"]', 'xpath', "Select 'accession' as value for stock type")->click();
69         $t->find_element_ok("trial_upload_design_method", "id", "find trial design select")->click();
70         sleep(1);
71         $t->find_element_ok('//select[@id="trial_upload_design_method"]/option[@value="CRD"]', 'xpath', "Select 'CRD' as value for design method")->click();
73         my $upload_input = $t->find_element_ok("trial_uploaded_file", "id", "find file input");
74         my $filename = $f->config->{basepath} . "/t/data/trial/trial_layout_example_other_plots.$extension";
76         $t->driver()->upload_file($filename);
77         $upload_input->send_keys($filename);
78         sleep(2);
80         $t->find_element_ok('next_step_trial_information_button', 'id', 'go to next screen - Intro')->click();
81         # SCREEN 4 /Trial Linkage/
83         $t->find_element_ok("upload_trial_trial_sourced", "id", "find trial sourced select")->click();
84         sleep(1);
85         $t->find_element_ok('//select[@id="upload_trial_trial_sourced"]/option[@value="no"]', 'xpath', "Select 'no' as value for trial sourced")->click();
87         $t->find_element_ok("upload_trial_trial_will_be_genotyped", "id", "find 'trial will be genotyped' select")->click();
88         sleep(1);
89         $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();
91         $t->find_element_ok("upload_trial_trial_will_be_crossed", "id", "find 'trial will be crossed' select")->click();
92         sleep(1);
93         $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();
95         $t->find_element_ok("upload_trial_validate_form_button", "id", "find and click trial validate form button")->click();
96         sleep(2);
98         $t->find_element_ok("upload_trial_submit_first", "name", "find and click upload trial submit button")->click();
100         # important sleep 60 seconds for a functionality - it can take ages to save a trail depend of the machine
101         sleep(60);
103         $t->find_element_ok("close_trial_upload_dialog", "id", "find and click close trial upload button")->click();
105         $t->get_ok('/breeders/trials');
106         sleep(3);
108         $t->find_element_ok("refresh_jstree_html", "name", "refresh tree")->click();
109         sleep(7);
111         $t->find_element_ok("test", "partial_link_text", "check program in tree")->click();
112         sleep(3);
114         $t->find_element_ok("jstree-icon", "class", "view drop down for program")->click();
115         sleep(5);
117         $t->find_element_ok("$trial_name", "partial_link_text", "check program in tree")->click();
118         sleep(1);
120         $f->clean_up_db();
121     }
124 $t->driver->close();
125 done_testing();