From dfe35eae81382fac7d2aee92dd94fc029681a71b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 28 Apr 2022 15:13:17 +0200 Subject: [PATCH] Bug 30645: Add tests to highlight the problem --- t/db_dependent/selenium/patrons_search.t | 29 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t index cd635991929..56d8e3b52a4 100755 --- a/t/db_dependent/selenium/patrons_search.t +++ b/t/db_dependent/selenium/patrons_search.t @@ -51,7 +51,7 @@ my $base_url = $s->base_url; my $builder = t::lib::TestBuilder->new; subtest 'Search patrons' => sub { - plan tests => 24; + plan tests => 25; if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); @@ -132,7 +132,7 @@ subtest 'Search patrons' => sub { description => 'my description1', } )->store; - my $attribute_type_searchable = Koha::Patron::Attribute::Type->new( + my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( { code => 'my code2', description => 'my description2', @@ -140,13 +140,24 @@ subtest 'Search patrons' => sub { staff_searchable => 1 } )->store; + my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( + { + code => 'my code3', + description => 'my description3', + opac_display => 1, + staff_searchable => 1 + } + )->store; + $patrons[0]->extended_attributes([ { code => $attribute_type->code, attribute => 'test_attr_1' }, - { code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, + { code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, + { code => $attribute_type_searchable_2->code, attribute => 'yyy'}, ]); $patrons[1]->extended_attributes([ { code => $attribute_type->code, attribute => 'test_attr_1' }, - { code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, + { code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, + { code => $attribute_type_searchable_2->code, attribute => 'yyy'}, ]); my $total_number_of_patrons = Koha::Patrons->search->count; @@ -254,6 +265,14 @@ subtest 'Search patrons' => sub { is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('No entries to show (filtered from %s total entries)', $total_number_of_patrons), 'Searching on a non-searchable attribute returns no results' ); + # clear form + $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); + $s->fill_form( { search_patron_filter => 'test_attr yyy' } ); # Terms must be split + $s->submit_form; + $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)', 2, 2, $total_number_of_patrons), 'Searching on a searchable attribute returns correct results' ); + # clear form $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); # Search on searchable attribute, we expect 2 patrons @@ -279,7 +298,7 @@ subtest 'Search patrons' => sub { push @cleanup, $library; push @cleanup, $library_2; push @cleanup, $patron_category; - push @cleanup, $attribute_type, $attribute_type_searchable; + push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2; C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields); C4::Context->set_preference('PatronsPerPage',$default_patron_per_page); -- 2.25.1