Line 0
Link Here
|
0 |
- |
1 |
# This file is part of Koha. |
|
|
2 |
# |
3 |
# Koha is free software; you can redistribute it and/or modify it |
4 |
# under the terms of the GNU General Public License as published by |
5 |
# the Free Software Foundation; either version 3 of the License, or |
6 |
# (at your option) any later version. |
7 |
# |
8 |
# Koha is distributed in the hope that it will be useful, but |
9 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 |
# GNU General Public License for more details. |
12 |
# |
13 |
# You should have received a copy of the GNU General Public License |
14 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
15 |
|
16 |
use Modern::Perl; |
17 |
|
18 |
use Koha::AuthUtils; |
19 |
use Test::More; |
20 |
|
21 |
use t::lib::Mocks; |
22 |
use t::lib::Selenium; |
23 |
use t::lib::TestBuilder; |
24 |
|
25 |
eval { require Selenium::Remote::Driver; }; |
26 |
if ( $@ ) { |
27 |
plan skip_all => "Selenium::Remote::Driver is needed for Selenium tests."; |
28 |
} else { |
29 |
plan tests => 1; |
30 |
} |
31 |
|
32 |
my @cleanup; |
33 |
|
34 |
my $builder = t::lib::TestBuilder->new; |
35 |
|
36 |
my $s = t::lib::Selenium->new; |
37 |
my $driver = $s->driver; |
38 |
my $base_url = $s->base_url; |
39 |
|
40 |
# Adjust the height and width of the generated screenshots |
41 |
#$driver->set_window_size( 2160, 991 ); # Height, then Width |
42 |
|
43 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1, branchcode => 'CPL' } } ); |
44 |
my $password = Koha::AuthUtils::generate_password( $patron->category ); |
45 |
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); |
46 |
$patron->set_password( { password => $password } ); |
47 |
|
48 |
push @cleanup, $patron; |
49 |
|
50 |
$s->auth( $patron->userid, $password ); |
51 |
|
52 |
subtest 'Perform a system preferences search for "log", and try to expand/collapse both "Policy" sections that appear' => sub { |
53 |
|
54 |
plan tests => 6; |
55 |
|
56 |
$driver->get( $base_url . 'admin/preferences.pl?tab=&op=search&searchfield=log' ); |
57 |
#$driver->capture_screenshot( 'Selenium_00.png' ); |
58 |
|
59 |
my $xpath_v1_expr1 = '//h3[@id="accounting_Policy"]'; |
60 |
|
61 |
# The first "Policy" section should be under the "Accounting" preferences top-level section and be initially expanded |
62 |
my $first_policy_section_toggle_elt = $driver->find_element( $xpath_v1_expr1 ); |
63 |
is( $first_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'expanded', 'The first "Policy" section (under "Accounting") is currently expanded' ); |
64 |
|
65 |
# Clicking on the expand/collapse button should collapse this section |
66 |
$first_policy_section_toggle_elt->click; |
67 |
#$driver->capture_screenshot( 'Selenium_01.png' ); |
68 |
is( $first_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'collapsed', 'The first "Policy" section (under "Accounting") is now collapsed' ); |
69 |
|
70 |
# Clicking on the expand/collapse button once more should expand this section back to its original state |
71 |
$first_policy_section_toggle_elt->click; |
72 |
#$driver->capture_screenshot( 'Selenium_02.png' ); |
73 |
is( $first_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'expanded', 'The first "Policy" section (under "Accounting") is back to the expanded state' ); |
74 |
|
75 |
my $xpath_v1_expr2 = '//h3[@id="acquisitions_Policy"]'; |
76 |
|
77 |
# The second "Policy" section should be under the "Acquisitions" preferences top-level section and be initially expanded |
78 |
my $second_policy_section_toggle_elt = $driver->find_element( $xpath_v1_expr2 ); |
79 |
is( $second_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'expanded', 'The second "Policy" section (under "Acquisitions") is currently expanded' ); |
80 |
|
81 |
# Clicking on the expand/collapse button should collapse this section |
82 |
$second_policy_section_toggle_elt->click; |
83 |
#$driver->capture_screenshot( 'Selenium_03.png' ); |
84 |
is( $second_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'collapsed', 'The second "Policy" section (under "Acquisitions") is now collapsed' ); |
85 |
|
86 |
# Clicking on the expand/collapse button once more should expand this section back to its original state |
87 |
$second_policy_section_toggle_elt->click; |
88 |
#$driver->capture_screenshot( 'Selenium_04.png' ); |
89 |
is( $second_policy_section_toggle_elt->get_attribute( 'class' , 1 ), 'expanded', 'The second "Policy" section (under "Acquisitions") is back to the expanded state' ); |
90 |
|
91 |
}; |
92 |
|
93 |
# Delete the test patron |
94 |
END { |
95 |
$_->delete for @cleanup; |
96 |
}; |