View | Details | Raw Unified | Return to bug 35284
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-1 / +1 lines)
Lines 916-922 function _dt_add_filters(table_node, table_dt, filters_options = {}) { Link Here
916
                    .column( i )
916
                    .column( i )
917
                    .search( val )
917
                    .search( val )
918
                    .draw();
918
                    .draw();
919
            }, 1000 );
919
            }, 500);
920
920
921
            $( input_type, this ).on( 'keyup change', function () {
921
            $( input_type, this ).on( 'keyup change', function () {
922
                if ( table_dt.column(i).search() !== this.value ) {
922
                if ( table_dt.column(i).search() !== this.value ) {
(-)a/t/db_dependent/selenium/patrons_search.t (-24 / +24 lines)
Lines 22-27 my $original_DefaultPatronSearchFields = C4::Context->preference('DefaultPatronS Link Here
22
my $original_DefaultPatronSearchMethod = C4::Context->preference('DefaultPatronSearchMethod');
22
my $original_DefaultPatronSearchMethod = C4::Context->preference('DefaultPatronSearchMethod');
23
my $original_PatronsPerPage            = C4::Context->preference('PatronsPerPage');
23
my $original_PatronsPerPage            = C4::Context->preference('PatronsPerPage');
24
our @cleanup;
24
our @cleanup;
25
our $DT_delay = 1;
25
26
26
END {
27
END {
27
    unless ( @cleanup ) { say "WARNING: Cleanup failed!" }
28
    unless ( @cleanup ) { say "WARNING: Cleanup failed!" }
Lines 196-202 subtest 'Search patrons' => sub { Link Here
196
    $s->submit_form;
197
    $s->submit_form;
197
    my $first_patron = $patrons[0];
198
    my $first_patron = $patrons[0];
198
199
199
    $s->wait_for_ajax;
200
    sleep $DT_delay && $s->wait_for_ajax;
200
    my @td = $driver->find_elements('//table[@id="'.$table_id.'"]/tbody/tr/td');
201
    my @td = $driver->find_elements('//table[@id="'.$table_id.'"]/tbody/tr/td');
201
    like ($td[2]->get_text, qr[\Q$firstname\E],
202
    like ($td[2]->get_text, qr[\Q$firstname\E],
202
        'Column "Name" should be the 3rd and contain the firstname correctly filtered'
203
        'Column "Name" should be the 3rd and contain the firstname correctly filtered'
Lines 231-250 subtest 'Search patrons' => sub { Link Here
231
    $driver->get( $base_url . "/members/members-home.pl" );
232
    $driver->get( $base_url . "/members/members-home.pl" );
232
    $s->fill_form( { search_patron_filter => 'test_patron' } );
233
    $s->fill_form( { search_patron_filter => 'test_patron' } );
233
    $s->submit_form;
234
    $s->submit_form;
234
    $s->wait_for_ajax;
235
    sleep $DT_delay && $s->wait_for_ajax;
235
236
236
    $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron');
237
    $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron');
237
    $s->wait_for_ajax;
238
    sleep $DT_delay && $s->wait_for_ajax;
238
    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' );
239
    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' );
239
240
240
    $s->driver->find_element('//table[@id="'.$table_id.'"]//th[@data-filter="libraries"]/select/option[@value="'.$library->branchcode.'"]')->click;
241
    $s->driver->find_element('//table[@id="'.$table_id.'"]//th[@data-filter="libraries"]/select/option[@value="'.$library->branchcode.'"]')->click;
241
    $s->wait_for_ajax;
242
    sleep $DT_delay && $s->wait_for_ajax;
242
    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' );
243
    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' );
243
244
244
    # Reset the filters
245
    # Reset the filters
245
    $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click();
246
    $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click();
246
    $s->submit_form;
247
    $s->submit_form;
247
    $s->wait_for_ajax;
248
    sleep $DT_delay && $s->wait_for_ajax;
248
249
249
    # And make sure all the patrons are present
250
    # And make sure all the patrons are present
250
    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' );
251
    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' );
Lines 253-268 subtest 'Search patrons' => sub { Link Here
253
    $s->fill_form( { search_patron_filter => 'test patron' } );
254
    $s->fill_form( { search_patron_filter => 'test patron' } );
254
    $s->submit_form;
255
    $s->submit_form;
255
256
256
    $s->wait_for_ajax;
257
    sleep $DT_delay && $s->wait_for_ajax;
257
    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) );
258
    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) );
258
    $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click();
259
    $driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click();
259
    $s->submit_form;
260
    $s->submit_form;
260
    $s->wait_for_ajax;
261
    sleep $DT_delay && $s->wait_for_ajax;
261
262
262
    # Search on non-searchable attribute, we expect no result!
263
    # Search on non-searchable attribute, we expect no result!
263
    $s->fill_form( { search_patron_filter => 'test_attr_1' } );
264
    $s->fill_form( { search_patron_filter => 'test_attr_1' } );
264
    $s->submit_form;
265
    $s->submit_form;
265
    $s->wait_for_ajax;
266
    sleep $DT_delay && $s->wait_for_ajax;
266
267
267
    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' );
268
    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' );
268
269
Lines 272-291 subtest 'Search patrons' => sub { Link Here
272
    # Search on searchable attribute, we expect 2 patrons
273
    # Search on searchable attribute, we expect 2 patrons
273
    $s->fill_form( { search_patron_filter => 'test_attr_2' } );
274
    $s->fill_form( { search_patron_filter => 'test_attr_2' } );
274
    $s->submit_form;
275
    $s->submit_form;
275
    $s->wait_for_ajax;
276
    sleep $DT_delay && $s->wait_for_ajax;
276
277
277
    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' );
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)', 2, 2, $total_number_of_patrons), 'Searching on a searchable attribute returns correct results' );
278
279
279
    # Refine search and search for test_patron in all the data using the DT global search
280
    # Refine search and search for test_patron in all the data using the DT global search
280
    # No change in result expected, still 2 patrons
281
    # No change in result expected, still 2 patrons
281
    $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron');
282
    $s->driver->find_element('//*[@id="'.$table_id.'_filter"]//input')->send_keys('test_patron');
282
    $s->wait_for_ajax;
283
    sleep $DT_delay && $s->wait_for_ajax;
283
    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' );
284
    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' );
284
285
285
    # Adding the surname of the first patron in the "Name" column
286
    # Adding the surname of the first patron in the "Name" column
286
    # We expect only 1 result
287
    # We expect only 1 result
287
    $s->driver->find_element('//table[@id="'.$table_id.'"]//input[@placeholder="Name search"]')->send_keys($patrons[0]->surname);
288
    $s->driver->find_element('//table[@id="'.$table_id.'"]//input[@placeholder="Name search"]')->send_keys($patrons[0]->surname);
288
    $s->wait_for_ajax;
289
    sleep $DT_delay && $s->wait_for_ajax;
289
    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' );
290
    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' );
290
291
291
    subtest 'remember_search' => sub {
292
    subtest 'remember_search' => sub {
Lines 296-302 subtest 'Search patrons' => sub { Link Here
296
        $driver->get( $base_url . "/members/members-home.pl" );
297
        $driver->get( $base_url . "/members/members-home.pl" );
297
        $s->fill_form( { search_patron_filter => 'test_patron' } );
298
        $s->fill_form( { search_patron_filter => 'test_patron' } );
298
        $s->submit_form;
299
        $s->submit_form;
299
        $s->wait_for_ajax;
300
        sleep $DT_delay && $s->wait_for_ajax;
300
        my $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text;
301
        my $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text;
301
        is( $patron_selected_text, "", "Patrons selected is not displayed" );
302
        is( $patron_selected_text, "", "Patrons selected is not displayed" );
302
303
Lines 311-317 subtest 'Search patrons' => sub { Link Here
311
        is( $patron_selected_text, "Patrons selected: 2", "Two patrons are selected" );
312
        is( $patron_selected_text, "Patrons selected: 2", "Two patrons are selected" );
312
313
313
        $driver->find_element('//*[@id="memberresultst_next"]')->click;
314
        $driver->find_element('//*[@id="memberresultst_next"]')->click;
314
        $s->wait_for_ajax;
315
        sleep $DT_delay && $s->wait_for_ajax;
315
        @checkboxes = $driver->find_elements(
316
        @checkboxes = $driver->find_elements(
316
            '//input[@type="checkbox"][@name="borrowernumber"]');
317
            '//input[@type="checkbox"][@name="borrowernumber"]');
317
        $checkboxes[0]->click;
318
        $checkboxes[0]->click;
Lines 322-328 subtest 'Search patrons' => sub { Link Here
322
        $driver->get( $base_url . "/members/members-home.pl" );
323
        $driver->get( $base_url . "/members/members-home.pl" );
323
        $s->fill_form( { search_patron_filter => 'test_patron' } );
324
        $s->fill_form( { search_patron_filter => 'test_patron' } );
324
        $s->submit_form;
325
        $s->submit_form;
325
        $s->wait_for_ajax;
326
        sleep $DT_delay && $s->wait_for_ajax;
326
        $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text;
327
        $patron_selected_text = $driver->find_element('//div[@id="table_search_selections"]/span')->get_text;
327
        is( $patron_selected_text, "Patrons selected: 3", "Three patrons still selected" );
328
        is( $patron_selected_text, "Patrons selected: 3", "Three patrons still selected" );
328
329
Lines 331-337 subtest 'Search patrons' => sub { Link Here
331
        my $patron_list_name = "my new list";
332
        my $patron_list_name = "my new list";
332
        $driver->find_element('//input[@id="new_patron_list"]')->send_keys($patron_list_name);
333
        $driver->find_element('//input[@id="new_patron_list"]')->send_keys($patron_list_name);
333
        $driver->find_element('//button[@id="add_to_patron_list_submit"]')->click;
334
        $driver->find_element('//button[@id="add_to_patron_list_submit"]')->click;
334
        $s->wait_for_ajax;
335
        sleep $DT_delay && $s->wait_for_ajax;
335
        is( $driver->find_element('//*[@id="patron_list_dialog"]')->get_text, "Added 3 patrons to $patron_list_name." );
336
        is( $driver->find_element('//*[@id="patron_list_dialog"]')->get_text, "Added 3 patrons to $patron_list_name." );
336
        my $patron_list = $schema->resultset('PatronList')->search({ name => $patron_list_name })->next;
337
        my $patron_list = $schema->resultset('PatronList')->search({ name => $patron_list_name })->next;
337
        is( $schema->resultset('PatronListPatron')->search({ patron_list_id => $patron_list->patron_list_id })->count, 3 );
338
        is( $schema->resultset('PatronListPatron')->search({ patron_list_id => $patron_list->patron_list_id })->count, 3 );
Lines 349-392 subtest 'Search patrons' => sub { Link Here
349
        $driver->get( $base_url . "/members/members-home.pl" );
350
        $driver->get( $base_url . "/members/members-home.pl" );
350
        $s->fill_form( { search_patron_filter => 'test_patron' } );
351
        $s->fill_form( { search_patron_filter => 'test_patron' } );
351
        $s->submit_form;
352
        $s->submit_form;
352
        $s->wait_for_ajax;
353
        sleep $DT_delay && $s->wait_for_ajax;
353
354
354
        $s->show_all_entries( '//div[@id="' . $table_id . '_wrapper"]' );
355
        $s->show_all_entries( '//div[@id="' . $table_id . '_wrapper"]' );
355
        my $dob_search_filter =
356
        my $dob_search_filter =
356
            $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Date of birth search"]' );
357
            $s->driver->find_element( '//table[@id="' . $table_id . '"]//input[@placeholder="Date of birth search"]' );
357
358
358
        $dob_search_filter->send_keys('1980');
359
        $dob_search_filter->send_keys('1980');
359
        $s->wait_for_ajax;
360
        sleep $DT_delay && $s->wait_for_ajax;
360
        is( is_patron_shown($patron_27), 1, 'search by correct year shows the patron' );
361
        is( is_patron_shown($patron_27), 1, 'search by correct year shows the patron' );
361
        $dob_search_filter->clear;
362
        $dob_search_filter->clear;
362
363
363
        $dob_search_filter->send_keys('1986');
364
        $dob_search_filter->send_keys('1986');
364
        $s->wait_for_ajax;
365
        sleep $DT_delay && $s->wait_for_ajax;
365
        is( is_patron_shown($patron_27), 0, 'search by incorrect year does not show the patron' );
366
        is( is_patron_shown($patron_27), 0, 'search by incorrect year does not show the patron' );
366
        $dob_search_filter->clear;
367
        $dob_search_filter->clear;
367
368
368
        $dob_search_filter->send_keys('1980-06');
369
        $dob_search_filter->send_keys('1980-06');
369
        $s->wait_for_ajax;
370
        sleep $DT_delay && $s->wait_for_ajax;
370
        is( is_patron_shown($patron_27), 1, 'search by correct year-month shows the patron' );
371
        is( is_patron_shown($patron_27), 1, 'search by correct year-month shows the patron' );
371
        $dob_search_filter->clear;
372
        $dob_search_filter->clear;
372
373
373
        $dob_search_filter->send_keys('1980-06-17');
374
        $dob_search_filter->send_keys('1980-06-17');
374
        $s->wait_for_ajax;
375
        sleep $DT_delay && $s->wait_for_ajax;
375
        is( is_patron_shown($patron_27), 1, 'search by correct full iso date shows the patron' );
376
        is( is_patron_shown($patron_27), 1, 'search by correct full iso date shows the patron' );
376
        $dob_search_filter->clear;
377
        $dob_search_filter->clear;
377
378
378
        $dob_search_filter->send_keys('1986-06-17');
379
        $dob_search_filter->send_keys('1986-06-17');
379
        $s->wait_for_ajax;
380
        sleep $DT_delay && $s->wait_for_ajax;
380
        is( is_patron_shown($patron_27), 0, 'search by incorrect full iso date does not show the patron' );
381
        is( is_patron_shown($patron_27), 0, 'search by incorrect full iso date does not show the patron' );
381
        $dob_search_filter->clear;
382
        $dob_search_filter->clear;
382
383
383
        $dob_search_filter->send_keys('17/06/1980');
384
        $dob_search_filter->send_keys('17/06/1980');
384
        $s->wait_for_ajax;
385
        sleep $DT_delay && $s->wait_for_ajax;
385
        is( is_patron_shown($patron_27), 1, 'search by correct full formatted date shows the patron' );
386
        is( is_patron_shown($patron_27), 1, 'search by correct full formatted date shows the patron' );
386
        $dob_search_filter->clear;
387
        $dob_search_filter->clear;
387
388
388
        $dob_search_filter->send_keys('17/06/1986');
389
        $dob_search_filter->send_keys('17/06/1986');
389
        $s->wait_for_ajax;
390
        sleep $DT_delay && $s->wait_for_ajax;
390
        is( is_patron_shown($patron_27), 0, 'search by incorrect full formatted date does not show the patron' );
391
        is( is_patron_shown($patron_27), 0, 'search by incorrect full formatted date does not show the patron' );
391
        $dob_search_filter->clear;
392
        $dob_search_filter->clear;
392
    };
393
    };
393
- 

Return to bug 35284