start fixing test for multi cat phenotype upload.
[sgn.git] / t / selenium2 / breeders / pedigree_download.t
blob156549d7cefaa325d8e7da0eb06d8e02bccdf28e
1 use lib 't/lib';
3 use Test::More 'tests' => 31;
5 use SGN::Test::WWW::WebDriver;
6 use SGN::Test::Fixture;
7 use Selenium::Remote::WDKeys 'KEYS';
9 my $f = SGN::Test::Fixture->new();
11 my $t = SGN::Test::WWW::WebDriver->new();
13 $t->while_logged_in_as("submitter", sub {
14     sleep(1);
16     $t->get_ok('/breeders/accessions');
17     sleep(2);
19     $t->find_element_ok("lists_link", "name", "find lists_link")->click();
21     my $random_val = int(rand(1000));
22     my $list_name = sprintf("pedigree_accessions_%d", $random_val);
23     $t->find_element_ok("add_list_input", "id", "find add list input test")->send_keys($list_name);
25     $t->find_element_ok("add_list_button", "id", "find add list button test")->click();
27     $t->find_element_ok("view_list_$list_name", "id", "view list test")->click();
28     sleep(2);
30     $t->find_element_ok(
31         "updateListDescField",
32         "id",
33         "add type of list")->send_keys("pedigree_accessions_for_selenium_tests");
35     $t->find_element_ok("type_select", "id", "add type of list")->click();
36     sleep(2);
38     $t->find_element_ok('option[name="accessions"]', "css", "select type 'accessions' from a list")->click();
39     sleep(2);
41     $t->find_element_ok("dialog_add_list_item", "id", "add test list")->send_keys("TMS14F1001P0001\nTMS14F1006P0001\nTMS14F1008P0004\nTMS14F1011P0002\nTMS14F1013P0005\nTMS13F1303P0001\nTMS13F1020P0002\nTMS13F1307P0011\nTMS13F1307P0020\nTMS13F1288P0009\nTMS13F1108P0007\n");
42     sleep(1);
44     $t->find_element_ok("dialog_add_list_item_button", "id", "find dialog_add_list_item_button test")->click();
46     $t->find_element_ok("close_list_item_dialog", "id", "find close_list_item_dialog button test")->click();
48     $t->find_element_ok("close_list_dialog_button", "id", "find close dialog button and click")->click();
50     $t->get_ok('/breeders/accessions');
51     sleep(1);
53     my $add_accessions_link = $t->find_element_ok(
54         "add_accessions_link",
55         "name",
56         "find element add accessions link as submitter");
57     $add_accessions_link->click();
58     sleep(1);
60     $t->find_element_ok("list_div_list_select", "id", "select new list test")->click();
61     $t->find_element_ok("//select[\@id='list_div_list_select']//option[contains(text(),\"$list_name\")]", 'xpath', "select $list_name option")->click();
62     sleep(1);
64     $t->find_element_ok("new_accessions_submit", "id", "submit new accessions")->click();
65     sleep(7);
67     $t->find_element_ok("review_found_matches_hide", "id", "review found matches test")->click();
68     sleep(1);
70     my $species_name_input = $t->find_element_ok("species_name_input", "id", "input species name");
71     $species_name_input->send_keys(KEYS->{'control'}, 'a');
72     $species_name_input->send_keys(KEYS->{'backspace'});
73     $species_name_input->send_keys("Manihot esculenta");
74     sleep(2);
76     my $review_matches = $t->find_element_ok("review_absent_accessions_submit", "id", "review matches submit");
77     $review_matches->click();
79     sleep(10);
81     $t->find_element_ok("close_add_accessions_saved_message_modal", "id", "close add accessions saved message modal");
83     # PEDIGREE UPLOAD FROM FILE FOR LIST
84     $t->get_ok('/breeders/accessions');
85     sleep(1);
87     $t->find_element_ok("upload_pedigrees_link", "id", "click on upload_pedigrees_link ")->click();
88     sleep(1);
90     my $upload_input = $t->find_element_ok("pedigrees_uploaded_file", "id", "find file input");
92     my $filename = $f->config->{basepath}."/t/data/pedigree_upload/pedigree_upload_selenium.txt";
94     $t->driver()->upload_file($filename);
96     $upload_input->send_keys($filename);
97     sleep(3);
99     my $upload_pedigrees = $t->find_element_ok("upload_pedigrees_dialog_submit", "id", "submit upload pedigrees file ");
100     $upload_pedigrees->click();
102     sleep(3);
104     $t->find_element_ok("upload_pedigrees_store", "id", "find and upload pedigrees store")->click();
105     sleep(3);
106     $t->find_element_ok("pedigrees_upload_success_dismiss", "id", "dismiss success modal ")->click();
107     sleep(1);
109     # PEDIGREE LIST DOWNLOAD
110     $t->get_ok('/breeders/download');
111     sleep(10);
113     $t->find_element_ok("pedigree_accession_list_list_select", "id", "select pedigrees accession download list")->click();
114     sleep(4);
116     $t->find_element_ok(
117         "//select[\@id='pedigree_accession_list_list_select']/option[contains(text(),\"$list_name\")]",
118         "xpath",
119         "Confirm $list_name pedigrees accession list to download")->click();
120     sleep(1);
122     $t->find_element_ok("pedigree", "id", "click pedigree download button")->click();
123     sleep(3);
126 $t->driver->close();
127 done_testing();