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") {
19 $t->get_ok('/breeders/trials');
22 $t->find_element_ok("refresh_jstree_html", "name", "click on refresh_jstree_html ")->click();
25 $t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
29 $t->find_element_ok("next_step_upload_intro_button", "id", "click on next_step_upload_intro_button ")->click();
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();
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();
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();
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();
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();
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();
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();
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);
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();
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();
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();
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();
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
103 $t->find_element_ok("close_trial_upload_dialog", "id", "find and click close trial upload button")->click();
105 $t->get_ok('/breeders/trials');
108 $t->find_element_ok("refresh_jstree_html", "name", "refresh tree")->click();
111 $t->find_element_ok("test", "partial_link_text", "check program in tree")->click();
114 $t->find_element_ok("jstree-icon", "class", "view drop down for program")->click();
117 $t->find_element_ok("$trial_name", "partial_link_text", "check program in tree")->click();