|
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 => 26; |
64 |
plan tests => 27; |
| 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 79-87
subtest 'Search patrons' => sub {
Link Here
|
| 79 |
value => { category_type => 'A' } |
79 |
value => { category_type => 'A' } |
| 80 |
} |
80 |
} |
| 81 |
); |
81 |
); |
|
|
82 |
push @cleanup, $patron_category; |
| 83 |
|
| 82 |
my $library = $builder->build_object( |
84 |
my $library = $builder->build_object( |
| 83 |
{ class => 'Koha::Libraries', value => { branchname => $branchname } } |
85 |
{ class => 'Koha::Libraries', value => { branchname => $branchname } } |
| 84 |
); |
86 |
); |
|
|
87 |
push @cleanup, $library; |
| 88 |
|
| 85 |
for my $i ( 1 .. 25 ) { |
89 |
for my $i ( 1 .. 25 ) { |
| 86 |
push @patrons, |
90 |
push @patrons, |
| 87 |
$builder->build_object( |
91 |
$builder->build_object( |
|
Lines 115-123
subtest 'Search patrons' => sub {
Link Here
|
| 115 |
} |
119 |
} |
| 116 |
); |
120 |
); |
| 117 |
|
121 |
|
|
|
122 |
unshift @cleanup, $_ for @patrons; |
| 123 |
|
| 118 |
my $library_2 = $builder->build_object( |
124 |
my $library_2 = $builder->build_object( |
| 119 |
{ class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } |
125 |
{ class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } |
| 120 |
); |
126 |
); |
|
|
127 |
push @cleanup, $library_2; |
| 128 |
|
| 121 |
my $patron_27 = |
129 |
my $patron_27 = |
| 122 |
$builder->build_object( |
130 |
$builder->build_object( |
| 123 |
{ |
131 |
{ |
|
Lines 134-140
subtest 'Search patrons' => sub {
Link Here
|
| 134 |
} |
142 |
} |
| 135 |
} |
143 |
} |
| 136 |
); |
144 |
); |
| 137 |
push @patrons, $patron_27; |
145 |
unshift @cleanup, $patron_27; |
| 138 |
|
146 |
|
| 139 |
my $attribute_type = Koha::Patron::Attribute::Type->new( |
147 |
my $attribute_type = Koha::Patron::Attribute::Type->new( |
| 140 |
{ |
148 |
{ |
|
Lines 153-165
subtest 'Search patrons' => sub {
Link Here
|
| 153 |
searched_by_default => 1 |
161 |
searched_by_default => 1 |
| 154 |
} |
162 |
} |
| 155 |
)->store; |
163 |
)->store; |
|
|
164 |
my $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new( |
| 165 |
{ |
| 166 |
code => 'mycode3', |
| 167 |
description => 'my description3', |
| 168 |
opac_display => 1, |
| 169 |
staff_searchable => 1, |
| 170 |
searched_by_default => 0 |
| 171 |
} |
| 172 |
)->store; |
| 173 |
push @cleanup, $attribute_type, $attribute_type_searchable, $attribute_type_searchable_not_default; |
| 174 |
|
| 156 |
$patrons[0]->extended_attributes([ |
175 |
$patrons[0]->extended_attributes([ |
| 157 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
176 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 158 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
177 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
|
|
178 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'}, |
| 159 |
]); |
179 |
]); |
| 160 |
$patrons[1]->extended_attributes([ |
180 |
$patrons[1]->extended_attributes([ |
| 161 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
181 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 162 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
182 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
|
|
183 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'}, |
| 163 |
]); |
184 |
]); |
| 164 |
|
185 |
|
| 165 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
186 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
|
Lines 280-285
subtest 'Search patrons' => sub {
Link Here
|
| 280 |
|
301 |
|
| 281 |
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' ); |
302 |
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' ); |
| 282 |
|
303 |
|
|
|
304 |
# clear form |
| 305 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 306 |
|
| 307 |
# Search on searchable attribute as specific field, we expect 2 patrons |
| 308 |
$s->fill_form( { search_patron_filter => 'test_attr_3' } ); |
| 309 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click(); |
| 310 |
$s->submit_form; |
| 311 |
sleep $DT_delay && $s->wait_for_ajax; |
| 312 |
|
| 313 |
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 as a specific field returns correct results' ); |
| 314 |
|
| 283 |
# Refine search and search for test_patron in all the data using the DT global search |
315 |
# Refine search and search for test_patron in all the data using the DT global search |
| 284 |
# No change in result expected, still 2 patrons |
316 |
# No change in result expected, still 2 patrons |
| 285 |
$s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); |
317 |
$s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); |
|
Lines 395-406
subtest 'Search patrons' => sub {
Link Here
|
| 395 |
$dob_search_filter->clear; |
427 |
$dob_search_filter->clear; |
| 396 |
}; |
428 |
}; |
| 397 |
|
429 |
|
| 398 |
push @cleanup, $_ for @patrons; |
|
|
| 399 |
push @cleanup, $library; |
| 400 |
push @cleanup, $library_2; |
| 401 |
push @cleanup, $patron_category; |
| 402 |
push @cleanup, $attribute_type, $attribute_type_searchable; |
| 403 |
|
| 404 |
$driver->quit(); |
430 |
$driver->quit(); |
| 405 |
}; |
431 |
}; |
| 406 |
|
432 |
|
| 407 |
- |
|
|