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

(-)a/t/db_dependent/selenium/patrons_search.t (-11 / +11 lines)
Lines 155-182 subtest 'Search patrons' => sub { Link Here
155
    $s->auth;
155
    $s->auth;
156
    C4::Context->set_preference('DefaultPatronSearchFields',"");
156
    C4::Context->set_preference('DefaultPatronSearchFields',"");
157
    my $PatronsPerPage = 15;
157
    my $PatronsPerPage = 15;
158
    my $nb_standard_fields = 13;
158
    C4::Context->set_preference('PatronsPerPage', $PatronsPerPage);
159
    C4::Context->set_preference('PatronsPerPage', $PatronsPerPage);
159
    $driver->get( $base_url . "/members/members-home.pl" );
160
    $driver->get( $base_url . "/members/members-home.pl" );
160
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
161
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
161
    is( scalar @adv_options, 13, 'All standard fields are searchable if DefaultPatronSearchFields not set');
162
    is( scalar @adv_options, $nb_standard_fields + 1, 'All standard fields are searchable if DefaultPatronSearchFields not set. middle_name is there.');
162
    is( $adv_options[0]->get_value(), 'firstname,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
163
    is( $adv_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard search uses hard coded list when DefaultPatronSearchFields not set');
163
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
164
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
164
    is( scalar @filter_options, 13, 'All standard fields are searchable by filter if DefaultPatronSearchFields not set');
165
    is( scalar @filter_options, $nb_standard_fields + 1, 'All standard fields + middle_name are searchable by filter if DefaultPatronSearchFields not set');
165
    is( $filter_options[0]->get_value(), 'firstname,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
166
    is( $filter_options[0]->get_value(), 'firstname,middle_name,surname,othernames,cardnumber,userid', 'Standard filter uses hard coded list when DefaultPatronSearchFields not set');
166
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials");
167
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials");
167
    $driver->get( $base_url . "/members/members-home.pl" );
168
    $driver->get( $base_url . "/members/members-home.pl" );
168
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
169
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
169
    is( scalar @adv_options, 13, 'New option added when DefaultPatronSearchFields is populated with a field');
170
    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');
170
    is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated');
171
    is( $adv_options[0]->get_value(), 'firstname,initials', 'Standard search uses DefaultPatronSearchFields when populated');
171
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
172
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
172
    is( scalar @filter_options, 13, 'New filter option added when DefaultPatronSearchFields is populated with a field');
173
    is( scalar @filter_options, $nb_standard_fields, 'New filter option added when DefaultPatronSearchFields is populated with a field');
173
    is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated');
174
    is( $filter_options[0]->get_value(), 'firstname,initials', 'Standard filter uses DefaultPatronSearchFields when populated');
174
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials,horses");
175
    C4::Context->set_preference('DefaultPatronSearchFields',"firstname,initials,horses");
175
    $driver->get( $base_url . "/members/members-home.pl" );
176
    $driver->get( $base_url . "/members/members-home.pl" );
176
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
177
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
177
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
178
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
178
    is( scalar @adv_options, 13, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field');
179
    is( scalar @adv_options, $nb_standard_fields, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field');
179
    is( scalar @filter_options, 13, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field');
180
    is( scalar @filter_options, $nb_standard_fields, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field');
180
    # NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken
181
    # NOTE: We should probably ensure the bad field is removed from 'standard' search here, else searches are broken
181
    C4::Context->set_preference('DefaultPatronSearchFields',"");
182
    C4::Context->set_preference('DefaultPatronSearchFields',"");
182
    $driver->get( $base_url . "/members/members-home.pl" );
183
    $driver->get( $base_url . "/members/members-home.pl" );
Lines 209-216 subtest 'Search patrons' => sub { Link Here
209
    is(
210
    is(
210
        $driver->get_title,
211
        $driver->get_title,
211
        sprintf(
212
        sprintf(
212
            "Modify patron %s %s (%s) %s (%s) (%s) › Patrons › Koha",
213
            "Modify patron %s %s %s (%s) %s (%s) (%s) › Patrons › Koha",
213
            $first_patron->title, $first_patron->firstname, $first_patron->othernames, $first_patron->surname, $first_patron->cardnumber,
214
            $first_patron->title, $first_patron->firstname, $first_patron->middle_name, $first_patron->othernames, $first_patron->surname, $first_patron->cardnumber,
214
            $first_patron->category->description,
215
            $first_patron->category->description,
215
        ),
216
        ),
216
        'Page title is correct after following modification link'
217
        'Page title is correct after following modification link'
217
- 

Return to bug 21978