From 18aeeb57fc92e77e788cc8501d9469b053621aa9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 14 Nov 2024 13:39:20 +0000 Subject: [PATCH] Bug 38444: Unit test to ensure limited categories don't break display Signed-off-by: David Nind --- t/db_dependent/selenium/patrons_search.t | 26 ++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t index 06a4822303..76cadfb10d 100755 --- a/t/db_dependent/selenium/patrons_search.t +++ b/t/db_dependent/selenium/patrons_search.t @@ -62,9 +62,12 @@ my $branchname = q|just 'another" library \123 ❤ my $firstname = q|fir's"tname \123 ❤|; my $address = q|add'res"s \123 ❤|; my $email = q|abad_email@example\123 ❤.com|; -my ($attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, $attribute_type_searchable_not_default); +my ( + $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, + $attribute_type_searchable_not_default, $patron_category, $library +); sub setup { - my $patron_category = $builder->build_object( + $patron_category = $builder->build_object( { class => 'Koha::Patron::Categories', value => { category_type => 'A' } @@ -72,7 +75,7 @@ sub setup { ); push @cleanup, $patron_category; - my $library = $builder->build_object( + $library = $builder->build_object( { class => 'Koha::Libraries', value => { branchname => $branchname } } ); push @cleanup, $library; @@ -207,7 +210,7 @@ sub teardown { } subtest 'Search patrons' => sub { - plan tests => 28; + plan tests => 29; setup(); my $total_number_of_patrons = Koha::Patrons->search->count; @@ -353,6 +356,21 @@ subtest 'Search patrons' => sub { sleep $DT_delay && $s->wait_for_ajax; is( $driver->find_element('//div[@id="'.$table_id.'_wrapper"]//div[@class="dt-info"]')->get_text, sprintf('Showing 1 to %s of %s entries (filtered from %s total entries)', 1, 1, $total_number_of_patrons), 'Refining with header filters works to further filter the original query' ); + subtest 'limited categories' => sub { + + plan tests => 1; + + $patron_category->replace_library_limits( [$library->id] ); + C4::Context->set_preference( 'PatronsPerPage', 5 ); + $driver->get( $base_url . "/members/members-home.pl" ); + clear_filters(); + $s->fill_form( { 'search_patron_filter' => 'test_patron' } ); + $s->submit_form; + sleep $DT_delay && $s->wait_for_ajax; + is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('Showing 1 to %s of %s entries (filtered from %s total entries)', $PatronsPerPage, 26, $total_number_of_patrons), 'Search works when category of patrons is limited to a library we are not signed in at' ); + + }; + subtest 'remember_search' => sub { plan tests => 7; -- 2.39.5