Bugzilla – Attachment 133685 Details for
Bug 30576
DefaultPatronSearchFields no longer takes effect
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30576: (follow-up) Corrections to behaviour to reflect unit tests
Bug-30576-follow-up-Corrections-to-behaviour-to-re.patch (text/plain), 7.49 KB, created by
Martin Renvoize (ashimema)
on 2022-04-22 14:22:00 UTC
(
hide
)
Description:
Bug 30576: (follow-up) Corrections to behaviour to reflect unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-04-22 14:22:00 UTC
Size:
7.49 KB
patch
obsolete
>From da0d39cd0041ddebd887e64c2d7f11c1e3b38f79 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 22 Apr 2022 15:19:29 +0100 >Subject: [PATCH] Bug 30576: (follow-up) Corrections to behaviour to reflect > unit tests > >The unit tests highlighted my original patch didn't cover the full >preference description. > >We now replace the 'standard' option with the fields from the preference >and we also add those fields as options to the field selection in >advanced searches. > >This patch also adjusts the tests to test for that and reflects the >expected changes to the number of options displayed in the select boxes. >--- > .../prog/en/includes/patron-search-header.inc | 3 ++- > .../prog/en/includes/patron-search.inc | 3 ++- > t/db_dependent/selenium/patrons_search.t | 24 ++++++++++++------- > 3 files changed, 19 insertions(+), 11 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc >index 5a1df7600e..f5e8dddcde 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc >@@ -24,7 +24,8 @@ > <p><label for="searchfieldstype">Search fields:</label> > <select name="searchfieldstype" id="searchfieldstype"> > [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname,surname,othernames,cardnumber,userid' %] >- [% SET search_options = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] >+ [% default_fields = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] >+ [% search_options = default_fields.merge(standard.split(',')).unique %] > [% FOREACH s_o IN search_options %] > [% display_name = PROCESS patron_fields name=s_o %] > [% NEXT IF !display_name.length %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 07997bf945..ec68d3620a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -61,7 +61,8 @@ > <label for="searchfieldstype_filter">Search field:</label> > <select name="searchfieldstype" id="searchfieldstype_filter"> > [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname,surname,othernames,cardnumber,userid' %] >- [% SET search_options = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] >+ [% default_fields = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] >+ [% search_options = default_fields.merge(standard.split(',')).unique %] > [% FOREACH s_o IN search_options %] > [% display_name = PROCESS patron_fields name=s_o %] > [% NEXT IF !display_name %] >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index 8c232b2c15..8bd4758711 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 => 17; >+ plan tests => 23; > > 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"); >@@ -142,22 +142,28 @@ subtest 'Search patrons' => sub { > C4::Context->set_preference('PatronsPerPage', $PatronsPerPage); > $driver->get( $base_url . "/members/members-home.pl" ); > my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >+ is( scalar @adv_options, 13, 'All standard fields are searchable if DefaultPatronSearchFields not set'); >+ is( $adv_options[0]->get_value(), 'firstname,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set'); > my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >- is( scalar @adv_options, 11, 'All standard fields are searchable if DefaultPatronSearchFields not set'); >- is( scalar @filter_options, 11, 'All standard fields are searchable by filter if DefaultPatronSearchFields not set'); >- C4::Context->set_preference('DefaultPatronSearchFields',"initials"); >+ is( scalar @filter_options, 13, 'All standard fields are searchable by filter if DefaultPatronSearchFields not set'); >+ is( $filter_options[0]->get_value(), 'firstname,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set'); >+ C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials"); > $driver->get( $base_url . "/members/members-home.pl" ); > @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); >+ is( scalar @adv_options, 13, 'New option added when DefaultPatronSearchFields is populated with a field'); >+ is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated'); > @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >- is( scalar @adv_options, 12, 'New option added when DefaultPatronSearchFields is populated with a field'); >- is( scalar @filter_options, 12, 'New filter option added when DefaultPatronSearchFields is populated with a field'); >- C4::Context->set_preference('DefaultPatronSearchFields',"initials,horses"); >+ is( scalar @filter_options, 13, 'New filter option added when DefaultPatronSearchFields is populated with a field'); >+ is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated'); >+ C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials,horses"); > $driver->get( $base_url . "/members/members-home.pl" ); > @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); > @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >- is( scalar @adv_options, 12, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); >- is( scalar @filter_options, 12, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ is( scalar @adv_options, 13, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ is( scalar @filter_options, 13, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ # NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken > C4::Context->set_preference('DefaultPatronSearchFields',""); >+ $driver->get( $base_url . "/members/members-home.pl" ); > $s->fill_form( { search_patron_filter => 'test_patron' } ); > $s->submit_form; > my $first_patron = $patrons[0]; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30576
:
133543
|
133555
|
133684
|
133685
|
134059
|
134060
|
134084
|
134085
|
134211
|
134212