|
Lines 21-30
use Modern::Perl;
Link Here
|
| 21 |
use Scalar::Util qw(blessed); |
21 |
use Scalar::Util qw(blessed); |
| 22 |
use Test::More; |
22 |
use Test::More; |
| 23 |
|
23 |
|
| 24 |
use base qw(t::lib::Page::Intra t::lib::Page::Members::Toolbar); |
24 |
use base qw(t::lib::Page::Intra t::lib::Page::Members::Toolbar t::lib::Page::Members::LeftNavigation); |
| 25 |
|
25 |
|
| 26 |
use Koha::Exception::BadParameter; |
26 |
use Koha::Exception::BadParameter; |
| 27 |
|
27 |
|
|
|
28 |
use t::lib::Page::Circulation::Circulation; |
| 29 |
|
| 28 |
|
30 |
|
| 29 |
sub new { |
31 |
sub new { |
| 30 |
my ($class, $params) = @_; |
32 |
my ($class, $params) = @_; |
|
Lines 61-75
sub _getInputFieldsForValidation {
Link Here
|
| 61 |
my ($self) = @_; |
63 |
my ($self) = @_; |
| 62 |
my $d = $self->getDriver(); |
64 |
my $d = $self->getDriver(); |
| 63 |
|
65 |
|
| 64 |
my $emailInput = $d->find_element('#email'); |
66 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber); |
| 65 |
my $emailProInput = $d->find_element('#emailpro'); |
67 |
eval { |
| 66 |
my $email_BInput = $d->find_element('#B_email'); |
68 |
$emailInput = $d->find_element('#email'); |
|
|
69 |
}; |
| 70 |
eval { |
| 71 |
$emailProInput = $d->find_element('#emailpro'); |
| 72 |
}; |
| 73 |
eval { |
| 74 |
$email_BInput = $d->find_element('#B_email'); |
| 75 |
}; |
| 76 |
eval { |
| 77 |
$phoneInput = $d->find_element('#phone'); |
| 78 |
}; |
| 79 |
eval { |
| 80 |
$phoneProInput = $d->find_element('#phonepro'); |
| 81 |
}; |
| 82 |
eval { |
| 83 |
$phone_BInput = $d->find_element('#B_phone'); |
| 84 |
}; |
| 85 |
eval { |
| 86 |
$SMSnumber = $d->find_element('#SMSnumber'); |
| 87 |
}; |
| 67 |
|
88 |
|
| 68 |
my $phoneInput = $d->find_element('#phone'); |
89 |
return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber); |
| 69 |
my $phoneProInput = $d->find_element('#phonepro'); |
90 |
} |
| 70 |
my $phone_BInput = $d->find_element('#B_phone'); |
91 |
|
|
|
92 |
sub _getMessagingPreferenceCheckboxes { |
| 93 |
my ($self) = @_; |
| 94 |
my $d = $self->getDriver(); |
| 95 |
|
| 96 |
my @email_prefs = $d->find_elements('input[type="checkbox"][id^="email"]'); |
| 97 |
my @phone_prefs = $d->find_elements('input[type="checkbox"][id^="phone"]'); |
| 98 |
my @sms_prefs = $d->find_elements('input[type="checkbox"][id^="sms"]'); |
| 71 |
|
99 |
|
| 72 |
return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput); |
100 |
return { email => \@email_prefs, phone => \@phone_prefs, sms => \@sms_prefs }; |
| 73 |
} |
101 |
} |
| 74 |
|
102 |
|
| 75 |
|
103 |
|
|
Lines 79-90
sub _getInputFieldsForValidation {
Link Here
|
| 79 |
=cut |
107 |
=cut |
| 80 |
################################################################################ |
108 |
################################################################################ |
| 81 |
|
109 |
|
|
|
110 |
sub checkMessagingPreferencesSet { |
| 111 |
my ($self, $valid, @prefs) = @_; |
| 112 |
my $d = $self->getDriver(); |
| 113 |
$self->debugTakeSessionSnapshot(); |
| 114 |
|
| 115 |
foreach my $type (@prefs){ |
| 116 |
my @this_pref = $d->find_elements('input[type="checkbox"][id^="'.$type.'"]'); |
| 117 |
|
| 118 |
my $ok = 0; |
| 119 |
|
| 120 |
foreach my $checkbox (@this_pref){ |
| 121 |
ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." not checked") if !$checkbox->is_selected() and $valid; |
| 122 |
ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." checked (not supposed to be)") if $checkbox->is_selected() and !$valid; |
| 123 |
$ok = 1; |
| 124 |
} |
| 125 |
ok($ok, "Intra Memberentry $type messaging checkboxes ok (all " . (($valid) ? 'checked':'unchecked') . ")"); |
| 126 |
} |
| 127 |
|
| 128 |
return $self; |
| 129 |
} |
| 130 |
|
| 131 |
sub clearMessagingContactFields { |
| 132 |
my ($self, @fields) = @_; |
| 133 |
my $d = $self->getDriver(); |
| 134 |
$self->debugTakeSessionSnapshot(); |
| 135 |
|
| 136 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation(); |
| 137 |
|
| 138 |
if (@fields) { |
| 139 |
for my $field (@fields){ |
| 140 |
$emailInput->clear() if $field eq "email"; |
| 141 |
$emailProInput->clear() if $field eq "emailpro"; |
| 142 |
$email_BInput->clear() if $field eq "B_email"; |
| 143 |
$phoneInput->clear() if $field eq "phone"; |
| 144 |
$phoneProInput->clear() if $field eq "phonepro"; |
| 145 |
$phone_BInput->clear() if $field eq "B_phone"; |
| 146 |
$SMSnumber->clear() if $field eq "SMSnumber"; |
| 147 |
} |
| 148 |
ok(1, "Intra Memberentry contact fields (@fields) cleared"); |
| 149 |
} else { |
| 150 |
$emailInput->clear(); |
| 151 |
$emailProInput->clear(); |
| 152 |
$email_BInput->clear(); |
| 153 |
$phoneInput->clear(); |
| 154 |
$phoneProInput->clear(); |
| 155 |
$phone_BInput->clear(); |
| 156 |
$SMSnumber->clear(); |
| 157 |
ok(1, "Intra Memberentry contact fields (email, emailpro, email_B, phone, phonepro, phone_B, SMSnumber) cleared"); |
| 158 |
} |
| 159 |
|
| 160 |
return $self; |
| 161 |
} |
| 162 |
|
| 163 |
sub checkPreferences { |
| 164 |
my ($self, $valid, $type) = @_; |
| 165 |
my $d = $self->getDriver(); |
| 166 |
$self->debugTakeSessionSnapshot(); |
| 167 |
|
| 168 |
my $checkboxes = $self->_getMessagingPreferenceCheckboxes(); |
| 169 |
|
| 170 |
ok (0, "Intra $type checkboxes not defined") if not defined $checkboxes->{$type}; |
| 171 |
return 0 if not defined $checkboxes->{$type}; |
| 172 |
|
| 173 |
foreach my $checkbox (@{ $checkboxes->{$type} }){ |
| 174 |
ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." not available") if !$checkbox->is_enabled() and $valid; |
| 175 |
ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." available (not supposed to be)") if $checkbox->is_enabled() and !$valid; |
| 176 |
|
| 177 |
$checkbox->click() if not $checkbox->is_selected(); |
| 178 |
} |
| 179 |
ok (1, "Intra Memberentry $type messaging checkboxes checked") if $valid; |
| 180 |
|
| 181 |
return $self; |
| 182 |
} |
| 82 |
sub setEmail { |
183 |
sub setEmail { |
| 83 |
my ($self, $input) = @_; |
184 |
my ($self, $input) = @_; |
| 84 |
my $d = $self->getDriver(); |
185 |
my $d = $self->getDriver(); |
| 85 |
$self->debugTakeSessionSnapshot(); |
186 |
$self->debugTakeSessionSnapshot(); |
| 86 |
|
187 |
|
| 87 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); |
188 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation(); |
| 88 |
|
189 |
|
| 89 |
$emailInput->clear(); |
190 |
$emailInput->clear(); |
| 90 |
$emailProInput->clear(); |
191 |
$emailProInput->clear(); |
|
Lines 102-108
sub setPhone {
Link Here
|
| 102 |
my $d = $self->getDriver(); |
203 |
my $d = $self->getDriver(); |
| 103 |
$self->debugTakeSessionSnapshot(); |
204 |
$self->debugTakeSessionSnapshot(); |
| 104 |
|
205 |
|
| 105 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); |
206 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation(); |
| 106 |
|
207 |
|
| 107 |
$phoneInput->clear(); |
208 |
$phoneInput->clear(); |
| 108 |
$phoneProInput->clear(); |
209 |
$phoneProInput->clear(); |
|
Lines 115-134
sub setPhone {
Link Here
|
| 115 |
return $self; |
216 |
return $self; |
| 116 |
} |
217 |
} |
| 117 |
|
218 |
|
|
|
219 |
sub setSMSNumber { |
| 220 |
my ($self, $input) = @_; |
| 221 |
my $d = $self->getDriver(); |
| 222 |
$self->debugTakeSessionSnapshot(); |
| 223 |
|
| 224 |
my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation(); |
| 225 |
|
| 226 |
$SMSnumber->clear(); |
| 227 |
$SMSnumber->send_keys($input); |
| 228 |
ok(1, "Intra Memberentry Wrote \"$input\" to SMSnumber."); |
| 229 |
|
| 230 |
return $self; |
| 231 |
} |
| 232 |
|
| 118 |
sub submitForm { |
233 |
sub submitForm { |
| 119 |
my ($self, $valid) = @_; |
234 |
my ($self, $valid) = @_; |
| 120 |
my $d = $self->getDriver(); |
235 |
my $d = $self->getDriver(); |
| 121 |
$self->debugTakeSessionSnapshot(); |
236 |
$self->debugTakeSessionSnapshot(); |
| 122 |
|
237 |
|
| 123 |
my $submitButton = $d->find_element('form#entryform input[type="submit"]'); |
238 |
my $submitButton = $d->find_element('form#entryform input[type="submit"]'); |
| 124 |
$submitButton->click(); |
239 |
$submitButton->submit(); |
| 125 |
|
|
|
| 126 |
$self->debugTakeSessionSnapshot(); |
240 |
$self->debugTakeSessionSnapshot(); |
| 127 |
|
241 |
|
| 128 |
if ($valid) { |
242 |
if ($valid) { |
| 129 |
my $submitted = $d->find_element("#editpatron", 'css'); |
243 |
my $submitted = $d->find_element("#editpatron", 'css'); |
| 130 |
ok(1, "Intra Memberentry Submit changes success"); |
244 |
ok(1, "Intra Memberentry Submit changes success"); |
| 131 |
return t::lib::Page::Members::Moremember->rebrandFromPageObject($self); |
245 |
return t::lib::Page::Circulation::Circulation->rebrandFromPageObject($self); |
| 132 |
} else { |
246 |
} else { |
| 133 |
my @notsubmitted = $d->find_elements('form#entryform label[class="error"]', 'css'); |
247 |
my @notsubmitted = $d->find_elements('form#entryform label[class="error"]', 'css'); |
| 134 |
my $error_ids = ""; |
248 |
my $error_ids = ""; |
|
Lines 142-151
sub submitForm {
Link Here
|
| 142 |
$d->refresh(); |
256 |
$d->refresh(); |
| 143 |
return $self; |
257 |
return $self; |
| 144 |
} |
258 |
} |
| 145 |
|
|
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
} |
259 |
} |
| 150 |
|
260 |
|
| 151 |
1; |
261 |
1; |