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 |
use Modern::Perl; |
19 |
use Test::More tests => 1; |
20 |
|
21 |
use C4::Biblio qw(DelBiblio); |
22 |
|
23 |
use C4::Context; |
24 |
use Koha::AuthUtils; |
25 |
use t::lib::Mocks; |
26 |
use t::lib::Selenium; |
27 |
use t::lib::TestBuilder; |
28 |
|
29 |
our $builder = t::lib::TestBuilder->new; |
30 |
our $ILLOpacUnauthenticatedRequest_value = C4::Context->preference('ILLOpacUnauthenticatedRequest'); |
31 |
our $ILLModule_value = C4::Context->preference('ILLModule'); |
32 |
|
33 |
SKIP: { |
34 |
eval { require Selenium::Remote::Driver; }; |
35 |
skip "Selenium::Remote::Driver is needed for selenium tests.", 3 if $@; |
36 |
|
37 |
our $s = t::lib::Selenium->new; |
38 |
our $driver = $s->driver; |
39 |
|
40 |
subtest 'unauthenticated ill request' => sub { |
41 |
plan tests => 2; |
42 |
|
43 |
subtest 'ILLOpacUnauthenticatedRequest enabled' => sub { |
44 |
plan tests => 4; |
45 |
|
46 |
C4::Context->set_preference( 'ILLOpacUnauthenticatedRequest', 1 ); |
47 |
C4::Context->set_preference( 'ILLModule', 1 ); |
48 |
|
49 |
$driver->get( $s->opac_base_url . "opac-search.pl?q=music" ); |
50 |
|
51 |
like( |
52 |
$driver->get_title, qr(Results of search for 'music'), |
53 |
'Correctly in search results page' |
54 |
); |
55 |
|
56 |
is( |
57 |
$driver->find_element('//div[@class="suggestion"]/ul/li')->get_text, |
58 |
'Make an Interlibrary loan request', |
59 |
'Placing an ILL request through the OPAC is allowed', |
60 |
); |
61 |
|
62 |
# Clicking on the search results page link works |
63 |
$driver->find_element('//div[@class="suggestion"]/ul/li/a')->click; |
64 |
is( |
65 |
$driver->find_element('(//nav[@id="breadcrumbs"]/ol/li)[last()]')->get_text, |
66 |
'New interlibrary loan request', |
67 |
'Correctly on the create new request OPAC page' |
68 |
); |
69 |
|
70 |
# Visiting the create request page directly works |
71 |
$driver->get( $s->opac_base_url . "opac-illrequests.pl?op=create" ); |
72 |
is( |
73 |
$driver->find_element('(//nav[@id="breadcrumbs"]/ol/li)[last()]')->get_text, |
74 |
'New interlibrary loan request', |
75 |
'Correctly on the create new request OPAC page' |
76 |
); |
77 |
|
78 |
}; |
79 |
|
80 |
subtest 'ILLOpacUnauthenticatedRequest disabled' => sub { |
81 |
plan tests => 3; |
82 |
|
83 |
C4::Context->set_preference( 'ILLOpacUnauthenticatedRequest', 0 ); |
84 |
C4::Context->set_preference( 'ILLModule', 1 ); |
85 |
|
86 |
$driver->get( $s->opac_base_url . "opac-search.pl?q=music" ); |
87 |
|
88 |
like( |
89 |
$driver->get_title, qr(Results of search for 'music'), |
90 |
'Correctly in search results page' |
91 |
); |
92 |
|
93 |
my $link_exists = |
94 |
$driver->find_elements( '//div[@class="suggestion"]/ul/li' ); |
95 |
|
96 |
is( |
97 |
scalar @{$link_exists}, |
98 |
0, |
99 |
'Search page - Place ILL request link should be absent. ' |
100 |
); |
101 |
|
102 |
# Visiting the create request page directly does not work |
103 |
$driver->get( $s->opac_base_url . "opac-illrequests.pl?op=create" ); |
104 |
is( |
105 |
$driver->find_element('(//nav[@id="breadcrumbs"]/ol/li)[last()]')->get_text, |
106 |
'Log in to your account', |
107 |
'Correctly on the log in page' |
108 |
); |
109 |
|
110 |
}; |
111 |
}; |
112 |
|
113 |
$driver->quit(); |
114 |
} |
115 |
|
116 |
END { |
117 |
C4::Context->set_preference( 'ILLOpacUnauthenticatedRequest', $ILLOpacUnauthenticatedRequest_value ); |
118 |
C4::Context->set_preference( 'ILLModule', $ILLModule_value ); |
119 |
} |