Koha/t/db_dependent/selenium/patrons_search.t
Jonathan Druart ecb12104ff Bug 22781: Does not double filter address
Ho, a bug!
Some fields in the address where double filtered.

Test plan:
Use the evil strings in the address field and do a search, you will see
double html encoded characters without this patch.

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-05-15 12:10:53 +00:00

112 lines
3.8 KiB
Perl
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Context;
use utf8;
use Test::More tests => 1;
use Test::MockModule;
use C4::Context;
use Koha::AuthUtils;
use t::lib::Mocks;
use t::lib::Selenium;
use t::lib::TestBuilder;
eval { require Selenium::Remote::Driver; };
skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
my $s = t::lib::Selenium->new;
my $driver = $s->driver;
my $opac_base_url = $s->opac_base_url;
my $base_url = $s->base_url;
my $builder = t::lib::TestBuilder->new;
our @cleanup;
subtest 'Search patrons' => sub {
plan tests => 5;
my @patrons;
my $borrowernotes = q|<strong>just 'a" note</strong> \123 ❤|;
my $borrowernotes_displayed = q|just 'a" note \123 ❤|;
my $branchname = q|<strong>just 'another" library</strong> \123 ❤|;
my $firstname = q|<strong>fir's"tname</strong> \123 ❤|;
my $address = q|<strong>add'res"s</strong> \123 ❤|;
my $patron_category = $builder->build_object(
{ class => 'Koha::Patron::Categories', category_type => 'A' } );
my $library = $builder->build_object(
{ class => 'Koha::Libraries', value => { branchname => $branchname } }
);
for my $i ( 1 .. 25 ) {
push @patrons,
$builder->build_object(
{
class => 'Koha::Patrons',
value => {
surname => "test_patron_" . $i++,
firstname => $firstname,
categorycode => $patron_category->categorycode,
branchcode => $library->branchcode,
borrowernotes => $borrowernotes,
address => $address,
}
}
);
}
$s->auth;
$driver->get( $base_url . "/members/members-home.pl" );
$s->fill_form( { searchmember_filter => 'test_patron' } );
$s->submit_form;
my $first_patron = $patrons[0];
my @td = $driver->find_elements('//table[@id="memberresultst"]/tbody/tr/td');
like ($td[2]->get_text, qr[\Q$firstname\E],
'Column "Name" should be the 3rd and contain the firstname correctly filtered'
);
like ($td[2]->get_text, qr[\Q$address\E],
'Column "Name" should be the 3rd and contain the address correctly filtered'
);
is( $td[5]->get_text, $branchname,
'Column "Library" should be the 6th and contain the html tags - they have been html filtered'
);
is( $td[9]->get_text, $borrowernotes_displayed,
'Column "Circ note" should be the 10th and not contain the html tags - they have not been html filtered'
);
$driver->find_element(
'//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber='
. $first_patron->borrowernumber
. '"]' )->click;
is(
$driver->get_title,
sprintf(
"Koha Patrons Modify patron %s %s (%s)",
$first_patron->firstname, $first_patron->surname,
$first_patron->category->description,
)
);
push @cleanup, $_ for @patrons;
push @cleanup, $library;
push @cleanup, $patron_category;
};
END {
$_->delete for @cleanup;
}