start fixing test for multi cat phenotype upload.
[sgn.git] / t / selenium2 / breeders / create_genotyping_trial.t
blob933686ca32d5be1acb6db4e3d325aa00cbd635c3
2 use strict;
4 use lib 't/lib';
6 use Test::More 'tests' => 77;
8 use Data::Dumper;
9 use SGN::Test::WWW::WebDriver;
10 use SGN::Test::Fixture;
12 my $f = SGN::Test::Fixture->new();
13 my $t = SGN::Test::WWW::WebDriver->new();
15 $t->while_logged_in_as("submitter", sub {
16         sleep(1);
18         $t->get_ok('/breeders/genotyping_projects');
19         sleep(2);
21         # CREATE PROJECT FIRST
22         $t->find_element_ok("create_genotyping_project_link", "name", "find create genotyping project link abd click")->click();
23         sleep(1);
25         # SCREEN 1 /Intro/
26         $t->find_element_ok('next_step_add_new_genotyping_project', 'id', 'Next step from Into Screen find and click')->click();
27         sleep(2);
29         # SCREEN 2 /Genotyping Project/
30         my $project_name = "NEXTGENCASSAVA";
31         $t->find_element_ok('new_genotyping_project_name', 'id', 'find "genotyping project name" and click')->send_keys($project_name);
32         sleep(1);
34         $t->find_element_ok('genotyping_project_facility_select', 'id', 'find "genotyping project facility select" and click')->click();
35         sleep(1);
36         $t->find_element_ok('//select[@id="genotyping_project_facility_select"]/option[@value="None"]', 'xpath', 'Select "None" as value for genotyping project facility')->click();
38         $t->find_element_ok('data_type', 'id', 'find "genotyping project data_type" and click')->click();
39         sleep(1);
40         $t->find_element_ok('//select[@id="data_type"]/option[@value="snp"]', 'xpath', 'Select "snp" as value for genotyping data type')->click();
42         $t->find_element_ok('genotyping_project_breeding_program_select', 'id', 'find "genotyping breeding program select" and click')->click();
43         sleep(1);
44         $t->find_element_ok('//select[@id="genotyping_project_breeding_program_select"]/option[@title="test"]', 'xpath', 'Select "Breedbase" as title for genotyping data type')->click();
46         $t->find_element_ok('genotyping_project_year_select', 'id', 'find "genotyping project year" select and click')->click();
47         sleep(1);
48         $t->find_element_ok('//select[@id="genotyping_project_year_select"]/option[@title="2018"]', 'xpath', 'Select "2018" as value of project year')->click();
50         $t->find_element_ok('genotyping_project_location_select', 'id', 'find "genotyping project location" select and click')->click();
51         sleep(1);
52         $t->find_element_ok('//select[@id="genotyping_project_location_select"]/option[@title="test_location"]', 'xpath', 'Select "test_location" as value of project location')->click();
54         $t->find_element_ok('genotyping_project_description', 'id', 'find "genotyping project description" and fill')->send_keys("Selenium test genotyping project description");
56         $t->find_element_ok('add_new_genotyping_project_submit', 'id', 'New genotyping project submit button find and click')->click();
57         sleep(4);
59         $t->find_element_ok('add_new_genotyping_project_close_modal', 'id', 'New genotyping project close modal button find and click')->click();
60         sleep(1);
62     #manage genotyping projects
63     $t->find_element_ok("refresh_genotyping_project_jstree_html_button", "id", "find and click 'refresh genotyping project jstree'")->click();
64     sleep(5);
66     $t->find_element_ok('//div[@id="genotyping_project_list"]//i[contains(@class, "jstree-icon")]', 'xpath', 'open a tree with genotyping project list')->click();
67     sleep(5);
69     my $href_to_trial = $t->find_element_ok("//div[\@id='genotyping_project_list']//a[contains(text(), '$project_name')]", 'xpath', 'find created project and take link href')->get_attribute('href');
71     $t->get_ok($href_to_trial);
72     sleep(5);
74         # test uploading genotyping plate for both excel formats xls and xlsx
75         my @files = (["NEW_CASSAVA_GS_74Template.xls", "2018TestPlate02"], ["NEW_CASSAVA_GS_74Template_selenium.xlsx", "2018TestPlate03"]);
76         for my $index (0 .. $#files) {
78                 my $plate_name = $files[$index][1];
79                 my $excel_file_name = $files[$index][0];
81                 $t->get_ok('/breeders/genotyping_projects');
82                 sleep(2);
84                 # CREATE TRIAL
85                 $t->find_element_ok("create_genotyping_trial_link", "name", "find create genotyping trial link abd click")->click();
86                 sleep(1);
88                 # SCREEN 1 /Intro/
89                 $t->find_element_ok('next_step_intro_button', 'id', 'go to next screen - Intro')->click();
90                 sleep(1);
92                 # SCREEN 2 /Genotyping Project/
93                 $t->find_element_ok('next_step_creating_genotyping_plates', 'id', 'go to next screen - Genotyping Project')->click();
94                 sleep(1);
96                 # SCREEN 3 /Basic Plate Info/
97                 $t->find_element_ok('plate_genotyping_project_id', 'id', 'find "genotyping trial facility select" and click')->click();
98                 sleep(1);
100                 $t->find_element_ok("//select[\@id=\"plate_genotyping_project_id\"]/option[\@title='$project_name']", 'xpath', "Select $project_name as value for genotyping project facility")->click();
102                 $t->find_element_ok('genotyping_trial_name', 'id', 'find "genotyping trial name" and click')->send_keys($plate_name);
104                 $t->find_element_ok('genotyping_trial_plate_format', 'id', 'find "genotyping trial plate format" select and click')->click();
105                 sleep(1);
106                 $t->find_element_ok('//select[@id="genotyping_trial_plate_format"]/option[@value="96"]', 'xpath', 'Select "96" as value for genotyping trial plate format')->click();
108                 $t->find_element_ok('genotyping_trial_plate_sample_type', 'id', 'find "genotyping trial plate sample type" select and click')->click();
109                 sleep(1);
110                 $t->find_element_ok('//select[@id="genotyping_trial_plate_sample_type"]/option[@value="DNA"]', 'xpath', 'Select "DNA" as value for plate sample type')->click();
112                 $t->find_element_ok('genotyping_trial_description', 'id', 'find "genotyping trial description" and fill')->send_keys("Selenium test plate description");
113                 $t->find_element_ok('plate_info_intro_button', 'id', 'go to next screen - Basic Plate Info')->click();
115                 # SCREEN 4 /Well Info/
116                 $t->find_element_ok('genotyping_trial_well_input_option', 'id', 'find "genotyping trial well input" select and click')->click();
117                 sleep(1);
118                 $t->find_element_ok('//select[@id="genotyping_trial_well_input_option"]/option[@value="xlsx"]', 'xpath', 'Select "xlsx" as value of trial well input formal (Excel)')->click();
119                 sleep(2);
121                 my $file_upload = $t->find_element_ok("genotyping_trial_layout_upload", "id", "find trial file upload button");
122                 my $filename = $f->config->{basepath} . "/t/data/genotype_trial_upload/$excel_file_name";
123                 my $remote_filename = $t->driver()->upload_file($filename);
124                 $file_upload->send_keys($filename);
126                 $t->find_element_ok('well_info_intro_button', 'id', 'go to next screen - Well Info')->click();
127                 sleep(1);
129                 # SCREEN 5 /Trial Linkage/
130                 $t->find_element_ok('trial_linkage_intro_button', 'id', 'go to next screen - Well Info')->click();
131                 sleep(1);
133                 # SCREEN 6 /Confirm/
134                 $t->find_element_ok('add_geno_trial_submit', 'id', 'find "submit genotyping trial" and click')->click();
135                 sleep(40);
137                 $t->driver()->accept_alert();
138                 $t->find_element_ok('close_trial_button', 'id', 'find "close trial button" and click')->click();
139                 sleep(3);
141         #New genotyping plate ID
142         my $genotyping_plate_id = $f->bcs_schema->resultset('Project::Project')->find({ name => $plate_name })->project_id();
143         $t->get_ok('/breeders/trial/' . $genotyping_plate_id);
144         sleep(5);
146         my $trial_table_content = $t->find_element_ok('trial_plate_view_table', 'id', 'find table with created trial data')->get_attribute('innerHTML');
147         ok($trial_table_content =~ /\Q${plate_name}_F07/, "Verify sample id in a table: ${plate_name}_F07");
148         ok($trial_table_content =~ /\Q${plate_name}_B04/, "Verify sample id in a table: ${plate_name}_B04");
149         ok($trial_table_content =~ /test_accession1/, "Verify accession id in a table: test_accession1");
151         my $trial_plate_layout = $t->find_element_ok('trial_plate_layout_table', 'id', 'find table with plate layout')->get_attribute('innerHTML');
153         ok($trial_table_content =~ /A01/, "Verify well id in a table: A01");
154         ok($trial_table_content =~ /A05/, "Verify well id in a table: A05");
155     }
158 $t->driver()->close();
159 done_testing();