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 $categoryname = 'Test';
36 our ($cleanup_needed);
39 eval { require Selenium::Remote::Driver; };
40 skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
44 my $s = t::lib::Selenium->new;
45 my $driver = $s->driver;
46 my $mainpage = $s->base_url . q|mainpage.pl|;
47 $driver->get($mainpage);
48 like( $driver->get_title(), qr(Log in to Koha), );
51 # Navigate to the Administration area and create an item type
52 $s->click( { href => '/admin/admin-home.pl', main => 'doc3' } )
53 ; # Koha administration
54 $s->click( { href => '/admin/itemtypes.pl', main => 'doc' } ); # Item Types
55 $s->click( { href => '/admin/itemtypes.pl?op=add_form', main => 'doc3' } )
58 { itemtype => $itemtype, description => "Digital Optical Disc" } );
62 href => '/admin/itemtypes.pl?op=add_form&itemtype=' . $itemtype,
68 { # Circulation/fine rules
69 $driver->get($mainpage);
70 $s->click( { href => '/admin/admin-home.pl', main => 'doc3' } )
71 ; # Koha administration
72 $s->click( { href => '/admin/smart-rules.pl', main => 'doc' } )
73 ; # Circulation and fines rules
74 # TODO Create smart navigation here
78 $driver->get($mainpage);
79 $s->click( { href => '/admin/admin-home.pl', main => 'doc3' } )
80 ; # Koha administration
81 $s->click( { href => '/admin/biblio_framework.pl', main => 'doc' } )
82 ; # MARC bibliographic framework
84 { href => '/admin/biblio_framework.pl?op=add_form', main => 'doc3' } )
88 frameworkcode => $frameworkcode,
89 description => 'just a description'
93 $s->click( { id => 'frameworkactions' . $frameworkcode } );
96 href => 'marctagstructure.pl?frameworkcode=' . $frameworkcode,
99 ); # MARC structure # FIXME '/admin/' is missing in the url
100 # TODO Click on OK to create the MARC structure
104 $driver->get($mainpage);
105 $s->click( { href => '/admin/admin-home.pl', main => 'doc3' } )
106 ; # Koha administration
107 $s->click( { href => '/admin/branches.pl', main => 'doc' } )
108 ; # Libraries and groups
109 $s->click( { href => '/admin/branches.pl?op=add_form', main => 'doc3' } )
111 $s->fill_form( { branchcode => $branchcode, branchname => 'my library' } );
115 href => '/admin/branches.pl?op=add_form&branchcode=' . $branchcode,
119 $s->fill_form( { branchname => 'another branchname' } );
123 href => '/admin/branches.pl?op=delete_confirm&branchcode='. $branchcode,
130 $driver->get($mainpage);
131 $s->click( { href => '/admin/admin-home.pl', main => 'doc3' } ); #Koha administration
133 $s->click( { href => '/admin/authorised_values.pl', main => 'doc' } ); #Authorized values
135 $s->click( { href => '/admin/authorised_values.pl?op=add_form&category=Adult', main => 'doc3' } ); # New category
136 $s->fill_form( { authorised_value => 'Hardover', lib => 'Hardcover book'} );
141 href => '/admin/authorised_values.pl?op=delete&searchfield=Adult&id=400',
148 $driver->get($mainpage);
149 $s->click( { href => '/admin/categories.pl', main => 'doc3' } ); #Koha administration
150 $s->click( { href => '/admin/categories.pl?op=add_form', main => 'doc' } ); #New patron category
152 $s->fill_form( { categorycode => 'Test', description => 'Test category', enrolmentperiod => 12, category_type => 'Adult' } );
157 href => '/admin/categories.pl?op=delete_confirm&categorycode=TEST',
167 cleanup() if $cleanup_needed;
171 my $dbh = C4::Context->dbh;
172 $dbh->do(q|DELETE FROM itemtypes WHERE itemtype=?|, undef, $itemtype);
173 $dbh->do(q|DELETE FROM biblio_framework WHERE frameworkcode=?|, undef, $frameworkcode);
174 $dbh->do(q|DELETE FROM branches WHERE branchcode=?|, undef, $branchcode);