Bugzilla – Attachment 145095 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), 6.56 KB, created by
Kyle M Hall
on 2023-01-06 19:18:07 UTC
(
hide
)
Description:
Bug 32559: Add tests
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2023-01-06 19:18:07 UTC
Size:
6.56 KB
patch
obsolete
>From 3f186449f69f2985697913aa19ea1a2f625bcc30 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 | 79 +++++++++++++++++++++--- > 1 file changed, 71 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t >index dac9bcb975..ef0470c8c9 100755 >--- a/t/db_dependent/selenium/patrons_search.t >+++ b/t/db_dependent/selenium/patrons_search.t >@@ -17,9 +17,16 @@ > > use Modern::Perl; > >+my $original_dateformat = C4::Context->preference('dateformat'); >+my $original_DefaultPatronSearchFields = C4::Context->preference('DefaultPatronSearchFields'); >+my $original_PatronsPerPage = C4::Context->preference('PatronsPerPage'); > our @cleanup; > END { >+ > unless ( @cleanup ) { say "WARNING: Cleanup failed!" } >+ C4::Context->set_preference('dateformat', $original_dateformat); >+ C4::Context->set_preference('DefaultPatronSearchFields', $original_DefaultPatronSearchFields); >+ C4::Context->set_preference('PatronsPerPage', $original_PatronsPerPage); > $_->delete for @cleanup; > }; > >@@ -52,7 +59,7 @@ 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 ) { > BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); >@@ -73,8 +80,6 @@ subtest 'Search patrons' => sub { > my $library = $builder->build_object( > { class => 'Koha::Libraries', value => { branchname => $branchname } } > ); >- my $default_patron_search_fields = C4::Context->preference('DefaultPatronSearchFields'); >- my $default_patron_per_page = C4::Context->preference('PatronsPerPage'); > for my $i ( 1 .. 25 ) { > push @patrons, > $builder->build_object( >@@ -111,7 +116,7 @@ subtest 'Search patrons' => sub { > my $library_2 = $builder->build_object( > { class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } > ); >- push @patrons, >+ my $patron_26 = > $builder->build_object( > { > class => 'Koha::Patrons', >@@ -123,9 +128,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( > { >@@ -304,7 +311,7 @@ subtest 'Search patrons' => sub { > '//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 >@@ -313,7 +320,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; >@@ -328,13 +335,69 @@ subtest 'Search patrons' => sub { > $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('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.30.2
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