From 08bec5f8d64bf365e55c4946cdf95fd35cbd941b Mon Sep 17 00:00:00 2001 From: Mason James Date: Sat, 24 Sep 2022 17:39:40 +1200 Subject: [PATCH] Bug 31565: Escape datatables MySQL special characters [FIX TESTS] Content-Type: text/plain; charset="utf-8" this patch removes _/& chars from test queries, as they are now removed via jscript to test: 1/ push patch 2/ note jenkins tests now pass --- t/db_dependent/selenium/patrons_search.t | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t index dac9bcb975..8e0585f3b9 100755 --- a/t/db_dependent/selenium/patrons_search.t +++ b/t/db_dependent/selenium/patrons_search.t @@ -54,7 +54,7 @@ my $schema = Koha::Database->schema; subtest 'Search patrons' => sub { plan tests => 25; - 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; @@ -81,7 +81,7 @@ subtest 'Search patrons' => sub { { class => 'Koha::Patrons', value => { - surname => "test_patron_" . $i++, + surname => "test.patron." . $i++, firstname => $firstname, categorycode => $patron_category->categorycode, branchcode => $library->branchcode, @@ -98,7 +98,7 @@ subtest 'Search patrons' => sub { class => 'Koha::Patrons', value => { surname => "test", - firstname => "not_p_a_t_r_o_n", # won't match 'patron' + firstname => "not._patr0n", # won't match 'patron' categorycode => $patron_category->categorycode, branchcode => $library->branchcode, borrowernotes => $borrowernotes, @@ -116,7 +116,7 @@ subtest 'Search patrons' => sub { { class => 'Koha::Patrons', value => { - surname => "test_patron_26", + surname => "test.patron.26", firstname => $firstname, categorycode => $patron_category->categorycode, branchcode => $library_2->branchcode, @@ -182,7 +182,7 @@ subtest 'Search patrons' => sub { # 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->fill_form( { search_patron_filter => 'test.patron' } ); $s->submit_form; my $first_patron = $patrons[0]; @@ -219,11 +219,11 @@ subtest 'Search patrons' => sub { ); $driver->get( $base_url . "/members/members-home.pl" ); - $s->fill_form( { search_patron_filter => 'test_patron' } ); + $s->fill_form( { search_patron_filter => 'test.patron' } ); $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' ); @@ -267,7 +267,7 @@ subtest 'Search patrons' => sub { # 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' ); @@ -283,7 +283,7 @@ subtest 'Search patrons' => sub { C4::Context->set_preference( 'PatronsPerPage', 5 ); $driver->get( $base_url . "/members/members-home.pl" ); - $s->fill_form( { search_patron_filter => 'test_patron' } ); + $s->fill_form( { search_patron_filter => 'test.patron' } ); $s->submit_form; $s->wait_for_ajax; my $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; @@ -309,7 +309,7 @@ subtest 'Search patrons' => sub { # Perform another search $driver->get( $base_url . "/members/members-home.pl" ); - $s->fill_form( { search_patron_filter => 'test_patron' } ); + $s->fill_form( { search_patron_filter => 'test.patron' } ); $s->submit_form; $s->wait_for_ajax; $patron_selected_text = $driver->find_element('//div[@id="patron_search_selected"]/span')->get_text; -- 2.20.1