|
Lines 25-37
our @cleanup;
Link Here
|
| 25 |
our $DT_delay = 1; |
25 |
our $DT_delay = 1; |
| 26 |
|
26 |
|
| 27 |
END { |
27 |
END { |
| 28 |
unless ( @cleanup ) { say "WARNING: Cleanup failed!" } |
28 |
unless (@cleanup) { say "WARNING: Cleanup failed!" } |
| 29 |
C4::Context->set_preference( 'dateformat', $original_dateformat ); |
29 |
C4::Context->set_preference( 'dateformat', $original_dateformat ); |
| 30 |
C4::Context->set_preference( 'DefaultPatronSearchFields', $original_DefaultPatronSearchFields ); |
30 |
C4::Context->set_preference( 'DefaultPatronSearchFields', $original_DefaultPatronSearchFields ); |
| 31 |
C4::Context->set_preference( 'DefaultPatronSearchMethod', $original_DefaultPatronSearchMethod ); |
31 |
C4::Context->set_preference( 'DefaultPatronSearchMethod', $original_DefaultPatronSearchMethod ); |
| 32 |
C4::Context->set_preference( 'PatronsPerPage', $original_PatronsPerPage ); |
32 |
C4::Context->set_preference( 'PatronsPerPage', $original_PatronsPerPage ); |
| 33 |
$_->delete for @cleanup; |
33 |
$_->delete for @cleanup; |
| 34 |
}; |
34 |
} |
| 35 |
|
35 |
|
| 36 |
use C4::Context; |
36 |
use C4::Context; |
| 37 |
|
37 |
|
|
Lines 47-53
use t::lib::Selenium;
Link Here
|
| 47 |
use t::lib::TestBuilder; |
47 |
use t::lib::TestBuilder; |
| 48 |
|
48 |
|
| 49 |
eval { require Selenium::Remote::Driver; }; |
49 |
eval { require Selenium::Remote::Driver; }; |
| 50 |
if ( $@ ) { |
50 |
if ($@) { |
| 51 |
plan skip_all => "Selenium::Remote::Driver is needed for selenium tests."; |
51 |
plan skip_all => "Selenium::Remote::Driver is needed for selenium tests."; |
| 52 |
} else { |
52 |
} else { |
| 53 |
plan tests => 1; |
53 |
plan tests => 1; |
|
Lines 63-79
my $schema = Koha::Database->schema;
Link Here
|
| 63 |
subtest 'Search patrons' => sub { |
63 |
subtest 'Search patrons' => sub { |
| 64 |
plan tests => 28; |
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"); |
| 68 |
} |
68 |
} |
| 69 |
my @patrons; |
69 |
my @patrons; |
| 70 |
my $borrowernotes = q|<strong>just 'a" note</strong> \123 ❤|; |
70 |
my $borrowernotes = q|<strong>just 'a" note</strong> \123 ❤|; |
| 71 |
my $borrowernotes_displayed = q|just 'a" note \123 ❤|; |
71 |
my $borrowernotes_displayed = q|just 'a" note \123 ❤|; |
| 72 |
my $branchname = q|<strong>just 'another" library</strong> \123 ❤|; |
72 |
my $branchname = q|<strong>just 'another" library</strong> \123 ❤|; |
| 73 |
my $firstname = q|<strong>fir's"tname</strong> \123 ❤|; |
73 |
my $firstname = q|<strong>fir's"tname</strong> \123 ❤|; |
| 74 |
my $address = q|<strong>add'res"s</strong> \123 ❤|; |
74 |
my $address = q|<strong>add'res"s</strong> \123 ❤|; |
| 75 |
my $email = q|a<strong>bad_email</strong>@example\123 ❤.com|; |
75 |
my $email = q|a<strong>bad_email</strong>@example\123 ❤.com|; |
| 76 |
my $patron_category = $builder->build_object( |
76 |
my $patron_category = $builder->build_object( |
| 77 |
{ |
77 |
{ |
| 78 |
class => 'Koha::Patron::Categories', |
78 |
class => 'Koha::Patron::Categories', |
| 79 |
value => { category_type => 'A' } |
79 |
value => { category_type => 'A' } |
|
Lines 81-94
subtest 'Search patrons' => sub {
Link Here
|
| 81 |
); |
81 |
); |
| 82 |
push @cleanup, $patron_category; |
82 |
push @cleanup, $patron_category; |
| 83 |
|
83 |
|
| 84 |
my $library = $builder->build_object( |
84 |
my $library = $builder->build_object( { class => 'Koha::Libraries', value => { branchname => $branchname } } ); |
| 85 |
{ class => 'Koha::Libraries', value => { branchname => $branchname } } |
|
|
| 86 |
); |
| 87 |
push @cleanup, $library; |
85 |
push @cleanup, $library; |
| 88 |
|
86 |
|
| 89 |
for my $i ( 1 .. 25 ) { |
87 |
for my $i ( 1 .. 25 ) { |
| 90 |
push @patrons, |
88 |
push @patrons, |
| 91 |
$builder->build_object( |
89 |
$builder->build_object( |
| 92 |
{ |
90 |
{ |
| 93 |
class => 'Koha::Patrons', |
91 |
class => 'Koha::Patrons', |
| 94 |
value => { |
92 |
value => { |
|
Lines 101-107
subtest 'Search patrons' => sub {
Link Here
|
| 101 |
email => $email, |
99 |
email => $email, |
| 102 |
} |
100 |
} |
| 103 |
} |
101 |
} |
| 104 |
); |
102 |
); |
| 105 |
} |
103 |
} |
| 106 |
|
104 |
|
| 107 |
push @patrons, $builder->build_object( |
105 |
push @patrons, $builder->build_object( |
|
Lines 121-133
subtest 'Search patrons' => sub {
Link Here
|
| 121 |
|
119 |
|
| 122 |
unshift @cleanup, $_ for @patrons; |
120 |
unshift @cleanup, $_ for @patrons; |
| 123 |
|
121 |
|
| 124 |
my $library_2 = $builder->build_object( |
122 |
my $library_2 = |
| 125 |
{ class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } |
123 |
$builder->build_object( { class => 'Koha::Libraries', value => { branchname => 'X' . $branchname } } ); |
| 126 |
); |
|
|
| 127 |
push @cleanup, $library_2; |
124 |
push @cleanup, $library_2; |
| 128 |
|
125 |
|
| 129 |
my $patron_27 = |
126 |
my $patron_27 = $builder->build_object( |
| 130 |
$builder->build_object( |
|
|
| 131 |
{ |
127 |
{ |
| 132 |
class => 'Koha::Patrons', |
128 |
class => 'Koha::Patrons', |
| 133 |
value => { |
129 |
value => { |
|
Lines 141-264
subtest 'Search patrons' => sub {
Link Here
|
| 141 |
dateofbirth => '1980-06-17', |
137 |
dateofbirth => '1980-06-17', |
| 142 |
} |
138 |
} |
| 143 |
} |
139 |
} |
| 144 |
); |
140 |
); |
| 145 |
unshift @cleanup, $patron_27; |
141 |
unshift @cleanup, $patron_27; |
| 146 |
|
142 |
|
| 147 |
my $attribute_type = Koha::Patron::Attribute::Type->new( |
143 |
my $attribute_type = Koha::Patron::Attribute::Type->new( |
| 148 |
{ |
144 |
{ |
| 149 |
code => 'my code1', |
145 |
code => 'my code1', |
| 150 |
description => 'my description1', |
146 |
description => 'my description1', |
| 151 |
staff_searchable => 0, |
147 |
staff_searchable => 0, |
| 152 |
searched_by_default => 0 |
148 |
searched_by_default => 0 |
| 153 |
} |
149 |
} |
| 154 |
)->store; |
150 |
)->store; |
| 155 |
my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( |
151 |
my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( |
| 156 |
{ |
152 |
{ |
| 157 |
code => 'my code2', |
153 |
code => 'my code2', |
| 158 |
description => 'my description2', |
154 |
description => 'my description2', |
| 159 |
opac_display => 1, |
155 |
opac_display => 1, |
| 160 |
staff_searchable => 1, |
156 |
staff_searchable => 1, |
| 161 |
searched_by_default => 1 |
157 |
searched_by_default => 1 |
| 162 |
} |
158 |
} |
| 163 |
)->store; |
159 |
)->store; |
| 164 |
my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( |
160 |
my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( |
| 165 |
{ |
161 |
{ |
| 166 |
code => 'my code3', |
162 |
code => 'my code3', |
| 167 |
description => 'my description3', |
163 |
description => 'my description3', |
| 168 |
opac_display => 1, |
164 |
opac_display => 1, |
| 169 |
staff_searchable => 1, |
165 |
staff_searchable => 1, |
| 170 |
searched_by_default => 1 |
166 |
searched_by_default => 1 |
| 171 |
} |
167 |
} |
| 172 |
)->store; |
168 |
)->store; |
| 173 |
my $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new( |
169 |
my $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new( |
| 174 |
{ |
170 |
{ |
| 175 |
code => 'mycode4', |
171 |
code => 'mycode4', |
| 176 |
description => 'my description4', |
172 |
description => 'my description4', |
| 177 |
opac_display => 1, |
173 |
opac_display => 1, |
| 178 |
staff_searchable => 1, |
174 |
staff_searchable => 1, |
| 179 |
searched_by_default => 0 |
175 |
searched_by_default => 0 |
| 180 |
} |
176 |
} |
| 181 |
)->store; |
177 |
)->store; |
| 182 |
push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, $attribute_type_searchable_not_default; |
178 |
push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, |
| 183 |
|
179 |
$attribute_type_searchable_not_default; |
| 184 |
$patrons[0]->extended_attributes([ |
180 |
|
| 185 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
181 |
$patrons[0]->extended_attributes( |
| 186 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
182 |
[ |
| 187 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'}, |
183 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 188 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'}, |
184 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2' }, |
| 189 |
]); |
185 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3' }, |
| 190 |
$patrons[1]->extended_attributes([ |
186 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4' }, |
| 191 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
187 |
] |
| 192 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
188 |
); |
| 193 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'}, |
189 |
$patrons[1]->extended_attributes( |
| 194 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'}, |
190 |
[ |
| 195 |
]); |
191 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
|
|
192 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2' }, |
| 193 |
{ code => $attribute_type_searchable_2->code, attribute => 'test_attr_3' }, |
| 194 |
{ code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4' }, |
| 195 |
] |
| 196 |
); |
| 196 |
|
197 |
|
| 197 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
198 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
| 198 |
my $table_id = "memberresultst"; |
199 |
my $table_id = "memberresultst"; |
| 199 |
|
200 |
|
| 200 |
$s->auth; |
201 |
$s->auth; |
| 201 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
202 |
C4::Context->set_preference( 'DefaultPatronSearchFields', "" ); |
| 202 |
C4::Context->set_preference('DefaultPatronSearchMethod',"contains"); |
203 |
C4::Context->set_preference( 'DefaultPatronSearchMethod', "contains" ); |
| 203 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search({ staff_searchable => 1 })->count(); |
204 |
my $searchable_attributes = Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->count(); |
| 204 |
my $PatronsPerPage = 15; |
205 |
my $PatronsPerPage = 15; |
| 205 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
206 |
my $nb_standard_fields = 13 + $searchable_attributes; # Standard fields, plus one searchable attribute |
| 206 |
C4::Context->set_preference('PatronsPerPage', $PatronsPerPage); |
207 |
C4::Context->set_preference( 'PatronsPerPage', $PatronsPerPage ); |
| 207 |
$driver->get( $base_url . "/members/members-home.pl" ); |
208 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 208 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
209 |
my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 209 |
is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.'); |
210 |
is( |
| 210 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"'); |
211 |
scalar @adv_options, $nb_standard_fields + 1, |
|
|
212 |
'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.' |
| 213 |
); |
| 214 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"' ); |
| 211 |
my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
215 |
my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
| 212 |
is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set'); |
216 |
is( |
| 213 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set'); |
217 |
scalar @filter_options, $nb_standard_fields + 1, |
| 214 |
C4::Context->set_preference('DefaultPatronSearchFields',"firstname|initials"); |
218 |
'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set' |
|
|
219 |
); |
| 220 |
is( |
| 221 |
$filter_options[0]->get_value(), 'standard', |
| 222 |
'Standard filter uses hard coded value "standard" DefaultPatronSearchFields not set' |
| 223 |
); |
| 224 |
C4::Context->set_preference( 'DefaultPatronSearchFields', "firstname|initials" ); |
| 215 |
$driver->get( $base_url . "/members/members-home.pl" ); |
225 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 216 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
226 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 217 |
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'); |
227 |
is( |
| 218 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"'); |
228 |
scalar @adv_options, $nb_standard_fields, |
|
|
229 |
'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' |
| 230 |
); |
| 231 |
is( $adv_options[0]->get_value(), 'standard', 'Standard search uses value "standard"' ); |
| 219 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
232 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
| 220 |
is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field'); |
233 |
is( |
| 221 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"'); |
234 |
scalar @filter_options, $nb_standard_fields, |
|
|
235 |
'New filter option added when DefaultPatronSearchFields is populated with a field' |
| 236 |
); |
| 237 |
is( $filter_options[0]->get_value(), 'standard', 'Standard filter uses value "standard"' ); |
| 222 |
$driver->get( $base_url . "/members/members-home.pl" ); |
238 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 223 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
239 |
@adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option'); |
| 224 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
240 |
@filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option'); |
| 225 |
is( scalar @adv_options, $nb_standard_fields, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); |
241 |
is( |
| 226 |
is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); |
242 |
scalar @adv_options, $nb_standard_fields, |
|
|
243 |
'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field' |
| 244 |
); |
| 245 |
is( |
| 246 |
scalar @filter_options, $nb_standard_fields, |
| 247 |
'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field' |
| 248 |
); |
| 227 |
|
249 |
|
| 228 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
250 |
# NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken |
| 229 |
C4::Context->set_preference('DefaultPatronSearchFields',""); |
251 |
C4::Context->set_preference( 'DefaultPatronSearchFields', "" ); |
| 230 |
$driver->get( $base_url . "/members/members-home.pl" ); |
252 |
$driver->get( $base_url . "/members/members-home.pl" ); |
| 231 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
253 |
$s->fill_form( { search_patron_filter => 'test_patron' } ); |
| 232 |
$s->submit_form; |
254 |
$s->submit_form; |
| 233 |
my $first_patron = $patrons[0]; |
255 |
my $first_patron = $patrons[0]; |
| 234 |
|
256 |
|
| 235 |
sleep $DT_delay && $s->wait_for_ajax; |
257 |
sleep $DT_delay && $s->wait_for_ajax; |
| 236 |
my @td = $driver->find_elements('//table[@id="'.$table_id.'"]/tbody/tr/td'); |
258 |
my @td = $driver->find_elements( '//table[@id="' . $table_id . '"]/tbody/tr/td' ); |
| 237 |
like ($td[2]->get_text, qr[\Q$firstname\E], |
259 |
like( |
|
|
260 |
$td[2]->get_text, qr[\Q$firstname\E], |
| 238 |
'Column "Name" should be the 3rd and contain the firstname correctly filtered' |
261 |
'Column "Name" should be the 3rd and contain the firstname correctly filtered' |
| 239 |
); |
262 |
); |
| 240 |
like ($td[2]->get_text, qr[\Q$address\E], |
263 |
like( |
|
|
264 |
$td[2]->get_text, qr[\Q$address\E], |
| 241 |
'Column "Name" should be the 3rd and contain the address correctly filtered' |
265 |
'Column "Name" should be the 3rd and contain the address correctly filtered' |
| 242 |
); |
266 |
); |
| 243 |
like ($td[2]->get_text, qr[\Q$email\E], |
267 |
like( |
|
|
268 |
$td[2]->get_text, qr[\Q$email\E], |
| 244 |
'Column "Name" should be the 3rd and contain the email address correctly filtered' |
269 |
'Column "Name" should be the 3rd and contain the email address correctly filtered' |
| 245 |
); |
270 |
); |
| 246 |
is( $td[4]->get_text, $branchname, |
271 |
is( |
|
|
272 |
$td[4]->get_text, $branchname, |
| 247 |
'Column "Library" should be the 6th and contain the html tags - they have been html filtered' |
273 |
'Column "Library" should be the 6th and contain the html tags - they have been html filtered' |
| 248 |
); |
274 |
); |
| 249 |
is( $td[9]->get_text, $borrowernotes_displayed, |
275 |
is( |
|
|
276 |
$td[9]->get_text, $borrowernotes_displayed, |
| 250 |
'Column "Circ note" should be the 10th and not contain the html tags - they have not been html filtered' |
277 |
'Column "Circ note" should be the 10th and not contain the html tags - they have not been html filtered' |
| 251 |
); |
278 |
); |
| 252 |
|
279 |
|
| 253 |
$driver->find_element( |
280 |
$driver->find_element( |
| 254 |
'//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' |
281 |
'//a[@href="/cgi-bin/koha/members/memberentry.pl?op=modify&destination=circ&borrowernumber=' |
| 255 |
. $first_patron->borrowernumber |
282 |
. $first_patron->borrowernumber |
| 256 |
. '"]' )->click; |
283 |
. '"]' )->click; |
| 257 |
is( |
284 |
is( |
| 258 |
$driver->get_title, |
285 |
$driver->get_title, |
| 259 |
sprintf( |
286 |
sprintf( |
| 260 |
"Modify patron %s %s %s (%s) %s (%s) (%s) › Patrons › Koha", |
287 |
"Modify patron %s %s %s (%s) %s (%s) (%s) › Patrons › Koha", |
| 261 |
$first_patron->title, $first_patron->firstname, $first_patron->middle_name, $first_patron->othernames, $first_patron->surname, $first_patron->cardnumber, |
288 |
$first_patron->title, $first_patron->firstname, $first_patron->middle_name, $first_patron->othernames, |
|
|
289 |
$first_patron->surname, $first_patron->cardnumber, |
| 262 |
$first_patron->category->description, |
290 |
$first_patron->category->description, |
| 263 |
), |
291 |
), |
| 264 |
'Page title is correct after following modification link' |
292 |
'Page title is correct after following modification link' |
|
Lines 269-281
subtest 'Search patrons' => sub {
Link Here
|
| 269 |
$s->submit_form; |
297 |
$s->submit_form; |
| 270 |
sleep $DT_delay && $s->wait_for_ajax; |
298 |
sleep $DT_delay && $s->wait_for_ajax; |
| 271 |
|
299 |
|
| 272 |
$s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); |
300 |
$s->driver->find_element( '//*[@id="' . $table_id . '_filter"]//input' )->send_keys('test_patron'); |
| 273 |
sleep $DT_delay && $s->wait_for_ajax; |
301 |
sleep $DT_delay && $s->wait_for_ajax; |
| 274 |
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' ); |
302 |
is( |
|
|
303 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 304 |
sprintf( |
| 305 |
'Showing 1 to %s of %s entries (filtered from %s total entries)', $PatronsPerPage, 26, |
| 306 |
$total_number_of_patrons |
| 307 |
), |
| 308 |
'Searching in standard brings back correct results' |
| 309 |
); |
| 275 |
|
310 |
|
| 276 |
$s->driver->find_element('//table[@id="'.$table_id.'"]//th[@data-filter="libraries"]/select/option[@value="'.$library->branchcode.'"]')->click; |
311 |
$s->driver->find_element( '//table[@id="' |
|
|
312 |
. $table_id |
| 313 |
. '"]//th[@data-filter="libraries"]/select/option[@value="' |
| 314 |
. $library->branchcode |
| 315 |
. '"]' )->click; |
| 277 |
sleep $DT_delay && $s->wait_for_ajax; |
316 |
sleep $DT_delay && $s->wait_for_ajax; |
| 278 |
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' ); |
317 |
is( |
|
|
318 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 319 |
sprintf( |
| 320 |
'Showing 1 to %s of %s entries (filtered from %s total entries)', $PatronsPerPage, 25, |
| 321 |
$total_number_of_patrons |
| 322 |
), |
| 323 |
'Filtering on library works in combination with main search' |
| 324 |
); |
| 279 |
|
325 |
|
| 280 |
# Reset the filters |
326 |
# Reset the filters |
| 281 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
327 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
|
Lines 283-296
subtest 'Search patrons' => sub {
Link Here
|
| 283 |
sleep $DT_delay && $s->wait_for_ajax; |
329 |
sleep $DT_delay && $s->wait_for_ajax; |
| 284 |
|
330 |
|
| 285 |
# And make sure all the patrons are present |
331 |
# And make sure all the patrons are present |
| 286 |
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' ); |
332 |
is( |
|
|
333 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 334 |
sprintf( 'Showing 1 to %s of %s entries', $PatronsPerPage, $total_number_of_patrons ), |
| 335 |
'Resetting filters works as expected' |
| 336 |
); |
| 287 |
|
337 |
|
| 288 |
# Pattern terms must be split |
338 |
# Pattern terms must be split |
| 289 |
$s->fill_form( { search_patron_filter => 'test patron' } ); |
339 |
$s->fill_form( { search_patron_filter => 'test patron' } ); |
| 290 |
$s->submit_form; |
340 |
$s->submit_form; |
| 291 |
|
341 |
|
| 292 |
sleep $DT_delay && $s->wait_for_ajax; |
342 |
sleep $DT_delay && $s->wait_for_ajax; |
| 293 |
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) ); |
343 |
is( |
|
|
344 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 345 |
sprintf( |
| 346 |
'Showing 1 to %s of %s entries (filtered from %s total entries)', $PatronsPerPage, 26, |
| 347 |
$total_number_of_patrons |
| 348 |
) |
| 349 |
); |
| 294 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
350 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 295 |
$s->submit_form; |
351 |
$s->submit_form; |
| 296 |
sleep $DT_delay && $s->wait_for_ajax; |
352 |
sleep $DT_delay && $s->wait_for_ajax; |
|
Lines 300-306
subtest 'Search patrons' => sub {
Link Here
|
| 300 |
$s->submit_form; |
356 |
$s->submit_form; |
| 301 |
sleep $DT_delay && $s->wait_for_ajax; |
357 |
sleep $DT_delay && $s->wait_for_ajax; |
| 302 |
|
358 |
|
| 303 |
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' ); |
359 |
is( |
|
|
360 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 361 |
sprintf( 'No entries to show (filtered from %s total entries)', $total_number_of_patrons ), |
| 362 |
'Searching on a non-searchable attribute returns no results' |
| 363 |
); |
| 304 |
|
364 |
|
| 305 |
# clear form |
365 |
# clear form |
| 306 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
366 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
|
Lines 310-348
subtest 'Search patrons' => sub {
Link Here
|
| 310 |
$s->submit_form; |
370 |
$s->submit_form; |
| 311 |
sleep $DT_delay && $s->wait_for_ajax; |
371 |
sleep $DT_delay && $s->wait_for_ajax; |
| 312 |
|
372 |
|
| 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 returns correct results' ); |
373 |
is( |
|
|
374 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 375 |
sprintf( 'Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons ), |
| 376 |
'Searching on a searchable attribute returns correct results' |
| 377 |
); |
| 314 |
|
378 |
|
| 315 |
# clear form |
379 |
# clear form |
| 316 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
380 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 317 |
|
381 |
|
| 318 |
$s->fill_form( { search_patron_filter => 'test_attr_3' } ); # Terms must be split |
382 |
$s->fill_form( { search_patron_filter => 'test_attr_3' } ); # Terms must be split |
| 319 |
$s->submit_form; |
383 |
$s->submit_form; |
| 320 |
sleep $DT_delay && $s->wait_for_ajax; |
384 |
sleep $DT_delay && $s->wait_for_ajax; |
| 321 |
|
385 |
|
| 322 |
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' ); |
386 |
is( |
|
|
387 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 388 |
sprintf( 'Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons ), |
| 389 |
'Searching on a searchable attribute returns correct results' |
| 390 |
); |
| 323 |
|
391 |
|
| 324 |
# clear form |
392 |
# clear form |
| 325 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
393 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 326 |
|
394 |
|
| 327 |
# Search on searchable attribute as specific field, we expect 2 patrons |
395 |
# Search on searchable attribute as specific field, we expect 2 patrons |
| 328 |
$s->fill_form( { search_patron_filter => 'test_attr_4' } ); |
396 |
$s->fill_form( { search_patron_filter => 'test_attr_4' } ); |
| 329 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click(); |
397 |
$driver->find_element( '//form[@id="patron_search_form"]//*[@id="searchfieldstype_filter"]//option[@value="_ATTR_' |
|
|
398 |
. $attribute_type_searchable_not_default->code |
| 399 |
. '"]' )->click(); |
| 330 |
$s->submit_form; |
400 |
$s->submit_form; |
| 331 |
sleep $DT_delay && $s->wait_for_ajax; |
401 |
sleep $DT_delay && $s->wait_for_ajax; |
| 332 |
|
402 |
|
| 333 |
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' ); |
403 |
is( |
|
|
404 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 405 |
sprintf( 'Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons ), |
| 406 |
'Searching on a searchable attribute as a specific field returns correct results' |
| 407 |
); |
| 334 |
|
408 |
|
| 335 |
# Refine search and search for test_patron in all the data using the DT global search |
409 |
# Refine search and search for test_patron in all the data using the DT global search |
| 336 |
# No change in result expected, still 2 patrons |
410 |
# No change in result expected, still 2 patrons |
| 337 |
$s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron'); |
411 |
$s->driver->find_element( '//*[@id="' . $table_id . '_filter"]//input' )->send_keys('test_patron'); |
| 338 |
sleep $DT_delay && $s->wait_for_ajax; |
412 |
sleep $DT_delay && $s->wait_for_ajax; |
| 339 |
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' ); |
413 |
is( |
|
|
414 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 415 |
sprintf( 'Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons ), |
| 416 |
'Refining with DataTables search works to further filter the original query' |
| 417 |
); |
| 340 |
|
418 |
|
| 341 |
# Adding the surname of the first patron in the "Name" column |
419 |
# Adding the surname of the first patron in the "Name" column |
| 342 |
# We expect only 1 result |
420 |
# We expect only 1 result |
| 343 |
$s->driver->find_element('//table[@id="'.$table_id.'"]//input[@placeholder="Name search"]')->send_keys($patrons[0]->surname); |
421 |
$s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Name search"]' ) |
|
|
422 |
->send_keys( $patrons[0]->surname ); |
| 344 |
sleep $DT_delay && $s->wait_for_ajax; |
423 |
sleep $DT_delay && $s->wait_for_ajax; |
| 345 |
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' ); |
424 |
is( |
|
|
425 |
$driver->find_element( '//div[@id="' . $table_id . '_info"]' )->get_text, |
| 426 |
sprintf( 'Showing 1 to %s of %s entries (filtered from %s total entries)', 1, 1, $total_number_of_patrons ), |
| 427 |
'Refining with header filters works to further filter the original query' |
| 428 |
); |
| 346 |
|
429 |
|
| 347 |
subtest 'remember_search' => sub { |
430 |
subtest 'remember_search' => sub { |
| 348 |
|
431 |
|
|
Lines 356-363
subtest 'Search patrons' => sub {
Link Here
|
| 356 |
my $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
439 |
my $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
| 357 |
is( $patron_selected_text, "", "Patrons selected is not displayed" ); |
440 |
is( $patron_selected_text, "", "Patrons selected is not displayed" ); |
| 358 |
|
441 |
|
| 359 |
my @checkboxes = $driver->find_elements( |
442 |
my @checkboxes = $driver->find_elements('//input[@type="checkbox"][@name="borrowernumber"]'); |
| 360 |
'//input[@type="checkbox"][@name="borrowernumber"]'); |
|
|
| 361 |
$checkboxes[2]->click; |
443 |
$checkboxes[2]->click; |
| 362 |
$patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
444 |
$patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
| 363 |
is( $patron_selected_text, "Patrons selected: 1", "One patron selected" ); |
445 |
is( $patron_selected_text, "Patrons selected: 1", "One patron selected" ); |
|
Lines 368-375
subtest 'Search patrons' => sub {
Link Here
|
| 368 |
|
450 |
|
| 369 |
$driver->find_element('//*[@id="memberresultst_next"]')->click; |
451 |
$driver->find_element('//*[@id="memberresultst_next"]')->click; |
| 370 |
sleep $DT_delay && $s->wait_for_ajax; |
452 |
sleep $DT_delay && $s->wait_for_ajax; |
| 371 |
@checkboxes = $driver->find_elements( |
453 |
@checkboxes = $driver->find_elements('//input[@type="checkbox"][@name="borrowernumber"]'); |
| 372 |
'//input[@type="checkbox"][@name="borrowernumber"]'); |
|
|
| 373 |
$checkboxes[0]->click; |
454 |
$checkboxes[0]->click; |
| 374 |
$patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
455 |
$patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text; |
| 375 |
is( $patron_selected_text, "Patrons selected: 3", "Three patrons are selected" ); |
456 |
is( $patron_selected_text, "Patrons selected: 3", "Three patrons are selected" ); |
|
Lines 389-396
subtest 'Search patrons' => sub {
Link Here
|
| 389 |
$driver->find_element('//button[@id="add_to_patron_list_submit"]')->click; |
470 |
$driver->find_element('//button[@id="add_to_patron_list_submit"]')->click; |
| 390 |
sleep $DT_delay && $s->wait_for_ajax; |
471 |
sleep $DT_delay && $s->wait_for_ajax; |
| 391 |
is( $driver->find_element('//*[@id="patron_list_dialog"]')->get_text, "Added 3 patrons to $patron_list_name." ); |
472 |
is( $driver->find_element('//*[@id="patron_list_dialog"]')->get_text, "Added 3 patrons to $patron_list_name." ); |
| 392 |
my $patron_list = $schema->resultset('PatronList')->search({ name => $patron_list_name })->next; |
473 |
my $patron_list = $schema->resultset('PatronList')->search( { name => $patron_list_name } )->next; |
| 393 |
is( $schema->resultset('PatronListPatron')->search({ patron_list_id => $patron_list->patron_list_id })->count, 3 ); |
474 |
is( |
|
|
475 |
$schema->resultset('PatronListPatron')->search( { patron_list_id => $patron_list->patron_list_id } )->count, |
| 476 |
3 |
| 477 |
); |
| 394 |
|
478 |
|
| 395 |
$patron_list->delete; |
479 |
$patron_list->delete; |
| 396 |
}; |
480 |
}; |
| 397 |
- |
|
|