5 use Test::More 'tests' => 110;
7 use SGN::Test::WWW::WebDriver;
8 use Selenium::Remote::WDKeys 'KEYS';
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 {
17 $t->get_ok('/breeders/search');
20 # COLUMN 1 WIZARD SEARCH - test list select / search - select trials
21 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[1]', 'xpath', 'find select column type in first column')->click();
23 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[1]//option[@value="trials"]', 'xpath', 'find and select "trials" in first column')->click();
25 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"])[2]//input[contains(@class, "wizard-search")]' , 'xpath', 'find a search box and type "Kasese solgs trial"')->send_keys('Kasese solgs trial');
28 # COLUMN 1 WIZARD SEARCH - check if only "Kasese solgs trial" is in unselect panel field
29 my $search_unselected = $t->find_element_ok(
30 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-unselected")]',
32 'find a content of "unselected trials panel" to test searchbox in first column')->get_attribute('innerHTML');
34 ok($search_unselected =~ /Kasese solgs trial/, "Verify if unselected panel after search contain: 'Kasese solgs trial'");
35 ok($search_unselected !~ /CASS_6Genotypes_Sampling_2015/, "Verify if unselected panel after search NOT contain: 'CASS_6Genotypes_Sampling_2015'");
36 ok($search_unselected !~ /trial2 NaCRRI/, "Verify if unselected panel after search NOT contain: 'trial2 NaCRRI'");
39 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]//a[contains(text(), "Kasese solgs trial")]//preceding-sibling::button' , 'xpath', 'find and add "Kasese solgs trial" trial in first column with search filter active')->click();
41 # COLUMN 2 WIZARD SEARCH - test list select / search - select trials
42 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[2]', 'xpath', 'find select column type in second column')->click();
44 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[2]//option[@value="traits"]', 'xpath', 'find and select "traits" in second column')->click();
46 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[2]//a[contains(text(), "dry matter content percentage|CO_334:0000092")]//preceding-sibling::button' , 'xpath', 'find and add "dry matter content percentage|CO_334:0000092" trait in second column')->click();
49 # COLUMN 1 AND 2 - test for all / any / default values / check if numbers off possible combinations are changing
50 my $active_union_button = $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/div[contains(@class, "wizard-union-toggle")]/div[contains(@class, "wizard-union-toggle-btn-group")]/button[contains(@class, "active")]' , 'xpath', 'find active union button in first column');
51 ok (lc($active_union_button->get_attribute('innerHTML')) eq "any", "default active union button for selection shall be ANY");
53 my $button_count_all_second_column_xpath = '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[2]/div/div[@class="btn-group"]//span[contains(@class, "wizard-count-all")]';
55 my $button_count_all_second_column = $t->find_element_ok($button_count_all_second_column_xpath , 'xpath', 'find count traits field pointer');
56 ok ($button_count_all_second_column->get_text() eq "3", "number of traits with 'ANY button' in second panel from 'Kasese solgs trial' should be 3");
58 my $search_column_1 = $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"])[2]//input[contains(@class, "wizard-search")]' , 'xpath', 'find search input in first column and clear it, for union test');
59 $search_column_1->send_keys(KEYS->{'control'}, 'a');
60 $search_column_1->send_keys(KEYS->{'backspace'});
63 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]//a[contains(text(), "trial2 NaCRRI")]//preceding-sibling::button' , 'xpath', 'find and select "trial2 NaCRRI" in first column')->click();
66 my $unselected_traits_second_column_xpath = '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[2]/ul[contains(@class, "wizard-list-unselected")]';
68 my $unselected_traits_content = $t->find_element_ok($unselected_traits_second_column_xpath, 'xpath', 'find content of unselected list from second column')->get_attribute('innerHTML');
69 ok ($unselected_traits_content =~ /harvest index variable|CO_334:0000015/, 'find new trait for two trials and ANY union "harvest index variable|CO_334:0000015"');
71 $button_count_all_second_column = $t->find_element_ok($button_count_all_second_column_xpath , 'xpath', 'find count traits field pointer');
72 ok ($button_count_all_second_column->get_text() eq "4", "number of traits with 'ANY button' in second panel from 'Kasese solgs trial' and 'trial2 NaCRRI' should be 4");
74 my $all_union_button = $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/div[contains(@class, "wizard-union-toggle")]/div[contains(@class, "wizard-union-toggle-btn-group")]/button[contains(text(), "ALL")]' , 'xpath', 'find "ALL" button');
75 my $any_union_button = $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/div[contains(@class, "wizard-union-toggle")]/div[contains(@class, "wizard-union-toggle-btn-group")]/button[contains(text(), "ANY")]' , 'xpath', 'find "ANY" button');
77 $all_union_button->click();
79 $button_count_all_second_column = $t->find_element_ok($button_count_all_second_column_xpath , 'xpath', 'find count traits field pointer');
80 ok ($button_count_all_second_column->get_text() eq "3", "ALL traits in second panel from 'Kasese solgs trial' and 'trial2 NaCRRI' should be 3");
82 $unselected_traits_content = $t->find_element_ok($unselected_traits_second_column_xpath, 'xpath', 'find content of unselected list from second column"')->get_attribute('innerHTML');
83 ok ($unselected_traits_content !~ /harvest index variable|CO_334:0000015/, '"harvest index variable|CO_334:0000015" trait for two trials and ALL union cannot be displayed in unselected traits');
85 $any_union_button->click();
87 $button_count_all_second_column = $t->find_element_ok($button_count_all_second_column_xpath , 'xpath', 'find count traits field pointer');
88 ok ($button_count_all_second_column->get_text() eq "4", "ANY traits in second panel from 'Kasese solgs trial' and 'trial2 NaCRRI' should be 4");
90 $unselected_traits_content = $t->find_element_ok($unselected_traits_second_column_xpath, 'xpath', 'find content of unselected list from second column"')->get_attribute('innerHTML');
91 ok ($unselected_traits_content =~ /harvest index variable|CO_334:0000015/, '"harvest index variable|CO_334:0000015" trait for two trials and ANY union shall be displayed in unselected traits');
93 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-selected wizard-list")]//a[contains(text(), "trial2 NaCRRI")]//preceding-sibling::button' , 'xpath', 'first select')->click();
95 $unselected_traits_content = $t->find_element_ok($unselected_traits_second_column_xpath, 'xpath', 'find content of unselected list from second column"')->get_attribute('innerHTML');
96 ok ($unselected_traits_content !~ /harvest index variable|CO_334:0000015/, '"harvest index variable|CO_334:0000015" trait for one trial after "trial2 NaCRRI" removed should not be displayed in unselected traits');
98 # COLUMN 3 WIZARD SEARCH - select years and save first dataset with 3 list
99 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[3]', 'xpath', 'find select column type in third column')->click();
100 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[3]//option[@value="years"]', 'xpath', 'find and select "years" in third column')->click();
101 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[3]//a[contains(text(), "2014")]//preceding-sibling::button' , 'xpath', 'find and add "2014" year in third column')->click();
104 my $dataset_name_input = $t->find_element_ok('input[placeholder="Create New Dataset"]', 'css', 'find dataset name input field');
105 $dataset_name_input->send_keys(KEYS->{'control'}, 'a');
106 $dataset_name_input->send_keys(KEYS->{'backspace'});
109 my $dataset_name_1 = "another_dataset_3_columns";
110 $dataset_name_input->send_keys($dataset_name_1);
111 $t->find_element_ok('//input[@placeholder="Create New Dataset"]/parent::div//button[contains(text(), "Create")]', 'xpath', "find 'create' button and create dataset $dataset_name_1")->click;
113 $t->driver()->accept_alert();
115 # COLUMN 4 WIZARD SEARCH - select accessions and save second dataset
116 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[4]', 'xpath', 'find select column type in fourth column')->click();
118 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[4]//option[@value="accessions"]', 'xpath', 'find and select "accessions" in fourth column')->click();
120 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[4]//a[contains(text(), "UG120001")]//preceding-sibling::button' , 'xpath', 'find and add "UG120001" year in fourth column')->click();
123 $dataset_name_input = $t->find_element_ok('input[placeholder="Create New Dataset"]', 'css', 'find dataset name input field and clear content');
124 $dataset_name_input->send_keys(KEYS->{'control'}, 'a');
125 $dataset_name_input->send_keys(KEYS->{'backspace'});
128 my $dataset_name_2 = "another_dataset_4_columns";
129 $dataset_name_input->send_keys($dataset_name_2);
130 $t->find_element_ok('//input[@placeholder="Create New Dataset"]/parent::div//button[contains(text(), "Create")]', 'xpath', "find 'create' button and create dataset $dataset_name_2")->click();
132 $t->driver()->accept_alert();
135 # SAVE A LIST FROM COLUMN 1
136 my $first_list_name = "trials_list";
138 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[1]//input[contains(@class, "wizard-create-list-name")]',
140 'find a "list name" for first column and fill a name')->click();
143 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[1]//input[contains(@class, "wizard-create-list-name")]',
145 "fill '$first_list_name' as list name in first column")->send_keys($first_list_name);
148 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[1]//button[contains(text(), "Create")]',
150 "find a 'create list' in first columns button and click")->click();
152 $t->driver()->accept_alert();
154 # SAVE A LIST FROM COLUMN 2
155 my $second_list_name = "traits_list";
157 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[2]//input[contains(@class, "wizard-create-list-name")]',
159 'find a "list name" for second column and fill a name')->click();
162 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[2]//input[contains(@class, "wizard-create-list-name")]',
164 "fill '$second_list_name' as list name in second column")->send_keys($second_list_name);
167 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[2]//button[contains(text(), "Create")]',
169 "find a 'create list' in second columns button and click")->click();
171 $t->driver()->accept_alert();
173 # SAVE A LIST FROM COLUMN 3
174 my $third_list_name = "years_list";
177 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[3]//input[contains(@class, "wizard-create-list-name")]',
179 'find a "list name" for third column and fill a name')->click();
182 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[3]//input[contains(@class, "wizard-create-list-name")]',
184 "fill '$third_list_name' as list name in third column")->send_keys($third_list_name);
187 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[3]//button[contains(text(), "Create")]',
189 "find a 'create list' in third columns button and click")->click();
191 $t->driver()->accept_alert();
193 # SAVE A LIST FROM COLUMN 4
194 my $fourth_list_name = "acc_list";
196 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[4]//input[contains(@class, "wizard-create-list-name")]',
198 'find a "list name" for fourth column and fill a name')->click();
201 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[4]//input[contains(@class, "wizard-create-list-name")]',
203 "fill '$fourth_list_name' as list name in fourth column")->send_keys($fourth_list_name);
206 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[4]//button[contains(text(), "Create")]',
208 "find a 'create list' in fourth columns button and click")->click();
210 $t->driver()->accept_alert();
212 # RELOAD PAGE AND LOAD DATASET_3_COLUMNS
213 $t->get_ok('/breeders/search');
217 '//select[contains(@class, "wizard-dataset-select")]',
219 'find a "select input" for datasets to load and click')->click();
223 "//select[contains(\@class, 'wizard-dataset-select')]/optgroup/option[contains(text(), '$dataset_name_1')]",
225 "find a dataset name: $dataset_name_1 in select input and click")->click();
228 '//div[contains(@class, "wizard-datasets")]//button[contains(@class, "wizard-dataset-load")]',
230 'find a load button for selected dataset and click')->click();
233 # unselected 1 column
234 my $unselected_reloaded_elements = $t->find_element_ok(
235 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-unselected")]',
237 "find content of unselected list from first column")->get_attribute('innerHTML');
239 ok($unselected_reloaded_elements =~ /CASS_6Genotypes_Sampling_2015/, "Verify first column wizard, unselected after load $dataset_name_1: CASS_6Genotypes_Sampling_2015");
240 ok($unselected_reloaded_elements =~ /trial2 NaCRRI/, "Verify first column wizard, unselected after load $dataset_name_1: trial2 NaCRRI");
243 my $selected_reloaded_elements = $t->find_element_ok(
244 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-selected wizard-list")]',
246 "find content of selected list from first column")->get_attribute('innerHTML');
248 ok($selected_reloaded_elements =~ /Kasese solgs trial/, "Verify first column wizard, selected after load $dataset_name_1: Kasese solgs trial");
250 # unselected 2 column
251 my $unselected_reloaded_elements = $t->find_element_ok(
252 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[2]/ul[contains(@class, "wizard-list-unselected")]',
254 "find content of unselected list from second column")->get_attribute('innerHTML');
256 ok($unselected_reloaded_elements =~ /fresh root weight|CO_334:0000012/, "Verify second column wizard, unselected after load $dataset_name_1: fresh root weight|CO_334:0000012");
257 ok($unselected_reloaded_elements =~ /fresh shoot weight measurement in kg|CO_334:0000016/, "Verify second column wizard, unselected after load $dataset_name_1: fresh shoot weight measurement in kg|CO_334:0000016");
260 my $selected_reloaded_elements = $t->find_element_ok(
261 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[2]/ul[contains(@class, "wizard-list-selected wizard-list")]',
263 "find content of selected list from second column")->get_attribute('innerHTML');
265 ok($selected_reloaded_elements =~ /dry matter content percentage|CO_334:0000092/, "Verify second column wizard, selected after load $dataset_name_1: dry matter content percentage|CO_334:0000092");
268 my $selected_reloaded_elements = $t->find_element_ok(
269 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[3]/ul[contains(@class, "wizard-list-selected wizard-list")]',
271 "find content of selected list from third column")->get_attribute('innerHTML');
273 ok($selected_reloaded_elements =~ /2014/, "Verify third column wizard, selected after load $dataset_name_1: 2014");
275 # RELOAD PAGE AND LOAD DATASET_4_COLUMNS
276 $t->get_ok('/breeders/search');
280 '//select[contains(@class, "wizard-dataset-select")]',
282 'find a select input for datasets to load and click')->click();
286 "//select[contains(\@class, 'wizard-dataset-select')]/optgroup/option[text()='$dataset_name_2']",
288 "find a dataset name: $dataset_name_2 in select input and click")->click();
292 '//div[contains(@class, "wizard-datasets")]//button[contains(@class, "wizard-dataset-load")]',
294 'find a load button for selected dataset and click')->click();
297 # unselected 4 column
298 my $unselected_reloaded_elements = $t->find_element_ok(
299 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[4]/ul[contains(@class, "wizard-list-unselected")]',
301 "find content of unselected list from fourth column")->get_attribute('innerHTML');
303 ok($unselected_reloaded_elements =~ /UG120002/, "Verify last column wizard, unselected after load $dataset_name_2: UG120002");
304 ok($unselected_reloaded_elements =~ /UG120003/, "Verify last column wizard, unselected after load $dataset_name_2: UG120003");
305 ok($unselected_reloaded_elements =~ /UG120007/, "Verify last column wizard, unselected after load $dataset_name_2: UG120007");
308 my $selected_reloaded_elements = $t->find_element_ok(
309 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[4]/ul[contains(@class, "wizard-list-selected wizard-list")]',
311 "find content of selected list from fourth column")->get_attribute('innerHTML');
313 ok($selected_reloaded_elements =~ /UG120001/, "Verify last column wizard, selected after load $dataset_name_2: UG120001");
315 # RELOAD PAGE AND LOAD A LIST OF TRAILS
316 $t->get_ok('/breeders/search');
319 # RELOAD PAGE AND LOAD A LIST OF TRAILS
320 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[1]', 'xpath', 'find select column type in first column')->click();
324 "(//div[\@id='wizard']/span/span/div/div/div[\@class='panel-heading']/select)[1]/optgroup/option[text()='$fourth_list_name']",
326 "find and select '$fourth_list_name' in first column")->click();
329 # selected 1 column - 2 new accessions and 1 old
330 $selected_reloaded_elements = $t->find_element_ok(
331 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-selected wizard-list")]',
333 "find content of selected list from first column")->get_attribute('innerHTML');
335 ok($selected_reloaded_elements =~ /UG120001/, "Verify first column wizard, selected after load $fourth_list_name: accession UG120001");
337 # ADD TO LIST FUNCTIONALITY
338 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[1]', 'xpath', 'find select column type in first column')->click();
342 "(//div[\@id='wizard']/span/span/div/div/div[\@class='panel-heading']/select)[1]//option[\@value='accessions']", 'xpath', 'find and select "accessions" in first column')->click();
345 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]//a[contains(text(), "IITA-TMS-IBA011412")]//preceding-sibling::button' , 'xpath', 'find and add "IITA-TMS-IBA011412" accessions in first column')->click();
346 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]//a[contains(text(), "IITA-TMS-IBA30572")]//preceding-sibling::button' , 'xpath', 'find and add "IITA-TMS-IBA30572" accessions in first column')->click();
350 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[1]//select[contains(@class, "wizard-add-to-list")]',
352 'find a add to list select for first column')->click();
356 "(//div[\@id='wizard']/span/span/div/div/table[contains(\@class, 'wizard-save-to-list')])[1]//select[contains(\@class, 'wizard-add-to-list')]/optgroup/option[text()='$fourth_list_name']",
358 "find a $fourth_list_name on lists name and select")->click();
361 '(//div[@id="wizard"]/span/span/div/div/table[contains(@class, "wizard-save-to-list")])[1]//button[contains(@class, "wizard-add-to-list")]',
363 'find a button "add to list" and click')->click();
365 $t->driver()->accept_alert();
367 $t->driver()->accept_alert();
369 # reload to check a new acc_list with two extra accessions
370 $t->get_ok('/breeders/search');
373 # COLUMN 1 WIZARD SEARCH - load saved list with accessions acc_list
374 $t->find_element_ok('(//div[@id="wizard"]/span/span/div/div/div[@class="panel-heading"]/select)[1]', 'xpath', 'find select column type in first column')->click();
378 "(//div[\@id='wizard']/span/span/div/div/div[\@class='panel-heading']/select)[1]/optgroup/option[text()='$fourth_list_name']",
380 "find and select '$fourth_list_name' in first column")->click();
384 $selected_reloaded_elements = $t->find_element_ok(
385 '(//div[@id="wizard"]/span/span/div/div/div[@class="panel-body"])[1]/ul[contains(@class, "wizard-list-selected wizard-list")]',
387 "find content of selected list from first column")->get_attribute('innerHTML');
389 ok($selected_reloaded_elements =~ /UG120001/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession UG120001");
390 ok($selected_reloaded_elements =~ /IITA-TMS-IBA011412/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA011412");
391 ok($selected_reloaded_elements =~ /IITA-TMS-IBA30572/, "Verify first column wizard, selected elements, after merging $fourth_list_name and two new elements: accession IITA-TMS-IBA30572");
394 $t->get_ok('/breeders/search');
398 '//select[contains(@class, "wizard-dataset-select")]',
400 'find a select input for datasets to delete and click')->click();
404 "//select[contains(\@class, 'wizard-dataset-select')]/optgroup/option[contains(text(), '$dataset_name_1')]",
406 "find a dataset name: $dataset_name_1 in select input and click")->click();
409 '//div[contains(@class, "wizard-datasets")]//button[contains(@class, "wizard-dataset-delete")]',
411 'find a "delete" dataset button for selected dataset and click')->click();
413 $t->driver()->accept_alert();
415 $t->driver()->accept_alert();
417 # TEST DATASET WAS DELETED
418 $t->get_ok('/breeders/search');
421 my $datasets_list = $t->find_element_ok(
422 '//select[contains(@class, "wizard-dataset-select")]',
424 'find a select input for datasets to delete and click')->get_attribute('innerHTML');
427 ok($datasets_list =~ /$dataset_name_2/, "Verify if datasets list after 'delete' contain $dataset_name_2");
428 ok($datasets_list !~ /$dataset_name_1/, "Verify if datasets list after 'delete' NOT contain $dataset_name_1");
435 $t->driver()->close();