Merge branch 'master' into topic/create_plant_entries
[sgn.git] / t / selenium2 / breeders / 01_folder.t
blob34100286e9e47aef86864097350150cb81b14571
2 use strict;
4 use lib 't/lib';
6 use Test::More;
8 use SGN::Test::WWW::WebDriver;
9 use SGN::Test::Fixture;
11 my $t = SGN::Test::WWW::WebDriver->new();
12 my $f = SGN::Test::Fixture->new();
13 my $schema = $f->bcs_schema;
15 $t->while_logged_in_as("submitter", sub {
16   
17   $t->get_ok("/breeders/trials");
18   sleep(2);
20   my $refresh_tree = $t->find_element_ok("refresh_jstree_html", "id", "refresh tree")->click();
21   sleep(3);
22   
23   my $open_tree = $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
24   sleep(2);
25   
26   my $add_folder = $t->find_element_ok("new_folder_dialog_link", "id", "create new folder")->click();
27   
28   my $new_folder_name = $t->find_element_ok("new_folder_name", "id","pass F1 as new folder name")->send_keys("F1");
29   
30   my $add_folder_submit = $t->find_element_ok("new_folder_submit", "id", "create new folder submit")->click();
31   $t->driver->accept_alert();
32   sleep(2);
33   
34   my $refresh_tree = $t->find_element_ok("refresh_jstree_html", "id", "refresh tree")->click();
35   sleep(3);
36   
37   my $open_tree = $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
38   sleep(2);
40   my $page_source = $t->driver->get_page_source();
42   ok($page_source =~ /glyphicon-folder-open/, "check if folder appears");
45   my $add_folder = $t->find_element_ok("new_folder_dialog_link", "id", "create new folder")->click();
46   sleep(1);
47   
48   my $new_folder_name = $t->find_element_ok("new_folder_name", "id","pass F2 as new folder name")->send_keys("F2");
49   sleep(1);
50   my $new_folder_name = $t->find_element_ok("new_folder_parent_folder_id", "id","pass F1 as new folder's parent name")->send_keys("F1");
51   
52   my $add_folder_submit = $t->find_element_ok("new_folder_submit", "id", "create new folder submit")->click();
53   $t->driver->accept_alert();
54   sleep(2);
55   
56   my $refresh_tree = $t->find_element_ok("refresh_jstree_html", "id", "refresh tree")->click();
57   sleep(3);
58   
59   my $open_tree = $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
60   sleep(2);
61   
62   
63   my $add_trial = $t->find_element_ok("open_folder_dialog_link", "id", "place trial in F2")->click();
64   sleep(1);
65   
66   my $folder_name = $t->find_element_ok("html_select_folder_for_trial", "id","pass F2 as folder name")->send_keys("F1F2");
67   sleep(1);
68   my $trial_name = $t->find_element_ok("html_select_trial_for_folder", "id","pass test_trial as trial name")->send_keys("test_trial");
69   
70   my $trial_submit = $t->find_element_ok("set_trial_folder", "id", "add trial to folder submit")->click();
71   $t->driver->accept_alert();
72   sleep(2);
73   
74   my $refresh_tree = $t->find_element_ok("refresh_jstree_html", "id", "refresh tree")->click();
75   sleep(3);
76   
77   #my $open_tree = $t->find_element_ok("jstree-icon", "class", "open up tree")->click();
78   #sleep(2);
79   
80   $t->get_ok("/folder/145");
81   sleep(2);
82   
83   my $delete_folder = $t->find_element_ok("delete_folder_button", "id", "delete folder fails because child folder.")->click();
84   $t->driver->accept_alert();
85   sleep(2);
86   $t->driver->accept_alert();
87   sleep(2);
88   
89   my $move_folder = $t->find_element_ok("Folders", "partial_link_text", "go to folder tab")->click();
91   sleep(2);
92   
93   my $move_folder = $t->find_element_ok("move_folder_dialog_link", "id", "move folder")->click();
94   
95   my $folder_name = $t->find_element_ok("move_folder_id", "id","pass F2 as folder name")->send_keys("F1F2");
96   
97   my $move_folder = $t->find_element_ok("move_folder_submit", "id", "move folder")->click();
98   $t->driver->accept_alert();
99   
100   $t->get_ok("/folder/145");
101   sleep(2);
102   
103   my $delete_folder = $t->find_element_ok("delete_folder_button", "id", "delete folder")->click();
104   $t->driver->accept_alert();
105   sleep(2);
106   $t->driver->accept_alert();
107   
108   my $check_folder_deleted = $schema->resultset("Project::Project")->find({ project_id => 145});
109   ok(!$check_folder_deleted, "folder deleted.");
112 done_testing();