|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 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. |
| 9 |
# |
| 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. |
| 14 |
# |
| 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>. |
| 17 |
|
| 18 |
#This selenium test tests the Koha Administration module functionality including adding circ rules, item types and modifying frameworks |
| 19 |
|
| 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 |
| 21 |
|
| 22 |
use Modern::Perl; |
| 23 |
|
| 24 |
use C4::Context; |
| 25 |
|
| 26 |
use Test::More tests => 1; |
| 27 |
|
| 28 |
use t::lib::Selenium; |
| 29 |
|
| 30 |
my $login = $ENV{KOHA_USER} || 'koha'; |
| 31 |
|
| 32 |
my $itemtype = 'UT_DVD'; |
| 33 |
my $frameworkcode = 'UTFW'; # frameworkcode is only 4 characters max! |
| 34 |
my $branchcode = 'UT_BC'; |
| 35 |
our ($cleanup_needed); |
| 36 |
|
| 37 |
SKIP: { |
| 38 |
eval { require Selenium::Remote::Driver; }; |
| 39 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@; |
| 40 |
|
| 41 |
$cleanup_needed = 1; |
| 42 |
|
| 43 |
my $s = t::lib::Selenium->new; |
| 44 |
my $driver = $s->driver; |
| 45 |
my $mainpage = $s->base_url . q|mainpage.pl|; |
| 46 |
$driver->get($mainpage); |
| 47 |
like( $driver->get_title(), qr(Log in to Koha), ); |
| 48 |
$s->auth; |
| 49 |
|
| 50 |
{ # Item types |
| 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' } ) |
| 56 |
; # New item type |
| 57 |
$s->fill_form( |
| 58 |
{ itemtype => $itemtype, description => "Digital Optical Disc" } ); |
| 59 |
$s->submit_form; |
| 60 |
$s->click( |
| 61 |
{ |
| 62 |
href => '/admin/itemtypes.pl?op=add_form&itemtype=' . $itemtype, |
| 63 |
main => 'doc3' |
| 64 |
} |
| 65 |
); # New item type |
| 66 |
}; |
| 67 |
|
| 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 |
| 75 |
}; |
| 76 |
|
| 77 |
{ # Biblio frameworks |
| 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 |
| 83 |
$s->click( |
| 84 |
{ href => '/admin/biblio_framework.pl?op=add_form', main => 'doc3' } ) |
| 85 |
; # New framework |
| 86 |
$s->fill_form( |
| 87 |
{ |
| 88 |
frameworkcode => $frameworkcode, |
| 89 |
description => 'just a description' |
| 90 |
} |
| 91 |
); |
| 92 |
$s->submit_form; |
| 93 |
$s->click( { id => 'frameworkactions' . $frameworkcode } ); |
| 94 |
$s->click( |
| 95 |
{ |
| 96 |
href => 'marctagstructure.pl?frameworkcode=' . $frameworkcode, |
| 97 |
main => 'doc3' |
| 98 |
} |
| 99 |
); # MARC structure # FIXME '/admin/' is missing in the url |
| 100 |
# TODO Click on OK to create the MARC structure |
| 101 |
}; |
| 102 |
|
| 103 |
{ #Libraries |
| 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' } ) |
| 110 |
; # New library |
| 111 |
$s->fill_form( { branchcode => $branchcode, branchname => 'my library' } ); |
| 112 |
$s->submit_form; |
| 113 |
$s->click( |
| 114 |
{ |
| 115 |
href => '/admin/branches.pl?op=add_form&branchcode=' . $branchcode, |
| 116 |
main => 'doc3' |
| 117 |
} |
| 118 |
); # Edit |
| 119 |
$s->fill_form( { branchname => 'another branchname' } ); |
| 120 |
$s->submit_form; |
| 121 |
$s->click( |
| 122 |
{ |
| 123 |
href => '/admin/branches.pl?op=delete_confirm&branchcode='. $branchcode, |
| 124 |
main => 'doc3' |
| 125 |
} |
| 126 |
); # Delete |
| 127 |
}; |
| 128 |
|
| 129 |
$driver->quit(); |
| 130 |
} |
| 131 |
|
| 132 |
END { |
| 133 |
cleanup() if $cleanup_needed; |
| 134 |
}; |
| 135 |
|
| 136 |
sub cleanup { |
| 137 |
my $dbh = C4::Context->dbh; |
| 138 |
$dbh->do(q|DELETE FROM itemtypes WHERE itemtype=?|, undef, $itemtype); |
| 139 |
$dbh->do(q|DELETE FROM biblio_framework WHERE frameworkcode=?|, undef, $frameworkcode); |
| 140 |
$dbh->do(q|DELETE FROM branches WHERE branchcode=?|, undef, $branchcode); |
| 141 |
} |