|
Lines 61-67
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 61 |
my $schema = Koha::Database->schema; |
61 |
my $schema = Koha::Database->schema; |
| 62 |
|
62 |
|
| 63 |
subtest 'Search patrons' => sub { |
63 |
subtest 'Search patrons' => sub { |
| 64 |
plan tests => 27; |
64 |
plan tests => 28; |
| 65 |
|
65 |
|
| 66 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
66 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
| 67 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
67 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
|
Lines 427-432
subtest 'Search patrons' => sub {
Link Here
|
| 427 |
$dob_search_filter->clear; |
427 |
$dob_search_filter->clear; |
| 428 |
}; |
428 |
}; |
| 429 |
|
429 |
|
|
|
430 |
subtest 'no clause for extended_attributes when none are default searchable' => sub { |
| 431 |
$attribute_type_searchable->update( { searched_by_default => 0 } ); |
| 432 |
|
| 433 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 434 |
|
| 435 |
$driver->execute_script( <<'EOF', 'capture_ajax_data' ); |
| 436 |
jQuery( document ).on( "ajaxSend", function( event, request, settings ) { |
| 437 |
jQuery('#patron_search_form').after('<div id="capture_ajax_data_was_executed"></div>'); |
| 438 |
var url = new URL(window.location.origin + settings.url); |
| 439 |
var parts = url.search.substring(1).split('&'); |
| 440 |
var q; |
| 441 |
for (var i = 0 ; i < parts.length ; i++) { |
| 442 |
var p = parts[i].split('='); |
| 443 |
if (p[0] === 'q') { |
| 444 |
q = JSON.parse(decodeURIComponent(p[1])); |
| 445 |
break; |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
for (var i = 0; i < q.length; i++) { |
| 450 |
var q0 = q[i]['-and']; |
| 451 |
for (var j = 0; q0 && j < q0.length; j++) { |
| 452 |
for (var k = 0; k < q0[j].length; k++) { |
| 453 |
if (q0[j][k].hasOwnProperty('extended_attributes.code')) { |
| 454 |
jQuery('#patron_search_form').after('<div id="had_extended_attributes_clause"></div>'); |
| 455 |
} |
| 456 |
} |
| 457 |
} |
| 458 |
} |
| 459 |
} ); |
| 460 |
EOF |
| 461 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
| 462 |
$s->submit_form; |
| 463 |
sleep $DT_delay && $s->wait_for_ajax; |
| 464 |
my $e1 = $driver->find_elements( 'capture_ajax_data_was_executed', 'id' ); |
| 465 |
is( scalar(@$e1), 1, 'the capture script was executed' ); |
| 466 |
my $e2 = $driver->find_elements( 'had_extended_attributes_clause', 'id' ); |
| 467 |
is( scalar(@$e2), 0, 'there were no extended attributes on the search clause' ); |
| 468 |
|
| 469 |
}; |
| 470 |
|
| 430 |
$driver->quit(); |
471 |
$driver->quit(); |
| 431 |
}; |
472 |
}; |
| 432 |
|
473 |
|
| 433 |
- |
|
|