From 81c3a75a26ae60c8f2226cd2f36d248c995bc657 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 --- 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 aa6f74c6112..5eeb30041f3 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.'_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