check stored prefixes globally
[sgn.git] / t / selenium2 / stock / stock_detail.t
blobd1d0dc08d9f6076582ca452a2eb3438c666de313
1 use lib 't/lib';
3 use Test::More 'tests' => 46;
5 use SGN::Test::WWW::WebDriver;
7 my $t = SGN::Test::WWW::WebDriver->new();
8 use Selenium::Remote::WDKeys 'KEYS';
10 $t->while_logged_in_as("submitter", sub {
11     sleep(2);
13     $t->get_ok('stock/38879/view');
14     sleep(2);
16     # Test edit / cancel button for stock / accession
17     $t->find_element_ok('//div[@id="stock_details_buttons"]/a[contains(text(), "Edit")]', "xpath", "find edit link")->click();
18     sleep(2);
20     $t->find_element_ok('//div[@id="stock_details_buttons"]/a[contains(text(), "Cancel")]', "xpath", "find edit link")->click();
21     sleep(2);
23     $t->find_element_ok('//div[@id="stock_details_buttons"]/a[contains(text(), "Edit")]', "xpath", "find edit link")->click();
24     sleep(2);
26     # Test edit form for stock / accession
27     my $species_name_input = $t->find_element_ok("species_name", "id", "edit stock organism");
28     $species_name_input->send_keys(KEYS->{'control'}, 'a');
29     $species_name_input->send_keys(KEYS->{'backspace'});
30     $species_name_input->send_keys('Manihot esculenta');
32     $t->find_element_ok("stockForm_reset_button", "id", "find reset edit button")->click();
33     sleep(1);
35     $species_name_input = $t->find_element_ok("species_name", "id", "edit stock organism");
36     $species_name_input->send_keys(KEYS->{'control'}, 'a');
37     $species_name_input->send_keys(KEYS->{'backspace'});
38     $species_name_input->send_keys('Manihot esculenta');
40     $t->find_element_ok("type_id", "name", "edit stock type")->click();
41     sleep(1);
43     $t->find_element_ok(
44         '//select[@name="type_id"]/option[contains(text(), "tissue_sample")]',
45         "xpath",
46         "select stock type as 'tissue_sample'")->click();
47     sleep(1);
49     my $unique_name = $t->find_element_ok("uniquename", "name", "edit stock uniquename");
50     $unique_name->send_keys(KEYS->{'control'}, 'a');
51     $unique_name->send_keys(KEYS->{'backspace'});
52     $unique_name->send_keys('UG120001_Testedit');
54     $t->find_element_ok("description", "name", "edit stock description")->send_keys('Test description edit.');
56     $t->find_element_ok("stockForm_submit_button", "id", "find submit edit button")->click();
57     sleep(1);
59     # Test adding and removing synonyms from stock additional info section
60     # my $synonym_onswitch = $t->find_element_ok("stock_additional_info_section_onswitch",  "id",  "click to open image panel");
61     # $synonym_onswitch->click();
62     # sleep(3);
64     $t->find_element_ok("stock_add_synonym", "id", "find add synonym link")->click();
65     sleep(1);
67     $t->find_element_ok("synonyms_select", "id", "find add synonym select")->click();
68     sleep(1);
70     $t->find_element_ok(
71         '//select[@id="synonyms_select"]/option[@title="stock_synonym"]',
72         "xpath",
73         "select 'stock_synonym' as value")->click();
74     sleep(1);
76     $t->find_element_ok("synonyms_prop", "id", "find add synonym input")->send_keys('test_synonym');
78     $t->find_element_ok("synonyms_addProp_submit", "id", "add synonym submit")->click();
79     sleep(10);
81     $t->driver->accept_alert();
82     sleep(5);
84     $t->find_element_ok('//div[@id="synonyms_content"]/a[text() = "X"]', "xpath", "find delete synonym link")->click();
86     $t->driver->accept_alert();
87     sleep(1);
88     $t->driver->accept_alert();
89     sleep(1);
91     # Test adding parents from pedigree info section
92     $t->get_ok('stock/38879/view');
93     sleep(2);
95     my $pedigree_section = $t->find_element_ok('stock_pedigree_section_onswitch', 'id', 'find pedigree section');
96     $t->driver->execute_script("arguments[0].scrollIntoView(true);window.scrollBy(0,-100)", $pedigree_section);
97     sleep(2);
98     $pedigree_section->click();
99     sleep(2);
101     my $add_parent_link = $t->find_element_ok('add_parent_link', 'id', 'find add parent link');
102     $add_parent_link->click();
103     sleep(1);
105     my $stock_name = $t->find_element_ok("stock_autocomplete", "id", "add parent input");
106     $stock_name->send_keys('test_wrong_stock_name');
108     $t->find_element_ok("male", "id", "find male input")->click();
109     $t->find_element_ok("female", "id", "find female input")->click();
111     $t->find_element_ok("add_parent_cross_type", "id", "add parent input")->click();
112     sleep(1);
114     $t->find_element_ok(
115         '//select[@id="add_parent_cross_type"]/option[@value="biparental"]',
116         "xpath",
117         "add parent input")->click();
118     sleep(1);
119     
120     $t->find_element_ok("add_parent_submit", "id", "submit add parent")->click();
121     sleep(1);
123     $t->driver->accept_alert();
124     sleep(1);
126     $stock_name->send_keys(KEYS->{'control'}, 'a');
127     $stock_name->send_keys(KEYS->{'backspace'});
128     $stock_name->send_keys('test_accession1');
130     $t->find_element_ok("add_parent_submit", "id", "submit add parent")->click();
131     sleep(1);
133     $t->driver->accept_alert();
134     sleep(4);
136     $t->get_ok('stock/38879/view');
137     sleep(5);
139     my $pedigree_section = $t->find_element_ok('stock_pedigree_section_onswitch', 'id', 'find pedigree section');
140     $t->driver->execute_script("arguments[0].scrollIntoView(true);window.scrollBy(0,-100)", $pedigree_section);
141     sleep(2);
142     $pedigree_section->click();
143     sleep(2);
145     my $add_parent_link = $t->find_element_ok('add_parent_link', 'id', 'find add parent link');
146     $add_parent_link->click();
147     sleep(1);
149     $stock_name = $t->find_element_ok("stock_autocomplete", "id", "add parent input");
151     $t->find_element_ok("male", "id", "find male input")->click();
153     $stock_name->send_keys(KEYS->{'control'}, 'a');
154     $stock_name->send_keys(KEYS->{'backspace'});
155     $stock_name->send_keys('test_accession2');
156   
157     $t->find_element_ok("add_parent_submit", "id", "submit add parent")->click();
158     sleep(1);
160     $t->driver->accept_alert();
161     sleep(2);
163     # Test if parents were added to database and now in a view
164     $t->get_ok('stock/38879/view');
165     sleep(5);
167     my $pedigree_section = $t->find_element_ok('stock_pedigree_section_onswitch', 'id', 'find pedigree section');
168     $t->driver->execute_script("arguments[0].scrollIntoView(true);window.scrollBy(0,-100)", $pedigree_section);
169     sleep(2);
170     $pedigree_section->click();
171     sleep(2);
173     my $pedigree_view = $t->find_element_ok(
174         '//div[@id="pdgv-wrap"]',
175         'xpath',
176         'find a content of pedigree view')->get_attribute('innerHTML');
178     ok($pedigree_view =~ /test_accession1/, "Verify if test_accession1 on pedigree panel");
179     ok($pedigree_view =~ /test_accession2/, "Verify if test_accession2 on pedigree panel");
181     my $pedigree_string = $t->find_element_ok("pedigree_string", "id", "verify pedigree string")->get_text();
183     ok($pedigree_string =~ /test_accession1\/test_accession2/, "Verify if pedigree string contain 'test_accession1/test_accession2'");
185     $t->find_element_ok("remove_parent_link", "id", "find delete parent link")->click();
186     sleep(1);
188     # Test removing parents from pedigree info section
189     $t->find_element_ok(
190         '//div[@id="remove_parent_list"]/a[1]',
191         "xpath",
192         "find delete parent link")->click();
193     sleep(1);
195     $t->driver->accept_alert();
196     sleep(1);
198     $t->driver->accept_alert();
199     sleep(3);
201     my $pedigree_section = $t->find_element_ok('stock_pedigree_section_onswitch', 'id', 'find pedigree section');
202     $t->driver->execute_script("arguments[0].scrollIntoView(true);window.scrollBy(0,-100)", $pedigree_section);
203     sleep(2);
204     $pedigree_section->click();
205     sleep(2);
207     $t->find_element_ok("remove_parent_link", "id", "find delete parent link")->click();
208     sleep(1);
210     $t->find_element_ok(
211         '//div[@id="remove_parent_list"]/a[1]',
212         "xpath",
213         "find delete parent link")->click();
215     $t->driver->accept_alert();
216     sleep(1);
218     $t->driver->accept_alert();
219     sleep(3);
221     }
224 $t->driver->close();
225 done_testing();