working on tests
[sgn.git] / t / selenium2 / 02_trial / trial_detail.t
blobdf2e4c0dd66843dc790c1105e5935725d69ea471
1 use lib 't/lib';
3 use Test::More;
5 use SGN::Test::WWW::WebDriver;
6 use SGN::Test::Fixture;
7 my $t = SGN::Test::WWW::WebDriver->new();
8 my $f = SGN::Test::Fixture->new();
10     $t->login_as("curator");
11     #Upload New Trial
12     $t->get_ok('/breeders/trials');
13     my $refresh_tree = $t->find_element_ok("refresh_jstree_html_trialtree_button", "id", "refresh tree")->click();
14     sleep(3);
15     $t->find_element_ok("upload_trial_link", "id", "click on upload_trial_link ")->click();
16     sleep(2);
17     my $program_select = $t->find_element_ok("trial_upload_breeding_program", "id", "find breeding program select");
18     $program_select->send_keys('test');
19     my $location_select = $t->find_element_ok("trial_upload_location", "id", "find location select");
20     $location_select->send_keys('test_location');
21     my $trial_name = $t->find_element_ok("trial_upload_name", "id", "find trial name input");
22     $trial_name->send_keys('T100');
23     my $trial_year = $t->find_element_ok("trial_upload_year", "id", "find trial year input");
24     $trial_year->send_keys('2016');
25     my $trial_description = $t->find_element_ok("trial_upload_description", "id", "find trial description input");
26     $trial_description->send_keys('T100 trial test description');
27     my $trial_design = $t->find_element_ok("trial_upload_design_method", "id", "find trial design select");
28     $trial_design->send_keys('Completely Randomized');
29     my $upload_input = $t->find_element_ok("trial_uploaded_file", "id", "find file input");
30     my $filename = $f->config->{basepath}."/t/data/trial/T100_trial_layout.xls";
31     my $remote_filename = $t->driver()->upload_file($filename);
32     $upload_input->send_keys($filename);
33     sleep(1);
34     $t->find_element_ok("upload_trial_submit", "id", "submit upload trial file ")->click();
35     sleep(5);
37     $t->find_element_ok("close_trial_upload_success_dialog", "id", "success msg")->click();
38     sleep(1);
39     $t->find_element_ok("close_trial_upload_dialog", "id", "close trial upload dialog")->click();
40     sleep(1);
42     my $refresh_tree = $t->find_element_ok("refresh_jstree_html_trialtree_button", "id", "refresh tree")->click();
43     sleep(3);
44     my $open_tree = $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
45     sleep(2);
46     my $open_tree = $t->find_element_ok("T100", "partial_link_text", "open up tree")->click();
48     my $trial_id = $f->bcs_schema->resultset('Project::Project')->search({name=>'T100'}, {order_by => { -desc => 'project_id'}})->first->project_id();
50     #Upload Trial Coordinates -> New Trial ID 144
51     $t->get_ok('/breeders/trial/'.$trial_id);
52     sleep(10);
53     $t->find_element_ok("upload_trial_coords_link", "id", "click on upload_trial_coords_link ")->click();
54     sleep(2);
55     my $upload_input = $t->find_element_ok("trial_coordinates_uploaded_file", "id", "find file input");
56     my $filename = $f->config->{basepath}."/t/data/trial/T100_trial_coords.csv";
57     my $remote_filename = $t->driver()->upload_file($filename);
58     $upload_input->send_keys($filename);
59     sleep(1);
60     $t->find_element_ok("upload_trial_coords_ok_button", "id", "submit upload trial coords file ")->click();
61     sleep(2); 
62     $t->find_element_ok("dismiss_trial_coord_upload_dialog", "id", "close success msg")->click();
63     sleep(3);    
64     $t->find_element_ok("physical_layout_onswitch", "id", "view field map ")->click();
65     sleep(6);
66     $t->find_element_ok("physical_layout_offswitch", "id", "view field map ")->click();
67     sleep(2);
69     #Verify Trial Info
70     
71     sleep(3);
72     $t->find_element_ok("//div[contains(., 'T100')]", "xpath", "verify trial name")->get_text();
73     $t->find_element_ok("//div[contains(., 'test')]", "xpath", "verify breeding program")->get_text();
74     $t->find_element_ok("//div[contains(., 'test_location')]", "xpath", "verify trial location")->get_text();
75     $t->find_element_ok("//div[contains(., '2016')]", "xpath", "verify trial year")->get_text();
76     $t->find_element_ok("//div[contains(., '[Type not set]')]", "xpath", "verify trial type")->get_text();
77     $t->find_element_ok("//div[contains(., '[No Planting Date]')]", "xpath", "verify planting date")->get_text();
78     $t->find_element_ok("//div[contains(., '[No Harvest Date]')]", "xpath", "verify harvest date")->get_text();
79     $t->find_element_ok("//div[contains(., 'T100 trial test description')]", "xpath", "verify description")->get_text();
81     #Verify Trial Design
82     $t->find_element_ok("//div[contains(., 'CRD')]", "xpath", "verify design type")->get_text();
83     $t->find_element_ok("//div[contains(., '2')]", "xpath", "verify number of blocks")->get_text();
84     $t->find_element_ok("//div[contains(., '2')]", "xpath", "verify number of blocks")->get_text();
85     $t->find_element_ok("//div[contains(., 'undefined')]", "xpath", "verify plants per plot")->get_text();
86     $t->find_element_ok("trial_accessions_onswitch", "id", "view trial accessions")->click();
87     sleep(5);
88     $t->find_element_ok("test_accession1", "partial_link_text", "verify accessions");
89     $t->find_element_ok("test_accession2", "partial_link_text", "verify accessions");
90     $t->find_element_ok("test_accession3", "partial_link_text", "verify accessions");
91     $t->find_element_ok("test_accession4", "partial_link_text", "verify accessions");
92      $t->find_element_ok("trial_controls_onswitch", "id", "view trial controls")->click();
93      sleep(5);
94     $t->find_element_ok("test_accession2", "partial_link_text", "verify controls");
95     $t->find_element_ok("test_accession3", "partial_link_text", "verify controls");
96     $t->find_element_ok("trial_plots_onswitch", "id", "view trial plots")->click();
97     sleep(5);
98     $t->find_element_ok("plot_select_all", "id", "select plots")->click();
99     sleep(1);
100     $t->find_element_ok("plot_data_new_list_name", "id", "find add list input");
102     my $add_list_input = $t->find_element_ok("plot_data_new_list_name", "id", "find add list input test");
103    
104     $add_list_input->send_keys("plots_list");
106     $t->find_element_ok("plot_data_add_to_new_list", "id", "find add list button")->click();
107     sleep(1);
108     $t->accept_alert_ok();
109     sleep(1);
110     my $out = $t->find_element_ok("lists_link", "name", "find lists_link")->click();
111     sleep(3);
112     $t->find_element_ok("close_list_dialog_button", "id", "find close dialog button")->click();
114     $t->find_element_ok("//div[contains(., 'T100_plot_01')]", "xpath", "verify plots")->get_text();
115     $t->find_element_ok("//div[contains(., 'T100_plot_02')]", "xpath", "verify plots")->get_text();
116     $t->find_element_ok("//div[contains(., 'T100_plot_03')]", "xpath", "verify plots")->get_text();
117     $t->find_element_ok("//div[contains(., 'T100_plot_04')]", "xpath", "verify plots")->get_text();
118     $t->find_element_ok("//div[contains(., 'T100_plot_05')]", "xpath", "verify plots")->get_text();
119     $t->find_element_ok("//div[contains(., 'T100_plot_06')]", "xpath", "verify plots")->get_text();
120     $t->find_element_ok("//div[contains(., 'T100_plot_07')]", "xpath", "verify plots")->get_text();
121     $t->find_element_ok("//div[contains(., 'T100_plot_08')]", "xpath", "verify plots")->get_text();
124     $t->find_element_ok("//div[contains(., 'test')]", "xpath", "verify breeding program")->get_text();
126     $t->find_element_ok("//div[contains(., 'T100')]", "xpath", "verify trial name")->get_text();
128     $t->find_element_ok("//div[contains(., '2016')]", "xpath", "verify trial type")->get_text();
130     $t->find_element_ok("//div[contains(., 'test_location')]", "xpath", "verify trial location")->get_text();
132     $t->find_element_ok("//div[contains(., 'T100 trial test description')]", "xpath", "verify desc")->get_text();
139 done_testing();