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

(-)a/t/db_dependent/selenium/patrons_search.t (-13 / +31 lines)
Lines 51-57 my $base_url = $s->base_url; Link Here
51
my $builder       = t::lib::TestBuilder->new;
51
my $builder       = t::lib::TestBuilder->new;
52
my $schema        = Koha::Database->schema;
52
my $schema        = Koha::Database->schema;
53
53
54
55
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) {
54
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) {
56
    BAIL_OUT("Cannot run this test, data we need to create already exist in the DB");
55
    BAIL_OUT("Cannot run this test, data we need to create already exist in the DB");
57
}
56
}
Lines 63-69 my $branchname = q|<strong>just 'another" library</strong> \123 ❤ Link Here
63
my $firstname               = q|<strong>fir's"tname</strong> \123 ❤|;
62
my $firstname               = q|<strong>fir's"tname</strong> \123 ❤|;
64
my $address                 = q|<strong>add'res"s</strong> \123 ❤|;
63
my $address                 = q|<strong>add'res"s</strong> \123 ❤|;
65
my $email                   = q|a<strong>bad_email</strong>@example\123 ❤.com|;
64
my $email                   = q|a<strong>bad_email</strong>@example\123 ❤.com|;
66
my ($attribute_type, $attribute_type_searchable, $attribute_type_searchable_not_default);
65
my ($attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, $attribute_type_searchable_not_default);
67
sub setup {
66
sub setup {
68
    my $patron_category = $builder->build_object(
67
    my $patron_category = $builder->build_object(
69
        {
68
        {
Lines 151-157 sub setup { Link Here
151
            searched_by_default => 0
150
            searched_by_default => 0
152
        }
151
        }
153
    )->store;
152
    )->store;
154
    $attribute_type_searchable = Koha::Patron::Attribute::Type->new(
153
    $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new(
155
        {
154
        {
156
            code             => 'my code2',
155
            code             => 'my code2',
157
            description      => 'my description2',
156
            description      => 'my description2',
Lines 160-185 sub setup { Link Here
160
            searched_by_default => 1
159
            searched_by_default => 1
161
        }
160
        }
162
    )->store;
161
    )->store;
163
    $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new(
162
    $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new(
164
        {
163
        {
165
            code             => 'mycode3',
164
            code             => 'my code3',
166
            description      => 'my description3',
165
            description      => 'my description3',
167
            opac_display     => 1,
166
            opac_display     => 1,
168
            staff_searchable => 1,
167
            staff_searchable => 1,
168
            searched_by_default => 1
169
        }
170
    )->store;
171
    $attribute_type_searchable_not_default = Koha::Patron::Attribute::Type->new(
172
        {
173
            code             => 'mycode4',
174
            description      => 'my description4',
175
            opac_display     => 1,
176
            staff_searchable => 1,
169
            searched_by_default => 0
177
            searched_by_default => 0
170
        }
178
        }
171
    )->store;
179
    )->store;
172
    push @cleanup, $attribute_type, $attribute_type_searchable, $attribute_type_searchable_not_default;
180
    push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2, $attribute_type_searchable_not_default;
173
181
174
    $patrons[0]->extended_attributes([
182
    $patrons[0]->extended_attributes([
175
        { code => $attribute_type->code, attribute => 'test_attr_1' },
183
        { code => $attribute_type->code, attribute => 'test_attr_1' },
176
        { code => $attribute_type_searchable->code, attribute => 'test_attr_2'},
184
        { code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'},
177
        { code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'},
185
        { code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'},
186
        { code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'},
178
    ]);
187
    ]);
179
    $patrons[1]->extended_attributes([
188
    $patrons[1]->extended_attributes([
180
        { code => $attribute_type->code, attribute => 'test_attr_1' },
189
        { code => $attribute_type->code, attribute => 'test_attr_1' },
181
        { code => $attribute_type_searchable->code, attribute => 'test_attr_2'},
190
        { code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'},
182
        { code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_3'},
191
        { code => $attribute_type_searchable_2->code, attribute => 'test_attr_3'},
192
        { code => $attribute_type_searchable_not_default->code, attribute => 'test_attr_4'},
183
    ]);
193
    ]);
184
    C4::Context->set_preference('PatronsPerPage', $PatronsPerPage);
194
    C4::Context->set_preference('PatronsPerPage', $PatronsPerPage);
185
}
195
}
Lines 194-200 sub teardown { Link Here
194
}
204
}
195
205
196
subtest 'Search patrons' => sub {
206
subtest 'Search patrons' => sub {
197
    plan tests => 27;
207
    plan tests => 28;
198
208
199
    setup();
209
    setup();
200
    my $total_number_of_patrons = Koha::Patrons->search->count;
210
    my $total_number_of_patrons = Koha::Patrons->search->count;
Lines 316-323 subtest 'Search patrons' => sub { Link Here
316
    # clear form
326
    # clear form
317
    $driver->find_element('//form[@class="patron_search_form"]//*[@class="btn btn-default clear_search"]')->click();
327
    $driver->find_element('//form[@class="patron_search_form"]//*[@class="btn btn-default clear_search"]')->click();
318
328
329
    $s->fill_form( { 'class=search_patron_filter' => 'test_attr_3' } ); # Terms must be split
330
    $s->submit_form;
331
    sleep $DT_delay && $s->wait_for_ajax;
332
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 returns correct results' );
334
335
    # clear form
336
    $driver->find_element('//form[@class="patron_search_form"]//*[@class="btn btn-default clear_search"]')->click();
337
319
    # Search on searchable attribute as specific field, we expect 2 patrons
338
    # Search on searchable attribute as specific field, we expect 2 patrons
320
    $s->fill_form( { 'class=search_patron_filter' => 'test_attr_3' } );
339
    $s->fill_form( { 'class=search_patron_filter' => 'test_attr_4' } );
321
    $driver->find_element('//form[@class="patron_search_form"]//*[@class="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click();
340
    $driver->find_element('//form[@class="patron_search_form"]//*[@class="searchfieldstype_filter"]//option[@value="_ATTR_'.$attribute_type_searchable_not_default->code.'"]')->click();
322
    $s->submit_form;
341
    $s->submit_form;
323
    sleep $DT_delay && $s->wait_for_ajax;
342
    sleep $DT_delay && $s->wait_for_ajax;
324
- 

Return to bug 30645