Bugzilla – Attachment 153846 Details for
Bug 32559
Support formatted date for column filtering (DT)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32559: Add tests
Bug-32559-Add-tests.patch (text/plain), 26.72 KB, created by
Martin Renvoize
on 2023-07-24 15:47:18 UTC
(
hide
)
Description:
Bug 32559: Add tests
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-07-24 15:47:18 UTC
Size:
26.72 KB
patch
obsolete
>From 5e464f461a67b4d47bede33e87dd79f4beac2759 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 4 Jan 2023 11:13:54 +0100 >Subject: [PATCH] Bug 32559: Add tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/selenium/patrons_search.t | 323 +++++++++++++++++------ > 1 file changed, 235 insertions(+), 88 deletions(-) > >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index a9170f7cc8..aa402233a1 100755 >--- a/t/db_dependent/selenium/patrons_search.t >+++ b/t/db_dependent/selenium/patrons_search.t >@@ -17,11 +17,21 @@ > > use Modern::Perl; > >+my $original_dateformat = C4::Context->preference('dateformat'); >+my $original_DefaultPatronSearchFields = C4::Context->preference('DefaultPatronSearchFields'); >+my $original_DefaultPatronSearchMethod = C4::Context->preference('DefaultPatronSearchMethod'); >+my $original_PatronsPerPage = C4::Context->preference('PatronsPerPage'); > our @cleanup; >+ > END { >- unless ( @cleanup ) { say "WARNING: Cleanup failed!" } >+ >+ unless (@cleanup) { say "WARNING: Cleanup failed!" } >+ C4::Context->set_preference( 'dateformat', $original_dateformat ); >+ C4::Context->set_preference( 'DefaultPatronSearchFields', $original_DefaultPatronSearchFields ); >+ C4::Context->set_preference( 'DefaultPatronSearchMethod', $original_DefaultPatronSearchMethod ); >+ C4::Context->set_preference( 'PatronsPerPage', $original_PatronsPerPage ); > $_->delete for @cleanup; >-}; >+} > > use C4::Context; > >@@ -37,13 +47,12 @@ use t::lib::Selenium; > use t::lib::TestBuilder; > > eval { require Selenium::Remote::Driver; }; >-if ( $@ ) { >+if ($@) { > plan skip_all => "Selenium::Remote::Driver is needed for selenium tests."; > } else { > plan tests => 1; > } > >- > my $s = t::lib::Selenium->new; > my $driver = $s->driver; > my $opac_base_url = $s->opac_base_url; >@@ -52,33 +61,28 @@ my $builder = t::lib::TestBuilder->new; > my $schema = Koha::Database->schema; > > subtest 'Search patrons' => sub { >- plan tests => 25; >+ plan tests => 26; > >- if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { >+ 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"); > } > 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 $email = q|a<strong>bad_email</strong>@example\123 â¤.com|; >- my $patron_category = $builder->build_object( >+ 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 $email = q|a<strong>bad_email</strong>@example\123 â¤.com|; >+ my $patron_category = $builder->build_object( > { > class => 'Koha::Patron::Categories', > value => { category_type => 'A' } > } > ); >- my $library = $builder->build_object( >- { class => 'Koha::Libraries', value => { branchname => $branchname } } >- ); >- my $default_patron_search_fields = C4::Context->preference('DefaultPatronSearchFields'); >- my $default_patron_search_method = C4::Context->preference('DefaultPatronSearchMethod'); >- my $default_patron_per_page = C4::Context->preference('PatronsPerPage'); >+ my $library = $builder->build_object( { class => 'Koha::Libraries', value => { branchname => $branchname } } ); > for my $i ( 1 .. 25 ) { > push @patrons, >- $builder->build_object( >+ $builder->build_object( > { > class => 'Koha::Patrons', > value => { >@@ -91,15 +95,15 @@ subtest 'Search patrons' => sub { > email => $email, > } > } >- ); >+ ); > } > > push @patrons, $builder->build_object( > { > class => 'Koha::Patrons', > value => { >- surname => "test", >- firstname => "not_p_a_t_r_o_n", # won't match 'patron' >+ surname => "test", >+ firstname => "not_p_a_t_r_o_n", # won't match 'patron' > categorycode => $patron_category->categorycode, > branchcode => $library->branchcode, > borrowernotes => $borrowernotes, >@@ -109,11 +113,9 @@ subtest 'Search patrons' => sub { > } > ); > >- my $library_2 = $builder->build_object( >- { class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } >- ); >- push @patrons, >- $builder->build_object( >+ my $library_2 = >+ $builder->build_object( { class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } ); >+ my $patron_26 = $builder->build_object( > { > class => 'Koha::Patrons', > value => { >@@ -124,9 +126,11 @@ subtest 'Search patrons' => sub { > borrowernotes => $borrowernotes, > address => $address, > email => $email, >+ dateofbirth => '1980-06-17', > } > } >- ); >+ ); >+ push @patrons, $patron_26; > > my $attribute_type = Koha::Patron::Attribute::Type->new( > { >@@ -142,79 +146,120 @@ subtest 'Search patrons' => sub { > 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'}, >- ]); >- $patrons[1]->extended_attributes([ >- { code => $attribute_type->code, attribute => 'test_attr_1' }, >- { code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, >- ]); >+ $patrons[0]->extended_attributes( >+ [ >+ { code => $attribute_type->code, attribute => 'test_attr_1' }, >+ { code => $attribute_type_searchable->code, attribute => 'test_attr_2' }, >+ ] >+ ); >+ $patrons[1]->extended_attributes( >+ [ >+ { code => $attribute_type->code, attribute => 'test_attr_1' }, >+ { code => $attribute_type_searchable->code, attribute => 'test_attr_2' }, >+ ] >+ ); > > my $total_number_of_patrons = Koha::Patrons->search->count; >- my $table_id = "memberresultst"; >+ my $table_id = "memberresultst"; > > $s->auth; >- C4::Context->set_preference('DefaultPatronSearchFields',""); >- C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); >- my $PatronsPerPage = 15; >+ C4::Context->set_preference( 'DefaultPatronSearchFields', "" ); >+ C4::Context->set_preference( 'DefaultPatronSearchMethod', "contains" ); >+ my $PatronsPerPage = 15; > my $nb_standard_fields = 13; >- C4::Context->set_preference('PatronsPerPage', $PatronsPerPage); >+ 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, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); >- is( $adv_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set'); >+ is( >+ scalar @adv_options, $nb_standard_fields + 1, >+ 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.' >+ ); >+ is( >+ $adv_options[0]->get_value(), 'firstname,middle_name,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 @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); >- is( $filter_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set'); >- C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials"); >+ is( >+ scalar @filter_options, $nb_standard_fields + 1, >+ 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set' >+ ); >+ is( >+ $filter_options[0]->get_value(), 'firstname,middle_name,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, $nb_standard_fields, 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields'); >- is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated'); >+ is( >+ scalar @adv_options, $nb_standard_fields, >+ 'New option added when DefaultPatronSearchFields is populated with a field. Note that middle_name disappears, we do not want it if not part of DefaultPatronSearchFields' >+ ); >+ 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 @filter_options, $nb_standard_fields, '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"); >+ is( >+ scalar @filter_options, $nb_standard_fields, >+ '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'); >+ @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); > @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); >- is( scalar @adv_options, $nb_standard_fields, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); >- is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); >+ is( >+ scalar @adv_options, $nb_standard_fields, >+ 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field' >+ ); >+ is( >+ scalar @filter_options, $nb_standard_fields, >+ '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',""); >+ 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]; > > $s->wait_for_ajax; >- my @td = $driver->find_elements('//table[@id="'.$table_id.'"]/tbody/tr/td'); >- like ($td[2]->get_text, qr[\Q$firstname\E], >+ my @td = $driver->find_elements( '//table[@id="' . $table_id . '"]/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], >+ like( >+ $td[2]->get_text, qr[\Q$address\E], > 'Column "Name" should be the 3rd and contain the address correctly filtered' > ); >- like ($td[2]->get_text, qr[\Q$email\E], >+ like( >+ $td[2]->get_text, qr[\Q$email\E], > 'Column "Name" should be the 3rd and contain the email address correctly filtered' > ); >- is( $td[4]->get_text, $branchname, >+ is( >+ $td[4]->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, >+ 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; >+ '//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' >+ . $first_patron->borrowernumber >+ . '"]' )->click; > is( > $driver->get_title, > sprintf( > "Modify patron %s %s %s (%s) %s (%s) (%s) ⺠Patrons ⺠Koha", >- $first_patron->title, $first_patron->firstname, $first_patron->middle_name, $first_patron->othernames, $first_patron->surname, $first_patron->cardnumber, >+ $first_patron->title, $first_patron->firstname, $first_patron->middle_name, $first_patron->othernames, >+ $first_patron->surname, $first_patron->cardnumber, > $first_patron->category->description, > ), > 'Page title is correct after following modification link' >@@ -225,13 +270,31 @@ subtest 'Search patrons' => sub { > $s->submit_form; > $s->wait_for_ajax; > >- $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); >+ $s->driver->find_element( '//*[@id="' . $table_id . '_filter"]//input' )->send_keys('test_patron'); > $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), 'Searching in standard brings back correct results' ); >+ 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 >+ ), >+ 'Searching in standard brings back correct results' >+ ); > >- $s->driver->find_element('//table[@id="'.$table_id.'"]//th[@data-filter="libraries"]/select/option[@value="'.$library->branchcode.'"]')->click; >+ $s->driver->find_element( '//table[@id="' >+ . $table_id >+ . '"]//th[@data-filter="libraries"]/select/option[@value="' >+ . $library->branchcode >+ . '"]' )->click; > $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, 25, $total_number_of_patrons), 'Filtering on library works in combination with main search' ); >+ 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, 25, >+ $total_number_of_patrons >+ ), >+ 'Filtering on library works in combination with main search' >+ ); > > # Reset the filters > $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); >@@ -239,14 +302,24 @@ subtest 'Search patrons' => sub { > $s->wait_for_ajax; > > # And make sure all the patrons are present >- is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('Showing 1 to %s of %s entries', $PatronsPerPage, $total_number_of_patrons), 'Resetting filters works as expected' ); >+ is( >+ $driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, >+ sprintf( 'Showing 1 to %s of %s entries', $PatronsPerPage, $total_number_of_patrons ), >+ 'Resetting filters works as expected' >+ ); > > # Pattern terms must be split > $s->fill_form( { search_patron_filter => 'test patron' } ); > $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)', $PatronsPerPage, 26, $total_number_of_patrons) ); >+ 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 >+ ) >+ ); > $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); > $s->submit_form; > $s->wait_for_ajax; >@@ -256,28 +329,46 @@ subtest 'Search patrons' => sub { > $s->submit_form; > $s->wait_for_ajax; > >- 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' ); >+ 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(); >+ > # Search on searchable attribute, we expect 2 patrons > $s->fill_form( { search_patron_filter => 'test_attr_2' } ); > $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' ); >+ 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' >+ ); > > # Refine search and search for test_patron in all the data using the DT global search > # No change in result expected, still 2 patrons >- $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); >+ $s->driver->find_element( '//*[@id="' . $table_id . '_filter"]//input' )->send_keys('test_patron'); > $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), 'Refining with DataTables search works to further filter the original query' ); >+ 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 ), >+ 'Refining with DataTables search works to further filter the original query' >+ ); > > # Adding the surname of the first patron in the "Name" column > # We expect only 1 result >- $s->driver->find_element('//table[@id="'.$table_id.'"]//input[@placeholder="Name search"]')->send_keys($patrons[0]->surname); >+ $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Name search"]' ) >+ ->send_keys( $patrons[0]->surname ); > $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' ); >+ 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 'remember_search' => sub { > >@@ -291,8 +382,7 @@ subtest 'Search patrons' => sub { > my $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; > is( $patron_selected_text, "", "Patrons selected is not displayed" ); > >- my @checkboxes = $driver->find_elements( >- '//input[@type="checkbox"][@name="borrowernumber"]'); >+ my @checkboxes = $driver->find_elements('//input[@type="checkbox"][@name="borrowernumber"]'); > $checkboxes[2]->click; > $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; > is( $patron_selected_text, "Patrons selected: 1", "One patron selected" ); >@@ -303,12 +393,10 @@ subtest 'Search patrons' => sub { > > $driver->find_element('//*[@id="memberresultst_next"]')->click; > $s->wait_for_ajax; >- @checkboxes = $driver->find_elements( >- '//input[@type="checkbox"][@name="borrowernumber"]'); >+ @checkboxes = $driver->find_elements('//input[@type="checkbox"][@name="borrowernumber"]'); > $checkboxes[0]->click; > $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; >- is( $patron_selected_text, "Patrons selected: 3", "Tree patrons are selected" ); >- >+ is( $patron_selected_text, "Patrons selected: 3", "Three patrons are selected" ); > > # Perform another search > $driver->get( $base_url . "/members/members-home.pl" ); >@@ -316,7 +404,7 @@ subtest 'Search patrons' => sub { > $s->submit_form; > $s->wait_for_ajax; > $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; >- is( $patron_selected_text, "Patrons selected: 3", "Tree patrons still selected" ); >+ is( $patron_selected_text, "Patrons selected: 3", "Three patrons still selected" ); > > $driver->find_element('//*[@id="patronlist-menu"]')->click; > $driver->find_element('//a[@class="patron-list-add"]')->click; >@@ -325,20 +413,79 @@ subtest 'Search patrons' => sub { > $driver->find_element('//button[@id="add_to_patron_list_submit"]')->click; > $s->wait_for_ajax; > is( $driver->find_element('//*[@id="patron_list_dialog"]')->get_text, "Added 3 patrons to $patron_list_name." ); >- my $patron_list = $schema->resultset('PatronList')->search({ name => $patron_list_name })->next; >- is( $schema->resultset('PatronListPatron')->search({ patron_list_id => $patron_list->patron_list_id })->count, 3 ); >+ my $patron_list = $schema->resultset('PatronList')->search( { name => $patron_list_name } )->next; >+ is( >+ $schema->resultset('PatronListPatron')->search( { patron_list_id => $patron_list->patron_list_id } )->count, >+ 3 >+ ); > > $patron_list->delete; > }; > >+ subtest 'filter by date of birth' => sub { >+ plan tests => 7; >+ >+ C4::Context->set_preference( 'dateformat', 'metric' ); >+ >+ # We have a patron with date of birth=1980-06-17 => formatted as 17/06/1980 >+ >+ $driver->get( $base_url . "/members/members-home.pl" ); >+ $s->fill_form( { search_patron_filter => 'test_patron' } ); >+ $s->submit_form; >+ $s->wait_for_ajax; >+ >+ $s->show_all_entries( '//div[@id="' . $table_id . '_wrapper"]' ); >+ my $dob_search_filter = >+ $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Date of birth search"]' ); >+ >+ $dob_search_filter->send_keys('1980'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 1, 'search by correct year shows the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('1986'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 0, 'search by incorrect year does not show the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('1980-06'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 1, 'search by correct year-month shows the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('1980-06-17'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 1, 'search by correct full iso date shows the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('1986-06-17'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 0, 'search by incorrect full iso date does not show the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('17/06/1980'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 1, 'search by correct full formatted date shows the patron' ); >+ $dob_search_filter->clear; >+ >+ $dob_search_filter->send_keys('17/06/1986'); >+ $s->wait_for_ajax; >+ is( is_patron_shown($patron_26), 0, 'search by incorrect full formatted date does not show the patron' ); >+ $dob_search_filter->clear; >+ }; >+ > push @cleanup, $_ for @patrons; > push @cleanup, $library; > push @cleanup, $library_2; > push @cleanup, $patron_category; > push @cleanup, $attribute_type, $attribute_type_searchable; >- C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields); >- C4::Context->set_preference('DefaultPatronSearchMethod',$default_patron_search_method); >- C4::Context->set_preference('PatronsPerPage',$default_patron_per_page); > > $driver->quit(); > }; >+ >+sub is_patron_shown { >+ my ($patron) = @_; >+ >+ my @checkboxes = $driver->find_elements('//input[@type="checkbox"][@name="borrowernumber"]'); >+ return scalar( grep { $_->get_value == $patron->borrowernumber } @checkboxes ); >+} >-- >2.41.0
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 32559
:
144951
|
144954
|
144977
|
145094
|
145095
|
145136
|
153845
| 153846 |
153847