start fixing test for multi cat phenotype upload.
[sgn.git] / t / selenium2 / breeders / 01_create_trial.t
blobe8f0d48c200c7990f894e8eecf2c572c48ba62c2
2 use strict;
4 use lib 't/lib';
6 use Test::More;
8 use SGN::Test::WWW::WebDriver;
9 use SGN::Test::Fixture;
11 my $t = SGN::Test::WWW::WebDriver->new();
12 my $f = SGN::Test::Fixture->new();
14 $t->while_logged_in_as("submitter", sub {
15         sleep(1);
17         $t->get_ok('/breeders/trials');
18         sleep(3);
20         $t->find_element_ok("refresh_jstree_html", "name", "refresh tree")->click();
21         sleep(5);
23         my $add_project_link = $t->find_element_ok('add_project_link', 'id', "find add trial link");
24         $add_project_link->click();
25         sleep(1);
27         # SCREEN 1 /Intro/
28         $t->find_element_ok('next_step_intro_button', 'id', 'go to next screen - Intro')->click();
30         # SCREEN 2 /Trial information/
31         $t->find_element_ok('select_breeding_program', 'id', 'find breeding program select and click "test"')->click();
32         sleep(1);
33         $t->find_element_ok('//select[@id="select_breeding_program"]/option[@value="test"]', 'xpath', "Select 'test' as value for breeding program")->click();
35         $t->find_element_ok('//select[@id="add_project_location"]/option[@value="test_location"]',
36                 'xpath',
37                 "Select 'test_location' as value for project location")->click();
39         my $trail_name = sprintf("Trial_selenium_%d", int(rand(1000)));
40         $t->find_element_ok('new_trial_name', 'id', "find new trial name input box")->send_keys($trail_name);
42         $t->find_element_ok('add_project_type', 'id', "find project type select list")->click();
43         sleep(1);
44         $t->find_element_ok('//select[@id="add_project_type"]/option[@title="misc_trial"]', 'xpath', "Select 'test' as value for breeding program")->click();
46         $t->find_element_ok('add_project_year', 'id', "find trial year select list")->click();
47         sleep(1);
48         $t->find_element_ok('//select[@id="add_project_year"]/option[@value="2015"]', 'xpath', "Select '2015' as value for year")->click();
50         $t->find_element_ok('add_project_planting_date', 'id', "Set '31/01/2015' as value for planting_date")->send_keys("31/01/2015");
52         $t->find_element_ok('add_project_plot_width', 'id', "find trial plot width input")->send_keys("10");
53         $t->find_element_ok('add_project_plot_length', 'id', "find trial plot length input")->send_keys("10");
54         $t->find_element_ok('new_trial_field_size', 'id', "find trial field size input")->send_keys("5");
55         $t->find_element_ok('add_plant_entries', 'id', "find trial plants per plot input")->send_keys("10");
57         $t->find_element_ok('add_project_description', 'id', "find project description input box")
58                 ->send_keys("Test trial selenium / description for field test");
60         $t->find_element_ok('select_stock_type', 'id', "find trial stock type select input");
61         sleep(1);
62         $t->find_element_ok('//select[@id="select_stock_type"]/option[@value="accession"]', 'xpath', "find accession value for stock type")->click();
64         $t->find_element_ok('select_design_method', 'id', "find field trial description input")->click();
65         sleep(1);
66         $t->find_element_ok('//select[@id="select_design_method"]/option[@value="CRD"]', 'xpath', "find randomized method of design")->click();
68         $t->find_element_ok('create_trial_validate_form_button', 'id', "find form validation button and click")->click();
69         sleep(3);
71         $t->find_element_ok('button[name="create_trial_submit"]', 'css', "find form submit button and click")->click();
72         sleep(3);
75         # SCREEN 3 /Design Information/
77         $t->find_element_ok('rep_count', 'id', "find trial replicates count input")->send_keys("1");
78         sleep(1);
80         $t->find_element_ok('show_list_of_accession_section', 'id', "find accessions to include select")->click();
81         sleep(1);
82         $t->find_element_ok('//option[text()="accessions2add"]', "xpath", "find accession value for list")->click();
83         sleep(2);
85         $t->find_element_ok('crbd_list_of_checks_section_list_select', 'id', "find accessions to include select")->click();
86         sleep(1);
87         $t->find_element_ok('//select[@id="crbd_list_of_checks_section_list_select"]//option[@value ="4"]', "xpath", "find checks for list")->click();
88         sleep(1);
90         $t->find_element_ok('next_step_design_information_button', 'id', 'go to next screen - Design Information')->click();
91         sleep(2);
93         # SCREEN 4 /Trail Linkage/
95         $t->find_element_ok('add_project_trial_sourced', 'id', "find add project trial sourced select")->click();
96         $t->find_element_ok('//select[@id="add_project_trial_sourced"]/option[contains(@value, "no")]', "xpath", "select project trial source option as 'no'")->click();
98         $t->find_element_ok('add_project_trial_will_be_genotyped', 'id', "find add project trial will be genotyped select")->click();
99         $t->find_element_ok('//select[@id="add_project_trial_will_be_genotyped"]/option[contains(@value, "no")]', "xpath", "select project trial will be genotyped option as 'no'")->click();
101         $t->find_element_ok('add_project_trial_will_be_crossed', 'id', "find project trial will be crossed select")->click();
102         $t->find_element_ok('//select[@id="add_project_trial_will_be_crossed"]/option[contains(@value, "no")]', "xpath", "select project trial will be crossed option as 'no'")->click();
104         $t->find_element_ok('next_step_trail_linkage_button', 'id', 'go to next screen - Trail Linkage')->click();
105         sleep(1);
107         # SCREEN 5 /Field map information/
108         $t->find_element_ok('fieldMap_row_number', 'id', "find field map row number input")->send_keys("1");
109         $t->find_element_ok('plot_layout_format', 'id', "find plot layout format select")->click();
110         $t->find_element_ok('//select[@id="plot_layout_format"]//option[contains(@value, "zigzag")]', "xpath", "find checks for list")->click();
112         $t->find_element_ok('next_step_field_map_button', 'id', 'go to next screen - Field map information')->click();
113         sleep(1);
115         # SCREEN 6 /Custom plot naming/
116         $t->find_element_ok('plot_prefix', 'id', "find plot prefix input")->send_keys("prefix_sel_");
117         $t->find_element_ok('start_number', 'id', "find plot start number select")->click();
118         $t->find_element_ok('//select[@id="start_number"]//option[contains(@value, "101")]', "xpath", "find checks for list")->click();
119         $t->find_element_ok('increment', 'id', "find plot number increment input")->send_keys("2");
121         $t->find_element_ok('new_trial_submit', 'id', 'go to next screen - Custom plot naming')->click();
122         sleep(20);
124         # SCREEN 7 /Review design/
125         $t->find_element_ok('redo_trial_layout_button', 'id', "find redo randomization and click button")->click();
126         sleep(20);
128         $t->find_element_ok('new_trial_confirm_submit', 'id', "find new trial confirm and submit")->click();
129         sleep(20);
131         # Very strange, but the only way to catch the complete trial button. Standard selectors without an extended XPath solution don't work.
132         $t->find_element_ok('create_trial_success_complete_button', 'id', "find success button after trial upload to database");
133         $t->find_element_ok('//div[@class="panel-body"]//div[@class="workflow-complete-message workflow-message-show"]//center//button[@id="create_trial_success_complete_button"]',
134                 'xpath', 'click complete button on last screen and finish a modal process')->click();
136         sleep(2);
138         $t->find_element_ok("refresh_jstree_html", "name", "refresh tree with new trial added")->click();
139         sleep(5);
141         $t->find_element_ok('//div[@id="trial_list"]//ul[@class="jstree-container-ul jstree-children"]//li//i[@class="jstree-icon jstree-ocl"]',
142                 'xpath', 'find a plus button to open a tree in test trails')->click();
143         sleep(2);
145         $t->find_element_ok("//a[contains(text(),\"$trail_name\")]", 'xpath', 'Confirm if trail exists in database and new tree after refresh')->click();
149 $t->driver->close();
150 done_testing();