start fixing test for multi cat phenotype upload.
[sgn.git] / t / selenium2 / breeders / upload_crosses_file.t
blob1767daad5b50ba23a609173ce610a8df0b802e72
1 use lib 't/lib';
3 use Test::More 'tests' => 76;
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 {
12     sleep(1);
14     # test for both excel formats xls and xlsx
15     for my $file ("crosses_plots_upload.xls", "crosses_plots_upload_selenium.xlsx") {
17         $t->get_ok('/breeders/crosses');
18         sleep(2);
20         $t->find_element_ok("upload_crosses_link", "name", "click on upload_crosses_link ")->click();
22         # SCREEN 1 /Intro/
23         $t->find_element_ok('next_step_intro_button', 'id', 'go to next screen - Intro')->click();
24         sleep(1);
26         # SCREEN 2 /Crossing experiment/
27         # with normal find_by_name method element cannot be find - that is why that strange double xpath structure
28         $t->find_element_ok('//div[@id="manage_page_section_1"]//button[@name="create_crossingtrial_link"]', 'xpath', 'find button to create a new experiment and click');
29         $t->find_element_ok('//div[@id="manage_page_section_1"]//button[@name="create_crossingtrial_link"]', 'xpath', 'find button to create a new experiment and click')->click();
30         sleep(2);
32         # Add New Crossing Experiment Intro/ modal
33         $t->find_element_ok('next_step_add_new_intro', 'id', 'go to next screen in Add New Experiment modal')->click();
35         # Add New Crossing Experiment Information/ modal
36         my $experiment_name = "Selenium_upload_cross_trial_$file";
37         $t->find_element_ok('crossingtrial_name', 'id', 'find "crossing trial name" input and give a name')->send_keys($experiment_name);
39         $t->find_element_ok('crossingtrial_program', 'id', 'find "crossing trial program" select input and click')->click();
40         sleep(1);
41         $t->find_element_ok('//select[@id="crossingtrial_program"]/option[text()="test"]', 'xpath', 'select "test" as value for crossing trial program')->click();
43         $t->find_element_ok('crossingtrial_location', 'id', 'find "crossing trial location" select input and click')->click();
44         sleep(1);
45         $t->find_element_ok('//select[@id="crossingtrial_location"]/option[@value="test_location"]', 'xpath', 'select "test_location" as value for crossing trial location')->click();
47         $t->find_element_ok('crosses_add_project_year_select', 'id', 'find "crossing trial year" select input and click')->click();
48         sleep(1);
49         $t->find_element_ok('//select[@id="crosses_add_project_year_select"]/option[@value="2018"]', 'xpath', 'select "2018" as value for crossing trial year')->click();
51         $t->find_element_ok('crosses_add_project_description', 'id', 'find "crossing trial description" input and give a description')->send_keys("Selenium_upload_cross_trial_description");
53         $t->find_element_ok('create_crossingtrial_submit', 'id', 'find and click "crossing trial submit" input and give a description')->click();
54         sleep(4);
56         # check if added successfully
57         my $trial_submit_info = $t->find_element_ok(
58             '//div[@id="add_crossing_trial_workflow"]//div[contains(@class, "workflow-complete-message")]',
59             'xpath',
60             'find feedback info after trial submition')->get_attribute('innerHTML');
62         ok($trial_submit_info =~ /Crossing experiment was added successfully/, "Verify feedback after submission, looking for: 'Crossing experiment was added successfully'");
64         $t->find_element_ok('add_crossing_experiment_dismiss_button_2', 'id', 'find and close "Add New Experiment" modal')->click();
65         sleep(1);
67         $t->find_element_ok('next_step_crossing_trial_button', 'id', 'go to next screen - Crossing experiment')->click();
68         sleep(2);
70         # SCREEN 3 /Upload your crosses/
71         $t->find_element_ok('upload_crosses_breeding_program_id', 'id', 'find "crossing trial program" select input and click')->click();
72         sleep(1);
73         $t->find_element_ok('//select[@id="upload_crosses_breeding_program_id"]/option[@title="test"]', 'xpath', 'select "test" as value for crossing experiment')->click();
74         sleep(2);
76         $t->find_element_ok('upload_crosses_crossing_experiment_id', 'id', 'find "crossing trial program" select input and click')->click();
77         sleep(1);
78         $t->find_element_ok("//select[\@id='upload_crosses_crossing_experiment_id']/option[\@title='$experiment_name']", 'xpath', "select '$experiment_name' as value for crossing experiment")->click();
80         $t->find_element_ok('cross_file_format_option', 'id', 'find "file format" select input and click')->click();
81         sleep(1);
82         $t->find_element_ok('//select[@id="cross_file_format_option"]/option[@value="xls_cross_plot"]', 'xpath', 'select "Excel (.xls) file with accession and plot names for parents" as value for crossing file format')->click();
83         sleep(1);
85         # File
86         my $upload_input = $t->find_element_ok("xls_crosses_plots_file", "id", "find file input");
87         my $filename = $f->config->{basepath} . "/t/data/cross/$file";
88         $t->driver()->upload_file($filename);
89         $upload_input->send_keys($filename);
91         $t->find_element_ok('upload_crosses_submit', 'id', 'find and "submit" uploaded cross file')->click();
92         sleep(5);
94         # Check if added successfully
95         my $cross_submit_info = $t->find_element_ok(
96             '//div[@id="crosses_upload_workflow"]',
97             'xpath',
98             'find feedback info after trial submition')->get_attribute('innerHTML');
100         ok($cross_submit_info =~ /The crosses file was uploaded successfully/, "Verify feedback after cross submission, looking for: 'The crosses file was uploaded successfully'");
102         $t->find_element_ok('upload_crosses_dismiss_button', 'name', 'find "close" modal button and click')->click();
103         sleep(2);
105         $t->find_element_ok("refresh_crosses_jstree_html_trialtree_button", "id", "find and click 'refresh crosses trial jstree'")->click();
106         sleep(10);
108         $t->find_element_ok('//div[@id="crosses_list"]//i[contains(@class, "jstree-icon")]', 'xpath', 'open a tree with crosses trial list')->click();
109         sleep(5);
111         my $href_to_trial = $t->find_element_ok("//div[\@id='crosses_list']//a[contains(text(), '$experiment_name')]", 'xpath', 'find created cross and take link href')->get_attribute('href');
113         $t->get_ok($href_to_trial);
114         sleep(3);
116         my $cross_table_content = $t->find_element_ok('parent_information', 'id', 'find table with parent information')->get_attribute('innerHTML');
118         ok($cross_table_content =~ /UG120001xUG120002/, "Verify info in the table: UG120001xUG120002");
119         ok($cross_table_content =~ /KASESE_TP2013_842/, "Verify info in the table: KASESE_TP2013_842");
120         ok($cross_table_content =~ /KASESE_TP2013_1591/, "Verify info in the table: KASESE_TP2013_1591");
121     }
124 $t->driver()->close();
125 done_testing();