3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 #This selenium test tests the Koha Administration module functionality including adding circ rules, item types and modifying frameworks
20 #Note: If you are testing this on kohadevbox with selenium installed in kohadevbox then you need to set the staffClientBaseURL to localhost:8080 and the OPACBaseURL to http://localhost:80
26 use Test::More tests => 1;
30 my $login = $ENV{KOHA_USER} || 'koha';
32 my $itemtype = 'UT_DVD';
33 my $frameworkcode = 'UTFW'; # frameworkcode is only 4 characters max!
34 my $branchcode = 'UT_BC';
35 my $av_category = 'AV_CAT_TEST';
36 my $category_code = 'PATRON_CAT';
37 our ($cleanup_needed);
40 eval { require Selenium::Remote::Driver; };
41 skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
45 my $s = t::lib::Selenium->new;
46 my $driver = $s->driver;
47 my $mainpage = $s->base_url . q|mainpage.pl|;
48 $driver->get($mainpage);
49 like( $driver->get_title(), qr(Log in to Koha), );
52 # Navigate to the Administration area and create an item type
53 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } )
54 ; # Koha administration
55 $s->click( { href => '/admin/itemtypes.pl', main_class => 'main container-fluid' } ); # Item Types
56 $s->click( { href => '/admin/itemtypes.pl?op=add_form', main => 'doc3' } )
59 { itemtype => $itemtype, description => "Digital Optical Disc" } );
63 href => '/admin/itemtypes.pl?op=add_form&itemtype=' . $itemtype,
69 { # Circulation/fine rules
70 $driver->get($mainpage);
71 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } )
72 ; # Koha administration
73 $s->click( { href => '/admin/smart-rules.pl', main_class => 'main container-fluid' } )
74 ; # Circulation and fines rules
75 # TODO Create smart navigation here
79 $driver->get($mainpage);
80 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } )
81 ; # Koha administration
82 $s->click( { href => '/admin/biblio_framework.pl', main_class => 'main container-fluid' } )
83 ; # MARC bibliographic framework
85 { href => '/admin/biblio_framework.pl?op=add_form', main => 'doc3' } )
89 frameworkcode => $frameworkcode,
90 description => 'just a description'
94 $s->click( { id => 'frameworkactions' . $frameworkcode } );
97 href => 'marctagstructure.pl?frameworkcode=' . $frameworkcode,
100 ); # MARC structure # FIXME '/admin/' is missing in the url
101 # TODO Click on OK to create the MARC structure
105 $driver->get($mainpage);
106 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } )
107 ; # Koha administration
108 $s->click( { href => '/admin/branches.pl', main_class => 'main container-fluid' } )
109 ; # Libraries and groups
110 $s->click( { href => '/admin/branches.pl?op=add_form', main => 'doc3' } )
112 $s->fill_form( { branchcode => $branchcode, branchname => 'my library' } );
116 href => '/admin/branches.pl?op=add_form&branchcode=' . $branchcode,
120 $s->fill_form( { branchname => 'another branchname' } );
124 id => 'delete_library_'.$branchcode,
130 $driver->get($mainpage);
131 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } ); #Koha administration
133 $s->click( { href => '/admin/authorised_values.pl', main_class => 'main container-fluid' } ); #Authorized values
135 $s->click( { href => { 'ends-with' => '/admin/authorised_values.pl?op=add_form' }, main => 'doc3' } ); # New category
136 $s->fill_form( { category => $av_category } );
141 href => '/admin/authorised_values.pl?op=add_form&category=' . $av_category,
144 ); # New authorised value for ...
147 authorised_value => "$av_category" . "_xxx",
148 lib => "This is a description for staff",
149 lib_opac => "This is a description for OPAC"
154 my $dbh = C4::Context->dbh;
155 my ( $av_id ) = $dbh->selectrow_array(q|
156 SELECT id FROM authorised_values WHERE category=?|, undef, $av_category );
159 href => '/admin/authorised_values.pl?op=delete&searchfield=' . $av_category . '&id=' . $av_id,
163 $s->driver->accept_alert; # Accept the modal "Are you sure you want to delete this authorized value?"
166 { # Patron categories
167 $driver->get($mainpage);
168 $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } ); # Koha administration
169 $s->click( { href => '/admin/categories.pl', main_class => 'main container-fluid' } ); # Patron categories
170 $s->click( { href => '/admin/categories.pl?op=add_form', main => 'doc3' } ); # New patron category
172 $s->fill_form( { categorycode => $category_code, description => 'Test category', enrolmentperiod => 12, category_type => 'A' } );
177 href => '/admin/categories.pl?op=delete_confirm&categorycode=' . $category_code,
182 $s->submit_form; # Delete this category
184 # TODO Make sure the category has been deleted
191 cleanup() if $cleanup_needed;
195 my $dbh = C4::Context->dbh;
196 $dbh->do(q|DELETE FROM itemtypes WHERE itemtype=?|, undef, $itemtype);
197 $dbh->do(q|DELETE FROM biblio_framework WHERE frameworkcode=?|, undef, $frameworkcode);
198 $dbh->do(q|DELETE FROM branches WHERE branchcode=?|, undef, $branchcode);
199 $dbh->do(q|DELETE FROM authorised_value_categories WHERE category_name=?|, undef, $av_category);
200 $dbh->do(q|DELETE FROM categories WHERE categorycode=?|, undef, $category_code);