5 use Test::More 'tests' => 69;
6 use SGN::Test::Fixture;
7 use SGN::Test::WWW::WebDriver;
11 my $d = SGN::Test::WWW::WebDriver->new();
13 my $f = SGN::Test::Fixture->new();
14 # my $c = SimulateC->new( { dbh => $f->dbh(),
15 # bcs_schema => $f->bcs_schema(),
16 # metadata_schema => $f->metadata_schema(),
17 # phenome_schema => $f->phenome_schema(),
18 # sp_person_id => 41 });
20 $d->while_logged_in_as("submitter", sub {
22 $d->get_ok("/search", "get root url test");
24 my $out = $d->find_element_ok("lists_link", "name", "find lists_link")->click();
26 print "Adding new list...\n";
28 $d->find_element_ok("add_list_input", "id", "find add list input");
32 my $add_list_input = $d->find_element_ok("add_list_input", "id", "find add list input test");
36 $add_list_input->send_keys("new_test_list");
38 $d->find_element_ok("add_list_button", "id", "find add list button test")->click();
40 $d->find_element_ok("view_list_new_test_list", "id", "view list test")->click();
44 $d->find_element_ok("dialog_add_list_item", "id", "add test list")->send_keys("element1\nelement2\nelement3\n");
48 $d->find_element_ok("dialog_add_list_item_button", "id", "find dialog_add_list_item_button test")->click();
50 my $edit_list_name = $d->find_element_ok("updateNameField", "id", "edit list name");
52 $edit_list_name->clear();
53 $edit_list_name->send_keys("update_list_name");
57 $d->find_element_ok("updateNameButton", "id", "submit edit list name")->click();
60 $d->accept_alert_ok();
62 #$d->accept_alert_ok();
65 $d->find_element_ok("close_list_item_dialog", "id", "find close_list_item_dialog button test")->click();
69 #my %test_lists = ('accessions'=>"test_accession1\ntest_accession2\ntest_accession3\n", 'plots'=>"test_trial1\ntest_trial21\ntest_trial22\n", 'locations'=>"test_location\nCornell Biotech\n", 'trials'=>"test\ntest_trial\ntest_genotyping_project\n", 'traits'=>"fresh shoot weight|CO_334:0000016\ndry matter content|CO_334:0000092\nharvest index|CO_334:0000015\n");
72 'accessions'=>"test_accession1\ntest_accession2\ntest_accession3\n",
73 'plots'=>"test_trial1\ntest_trial21\ntest_trial22\n",
74 'locations'=>"test_location\nCornell Biotech\n",
75 #'traits'=>"fresh shoot weight|CO_334:0000016\ndry matter content|CO_334:0000092\nharvest index|CO_334:0000015\n"
78 foreach my $list_type ( keys %test_lists ) {
80 print STDERR "NOW TESTING $list_type...\n";
83 $d->find_element_ok("add_list_input", "id", "find add list input");
87 $d->find_element_ok("add_list_input", "id", "find add list input test")->send_keys($list_type);
89 $d->find_element_ok("add_list_button", "id", "find add list button test")->click();
91 $d->find_element_ok("view_list_".$list_type, "id", "view list dialog test")->click();
95 $d->find_element_ok("dialog_add_list_item", "id", "add list items")->send_keys($test_lists{$list_type});
97 my @list_items = split /\n/, $test_lists{$list_type};
99 $d->find_element_ok("dialog_add_list_item_button", "id", "find dialog_add_list_item_button test")->click();
101 $d->find_element_ok("type_select", "id", "validate list select")->click();
103 $d->find_element_ok("//select[\@id='type_select']/option[\@name='$list_type']", 'xpath', "Select '$list_type' as value for list type")->click();
105 $d->find_element_ok("list_item_dialog_validate", "id", "submit list validate")->click();
108 my $alert_text = $d->driver->get_alert_text;
109 if ($alert_text eq 'This list passed validation.'){
110 $d->accept_alert_ok();
112 print STDERR "\n\n<ERROR>: list not validated: ".$list_type."\n\n";
113 $d->accept_alert_ok();
117 $d->find_element_ok("close_list_item_dialog", "id", "find close list dialog button")->click();
119 $d->find_element_ok("view_list_".$list_type, "id", "view accession list dialog test");
123 $d->find_element_ok("view_public_lists_button", "id", "find public list button")->click();
127 $d->find_element_ok("view_public_list_johndoe_1_public", "id", "view johndoe1public list")->click();
131 $d->find_element_ok("close_list_item_dialog", "id", "close public list item dialog")->click();
135 $d->find_element_ok("copy_public_list_johndoe_1_public", "id", "copy johndoe public list")->click();
139 $d->accept_alert_ok();
143 $d->find_element_ok("copy_public_list_janedoe_1_public", "id", "copy janedoe public list")->click();
147 $d->accept_alert_ok();
151 $d->find_element_ok("close_public_list_item_dialog", "id", "close public list dialog")->click();
155 $d->find_element_ok("share_list_johndoe_1_private", "id", "make private list public")->click();
159 $d->accept_alert_ok();
163 $d->find_element_ok("view_public_lists_button", "id", "view public lists")->click();
167 $d->find_element_ok("view_public_list_johndoe_1_private", "id", "view new public list")->click();
171 $d->find_element_ok("close_list_item_dialog", "id", "close new public list item dialog")->click();
175 $d->find_element_ok("close_public_list_item_dialog", "id", "close new public list dialog")->click();
179 $d->find_element_ok("view_list_janedoe_1_public", "id", "view new public list")->click();
184 #my $q = "SELECT list_item_id from sgn_people.list join sgn_people.list_item using(list_id) WHERE list_id=?";
185 #my $h = $c->dbh->prepare($q);
186 #$h->execute($list_id);
188 #while (my ($content) = $h->fetchrow_array()) {
189 # push @list, $content;
192 #$d->find_element_ok($list[0], "id", "delete item from list")->click();
193 #$d->find_element_ok($list[1], "id", "delete item from list")->click();
197 $d->find_element_ok("close_list_item_dialog", "id", "close new public list item dialog")->click();
201 print "Delete test list...\n";
203 # $d->find_element_ok("delete_list_update_list_name", "id", "find delete test list button")->click();
204 $d->find_element_ok('//*[starts-with(@id, "delete_list")]', 'xpath', 'delete list')->click();
208 $d->accept_alert_ok();
212 $d->accept_alert_ok();
214 print "Deleted the list\n";
216 $d->find_element_ok("close_list_dialog_button", "id", "find close dialog button")->click();