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

(-)a/t/db_dependent/MessagingPreferencesValidation.t (+176 lines)
Line 0 Link Here
1
#!/usr/bin/env perl
2
3
# Copyright 2015 Open Source Freedom Fighters
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
$ENV{KOHA_PAGEOBJECT_DEBUG} = 1;
20
use Modern::Perl;
21
22
use Test::More;
23
use Try::Tiny; #Even Selenium::Remote::Driver uses Try::Tiny :)
24
25
use Koha::Auth::PermissionManager;
26
27
use t::lib::Page::Mainpage;
28
use t::lib::Page::Opac::OpacMain;
29
use t::lib::Page::Opac::OpacMemberentry;
30
use t::lib::Page::Members::Memberentry;
31
use t::lib::Page::Members::Moremember;
32
33
use t::lib::TestObjects::BorrowerFactory;
34
use t::lib::TestObjects::SystemPreferenceFactory;
35
36
##Setting up the test context
37
my $testContext = {};
38
39
my $password = '1234';
40
my $borrowerFactory = t::lib::TestObjects::BorrowerFactory->new();
41
my $borrowers = $borrowerFactory->createTestGroup([
42
            {firstname  => 'Testone',
43
             surname    => 'Testtwo',
44
             cardnumber => '1A01',
45
             branchcode => 'CPL',
46
             userid     => 'normal_user',
47
             password   => $password,
48
            },
49
            {firstname  => 'Testthree',
50
             surname    => 'Testfour',
51
             cardnumber => 'superuberadmin',
52
             branchcode => 'CPL',
53
             userid     => 'god',
54
             password   => $password,
55
            },
56
        ], undef, $testContext);
57
58
my $systempreferences = t::lib::TestObjects::SystemPreferenceFactory->createTestGroup([
59
            {preference => 'ValidateEmailAddress',
60
             value      => 1
61
            },
62
            {preference => 'ValidatePhoneNumber',
63
             value      => 'ipn',
64
            },
65
            {preference => 'TalkingTechItivaPhoneNotification',
66
             value      => 1
67
            },
68
            {preference => 'SMSSendDriver',
69
             value      => 'test'
70
            },      
71
        ], undef, $testContext);
72
73
my $permissionManager = Koha::Auth::PermissionManager->new();
74
$permissionManager->grantPermissions($borrowers->{'superuberadmin'}, {superlibrarian => 'superlibrarian'});
75
76
eval {
77
    
78
    # staff client
79
    my $memberentry = t::lib::Page::Members::Memberentry->new({borrowernumber => $borrowers->{'superuberadmin'}->borrowernumber, op => 'modify', destination => 'circ', categorycode => 'PT'});
80
    # opac
81
    my $main = t::lib::Page::Opac::OpacMain->new({borrowernumber => $borrowers->{'superuberadmin'}->borrowernumber});
82
    
83
    # set valid contacts and check preferences checkboxes
84
    $memberentry->doPasswordLogin($borrowers->{'superuberadmin'}->userid(), $password)
85
    ->setEmail("valid\@email.com")
86
    ->checkPreferences(1, "email")
87
    ->setPhone("+3585012345678")
88
    ->checkPreferences(1, "phone")
89
    ->setSMSNumber("+3585012345678")
90
    ->checkPreferences(1, "sms")
91
    ->submitForm(1) # expecting success
92
    ->navigateToDetails()
93
    # make sure everything is now checked on moremember.pl details page
94
    ->checkMessagingPreferencesSet(1, "email", "sms", "phone");
95
    
96
    $main # check that they are also checked in OPAC
97
    ->doPasswordLogin($borrowers->{'superuberadmin'}->userid(), $password)
98
    ->navigateYourMessaging()
99
    ->checkMessagingPreferencesSet(1, "email", "sms", "phone");
100
    
101
    # go to edit patron and set invalid contacts.
102
    $memberentry
103
    ->navigateEditPatron()
104
    ->setEmail("invalidemail.com")
105
    ->checkPreferences(0, "email")
106
    ->setPhone("+3585012asd345678")
107
    ->checkPreferences(0, "phone")
108
    ->setSMSNumber("+358501asd2345678")
109
    ->checkPreferences(0, "sms")
110
    # check messaging preferences: they should be unchecked
111
    ->checkMessagingPreferencesSet(0, "email", "sms", "phone")
112
    ->submitForm(0) # also confirm that we cant submit the preferences
113
    ->navigateToDetails()
114
    
115
    # go to library use and just simply submit the form without any changes
116
    ->navigateToLibraryUseEdit()
117
    ->submitForm(1)
118
    # all the preferences should be still set
119
    ->checkMessagingPreferencesSet(1, "email", "sms", "phone")
120
121
    # go to smsnumber edit and make sure everything is checked
122
    ->navigateToSMSnumberEdit()
123
    ->checkMessagingPreferencesSet(1, "email", "sms", "phone")
124
    ->submitForm(1)
125
    ->checkMessagingPreferencesSet(1, "email", "sms", "phone")
126
    
127
    # go to patron information edit and clear email and phone
128
    ->navigateToPatronInformationEdit()
129
    ->clearMessagingContactFields("email", "phone")
130
    ->submitForm(1)
131
    # this should remove our messaging preferences for phone and email
132
    ->checkMessagingPreferencesSet(0, "email", "phone")
133
    ->checkMessagingPreferencesSet(1, "sms"); # ... but not for sms (it's still set)
134
    
135
    $main # check the preferences also from OPAC
136
    ->navigateYourMessaging()
137
    ->checkMessagingPreferencesSet(0, "email", "phone")
138
    ->checkMessagingPreferencesSet(1, "sms");
139
    
140
    # go to smsnumber edit and see that email and phone are disabled
141
    $memberentry
142
    ->navigateToSMSnumberEdit()
143
    ->checkMessagingPreferencesSet(0, "email", "phone")
144
    ->clearMessagingContactFields("SMSnumber") # uncheck all sms preferences
145
    ->submitForm(1)
146
    ->checkMessagingPreferencesSet(0, "email", "phone", "sms");
147
    
148
    $main # check the preferences also from OPAC
149
    ->navigateYourMessaging()
150
    ->checkMessagingPreferencesSet(0, "email", "phone", "sms");
151
    
152
};
153
if ($@) { #Catch all leaking errors and gracefully terminate.
154
    warn $@;
155
    tearDown();
156
    exit 1;
157
}
158
159
##All tests done, tear down test context
160
tearDown();
161
done_testing;
162
163
sub tearDown {
164
    t::lib::TestObjects::ObjectFactory->tearDownTestContext($testContext);
165
}
166
167
168
169
170
171
172
173
174
######################################################
175
    ###  STARTING TEST IMPLEMENTATIONS         ###
176
######################################################
(-)a/t/lib/Page/Members/Memberentry.pm (-15 / +123 lines)
Lines 61-75 sub _getInputFieldsForValidation { Link Here
61
    my ($self) = @_;
61
    my ($self) = @_;
62
    my $d = $self->getDriver();
62
    my $d = $self->getDriver();
63
63
64
    my $emailInput  = $d->find_element('#email');
64
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber);
65
    my $emailProInput  = $d->find_element('#emailpro');
65
    eval {
66
    my $email_BInput  = $d->find_element('#B_email');
66
        $emailInput  = $d->find_element('#email');
67
    };
68
    eval {
69
        $emailProInput  = $d->find_element('#emailpro');
70
    };
71
    eval {
72
        $email_BInput  = $d->find_element('#B_email');
73
    };
74
    eval {
75
        $phoneInput  = $d->find_element('#phone');
76
    };
77
    eval {
78
        $phoneProInput  = $d->find_element('#phonepro');
79
    };
80
    eval {
81
        $phone_BInput  = $d->find_element('#B_phone');
82
    };
83
    eval {
84
        $SMSnumber = $d->find_element('#SMSnumber');
85
    };
67
    
86
    
68
    my $phoneInput  = $d->find_element('#phone');
87
    return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber);
69
    my $phoneProInput  = $d->find_element('#phonepro');
88
}
70
    my $phone_BInput  = $d->find_element('#B_phone');
89
90
sub _getMessagingPreferenceCheckboxes {
91
    my ($self) = @_;
92
    my $d = $self->getDriver();
93
94
    my @email_prefs = $d->find_elements('input[type="checkbox"][id^="email"]');
95
    my @phone_prefs = $d->find_elements('input[type="checkbox"][id^="phone"]');
96
    my @sms_prefs = $d->find_elements('input[type="checkbox"][id^="sms"]');
71
    
97
    
72
    return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput);
98
    return  { email => \@email_prefs, phone => \@phone_prefs, sms => \@sms_prefs };
73
}
99
}
74
100
75
101
Lines 79-90 sub _getInputFieldsForValidation { Link Here
79
=cut
105
=cut
80
################################################################################
106
################################################################################
81
107
108
sub checkMessagingPreferencesSet {
109
    my ($self, $valid, @prefs) = @_;
110
    my $d = $self->getDriver();
111
    $self->debugTakeSessionSnapshot();
112
    
113
    foreach my $type (@prefs){
114
        my @this_pref = $d->find_elements('input[type="checkbox"][id^="'.$type.'"]');
115
        
116
        my $ok = 0;
117
        
118
        foreach my $checkbox (@this_pref){
119
            ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." not checked") if !$checkbox->is_selected() and $valid;
120
            ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." checked (not supposed to be)") if $checkbox->is_selected() and !$valid;
121
            $ok = 1;
122
        }
123
        ok($ok, "Intra Memberentry $type messaging checkboxes ok (all " . (($valid) ? 'checked':'unchecked') . ")");
124
    }
125
    
126
    return $self;
127
}
128
129
sub clearMessagingContactFields {
130
    my ($self, @fields) = @_;
131
    my $d = $self->getDriver();
132
    $self->debugTakeSessionSnapshot();
133
    
134
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation();
135
136
    if (@fields) {
137
        for my $field (@fields){
138
            $emailInput->clear() if $field eq "email";
139
            $emailProInput->clear() if $field eq "emailpro";
140
            $email_BInput->clear() if $field eq "B_email";
141
            $phoneInput->clear() if $field eq "phone";
142
            $phoneProInput->clear() if $field eq "phonepro";
143
            $phone_BInput->clear() if $field eq "B_phone";
144
            $SMSnumber->clear() if $field eq "SMSnumber";
145
        }
146
        ok(1, "Intra Memberentry contact fields (@fields) cleared");
147
    } else {
148
        $emailInput->clear();
149
        $emailProInput->clear();
150
        $email_BInput->clear();
151
        $phoneInput->clear();
152
        $phoneProInput->clear();
153
        $phone_BInput->clear();
154
        $SMSnumber->clear();
155
        ok(1, "Intra Memberentry contact fields (email, emailpro, email_B, phone, phonepro, phone_B, SMSnumber) cleared");
156
    }
157
    
158
    return $self;
159
}
160
161
sub checkPreferences {
162
    my ($self, $valid, $type) = @_;
163
    my $d = $self->getDriver();
164
    $self->debugTakeSessionSnapshot();
165
    
166
    my $checkboxes = $self->_getMessagingPreferenceCheckboxes();
167
    
168
    ok (0, "Intra $type checkboxes not defined") if not defined $checkboxes->{$type};
169
    return 0 if not defined $checkboxes->{$type};
170
    
171
    foreach my $checkbox (@{ $checkboxes->{$type} }){
172
        ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." not available") if !$checkbox->is_enabled() and $valid;
173
        ok(0, "Intra Memberentry $type messaging checkbox ".$checkbox->get_attribute('id')." available (not supposed to be)") if $checkbox->is_enabled() and !$valid;
174
175
        $checkbox->click() if not $checkbox->is_selected();
176
    }
177
    ok (1, "Intra Memberentry $type messaging checkboxes checked") if $valid;
178
    
179
    return $self;
180
}
82
sub setEmail {
181
sub setEmail {
83
    my ($self, $input) = @_;
182
    my ($self, $input) = @_;
84
    my $d = $self->getDriver();
183
    my $d = $self->getDriver();
85
    $self->debugTakeSessionSnapshot();
184
    $self->debugTakeSessionSnapshot();
86
    
185
    
87
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation();
186
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation();
88
    
187
    
89
    $emailInput->clear();
188
    $emailInput->clear();
90
    $emailProInput->clear();
189
    $emailProInput->clear();
Lines 102-108 sub setPhone { Link Here
102
    my $d = $self->getDriver();
201
    my $d = $self->getDriver();
103
    $self->debugTakeSessionSnapshot();
202
    $self->debugTakeSessionSnapshot();
104
    
203
    
105
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation();
204
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation();
106
    
205
    
107
    $phoneInput->clear();
206
    $phoneInput->clear();
108
    $phoneProInput->clear();
207
    $phoneProInput->clear();
Lines 115-128 sub setPhone { Link Here
115
    return $self;
214
    return $self;
116
}
215
}
117
216
217
sub setSMSNumber {
218
    my ($self, $input) = @_;
219
    my $d = $self->getDriver();
220
    $self->debugTakeSessionSnapshot();
221
    
222
    my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput, $SMSnumber) = $self->_getInputFieldsForValidation();
223
    
224
    $SMSnumber->clear();
225
    $SMSnumber->send_keys($input);
226
    ok(1, "Intra Memberentry Wrote \"$input\" to SMSnumber.");
227
    
228
    return $self;
229
}
230
118
sub submitForm {
231
sub submitForm {
119
    my ($self, $valid) = @_;
232
    my ($self, $valid) = @_;
120
    my $d = $self->getDriver();
233
    my $d = $self->getDriver();
121
    $self->debugTakeSessionSnapshot();
234
    $self->debugTakeSessionSnapshot();
122
    
235
    
123
    my $submitButton = $d->find_element('form#entryform input[type="submit"]');
236
    my $submitButton = $d->find_element('form#entryform input[type="submit"]');
124
    $submitButton->click();
237
    $submitButton->submit();
125
    
126
    $self->debugTakeSessionSnapshot();
238
    $self->debugTakeSessionSnapshot();
127
    
239
    
128
    if ($valid) {
240
    if ($valid) {
Lines 142-151 sub submitForm { Link Here
142
        $d->refresh();
254
        $d->refresh();
143
        return $self;
255
        return $self;
144
    }
256
    }
145
    
146
    
147
    
148
    
149
}
257
}
150
258
151
1;
259
1;
(-)a/t/lib/Page/Members/Moremember.pm (-1 / +117 lines)
Lines 19-24 package t::lib::Page::Members::Moremember; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Scalar::Util qw(blessed);
21
use Scalar::Util qw(blessed);
22
use Test::More;
22
23
23
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);
24
25
Lines 74-82 See. Selenium documentation best practices for UI element mapping to common lang Link Here
74
=cut
75
=cut
75
################################################################################
76
################################################################################
76
77
78
sub _getEditLinks {
79
    my ($self) = @_;
80
    my $d = $self->getDriver();
81
82
    my $patron_info_edit = $d->find_element("div#patron-information div.action a[href*='memberentry.pl?op=modify'][href*='step=1']", 'css');
83
    my $sms_number_edit = $d->find_element("div.action a[href*='memberentry.pl?op=modify'][href*='step=5']", 'css');
84
    my $library_use_edit = $d->find_element("div.action a[href*='memberentry.pl?op=modify'][href*='step=3']", 'css');
85
    my $alternate_addr_edit = $d->find_element("div.action a[href*='memberentry.pl?op=modify'][href*='step=6']", 'css');
86
    my $alternative_contact_edit = $d->find_element("div.action a[href*='memberentry.pl?op=modify'][href*='step=2']", 'css');
87
88
    my $e = {};
89
    $e->{patron_information} = $patron_info_edit if $patron_info_edit;
90
    $e->{smsnumber} = $sms_number_edit if $sms_number_edit;
91
    $e->{library_use} = $library_use_edit if $library_use_edit;
92
    $e->{alternate_address} = $alternate_addr_edit if $alternate_addr_edit;
93
    $e->{alternative_contact} = $alternative_contact_edit if $alternative_contact_edit;
94
    return $e;
95
}
77
96
97
sub _getMessagingPreferenceCheckboxes {
98
    my ($self) = @_;
99
    my $d = $self->getDriver();
78
100
79
101
    my @email_prefs = $d->find_elements('input[type="checkbox"][id^="email"]');
102
    my @phone_prefs = $d->find_elements('input[type="checkbox"][id^="phone"]');
103
    my @sms_prefs = $d->find_elements('input[type="checkbox"][id^="sms"]');
104
    
105
    return  { email => \@email_prefs, phone => \@phone_prefs, sms => \@sms_prefs };
106
}
80
107
81
################################################################################
108
################################################################################
82
=head PageObject Services
109
=head PageObject Services
Lines 84-90 See. Selenium documentation best practices for UI element mapping to common lang Link Here
84
=cut
111
=cut
85
################################################################################
112
################################################################################
86
113
114
sub checkMessagingPreferencesSet {
115
    my ($self, $valid, @prefs) = @_;
116
    my $d = $self->getDriver();
117
    $self->debugTakeSessionSnapshot();
118
    
119
    foreach my $type (@prefs){
120
        my @this_pref = $d->find_elements('input[type="checkbox"][id^="'.$type.'"]');
121
        
122
        my $ok = 0;
123
        
124
        foreach my $checkbox (@this_pref){
125
            ok(0, "Intra Moremember $type messaging checkbox ".$checkbox->get_attribute('id')." not checked") if !$checkbox->is_selected() and $valid;
126
            ok(0, "Intra Moremember $type messaging checkbox ".$checkbox->get_attribute('id')." checked (not supposed to be)") if $checkbox->is_selected() and !$valid;
127
            $ok = 1;
128
        }
129
        ok($ok, "Intra Moremember $type messaging checkboxes ok (all " . (($valid) ? 'checked':'unchecked') . ")");
130
    }
131
    
132
    return $self;
133
}
134
135
sub navigateToPatronInformationEdit {
136
    my ($self) = @_;
137
    my $d = $self->getDriver();
138
    $self->debugTakeSessionSnapshot();
139
140
    my $elements = $self->_getEditLinks();
141
    $elements->{patron_information}->click();
142
    ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron information");
143
144
    $self->debugTakeSessionSnapshot();
145
146
    return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self);
147
}
148
149
sub navigateToSMSnumberEdit {
150
    my ($self) = @_;
151
    my $d = $self->getDriver();
152
    $self->debugTakeSessionSnapshot();
153
154
    my $elements = $self->_getEditLinks();
155
    $elements->{smsnumber}->click();
156
    ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron SMS number");
157
158
    $self->debugTakeSessionSnapshot();
159
160
    return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self);
161
}
162
163
sub navigateToLibraryUseEdit {
164
    my ($self) = @_;
165
    my $d = $self->getDriver();
166
    $self->debugTakeSessionSnapshot();
167
168
    my $elements = $self->_getEditLinks();
169
    $elements->{library_use}->click();
170
    ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron Library use");
171
172
    $self->debugTakeSessionSnapshot();
173
174
    return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self);
175
}
176
177
sub navigateToAlternateAddressEdit {
178
    my ($self) = @_;
179
    my $d = $self->getDriver();
180
    $self->debugTakeSessionSnapshot();
181
182
    my $elements = $self->_getEditLinks();
183
    $elements->{alternate_address}->click();
184
    ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron Alternate address");
87
185
186
    $self->debugTakeSessionSnapshot();
187
188
    return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self);
189
}
190
191
sub navigateToAlternativeContactEdit {
192
    my ($self) = @_;
193
    my $d = $self->getDriver();
194
    $self->debugTakeSessionSnapshot();
195
196
    my $elements = $self->_getEditLinks();
197
    $elements->{alternative_contact}->click();
198
    ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron Alternative contact");
199
200
    $self->debugTakeSessionSnapshot();
201
202
    return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self);
203
}
88
204
89
205
90
206
(-)a/t/lib/Page/Members/Toolbar.pm (+16 lines)
Lines 143-146 sub navigateEditPatron { Link Here
143
}
143
}
144
144
145
145
146
# left menu
147
sub navigateToDetails {
148
    my ($self) = @_;
149
    my $d = $self->getDriver();
150
151
    my $e = {};
152
    
153
    $e->{details} = $d->find_element("div#menu a[href*='moremember.pl']", 'css');
154
    
155
    $e->{details}->click();
156
    ok($d->get_title() =~ m/Patron details for/, "Intra Navigate to Patron Details");
157
158
    $self->debugTakeSessionSnapshot();
159
    return t::lib::Page::Members::Moremember->rebrandFromPageObject($self);
160
}
161
146
1; #Make the compiler happy!
162
1; #Make the compiler happy!
(-)a/t/lib/Page/Opac/LeftNavigation.pm (+22 lines)
Lines 22-27 use Scalar::Util qw(blessed); Link Here
22
use Test::More;
22
use Test::More;
23
23
24
use t::lib::Page::Opac::OpacApiKeys;
24
use t::lib::Page::Opac::OpacApiKeys;
25
use t::lib::Page::Opac::OpacMessaging;
25
26
26
=head NAME t::lib::Page::Opac::LeftNavigation
27
=head NAME t::lib::Page::Opac::LeftNavigation
27
28
Lines 72-77 sub _getLeftNavigationActionElements { Link Here
72
        $e->{yourPurchaseSuggestions} = $d->find_element("a[href*='opac-suggestions.pl']", 'css');
73
        $e->{yourPurchaseSuggestions} = $d->find_element("a[href*='opac-suggestions.pl']", 'css');
73
    };
74
    };
74
    eval {
75
    eval {
76
        $e->{yourMessaging} = $d->find_element("a[href*='opac-messaging.pl']", 'css');
77
    };
78
    eval {
75
        $e->{yourLists} = $d->find_element("a[href*='opac-shelves.pl']", 'css');
79
        $e->{yourLists} = $d->find_element("a[href*='opac-shelves.pl']", 'css');
76
    };
80
    };
77
    eval {
81
    eval {
Lines 106-111 sub navigateYourAPIKeys { Link Here
106
    return t::lib::Page::Opac::OpacApiKeys->rebrandFromPageObject($self);
110
    return t::lib::Page::Opac::OpacApiKeys->rebrandFromPageObject($self);
107
}
111
}
108
112
113
sub navigateYourMessaging {
114
    my ($self) = @_;
115
    my $d = $self->getDriver();
116
    $self->debugTakeSessionSnapshot();
117
118
    my $elements = $self->_getLeftNavigationActionElements();
119
    $elements->{yourMessaging}->click();
120
    $self->debugTakeSessionSnapshot();
121
122
    my $breadcrumbs = $self->_getBreadcrumbLinks();
123
124
    ok(ref($breadcrumbs) eq 'ARRAY' &&
125
       $breadcrumbs->[scalar(@$breadcrumbs)-1]->get_text() =~ m/Your messaging/i,
126
       "Opac Navigate to Your messaging");
127
128
    return t::lib::Page::Opac::OpacMessaging->rebrandFromPageObject($self);
129
}
130
109
sub navigateYourPersonalDetails {
131
sub navigateYourPersonalDetails {
110
    my ($self) = @_;
132
    my ($self) = @_;
111
    my $d = $self->getDriver();
133
    my $d = $self->getDriver();
(-)a/t/lib/Page/Opac/OpacMemberentry.pm (-1 / +1 lines)
Lines 23-29 use Test::More; Link Here
23
23
24
use t::lib::Page::Opac::OpacUser;
24
use t::lib::Page::Opac::OpacUser;
25
25
26
use base qw(t::lib::Page::Opac);
26
use base qw(t::lib::Page::Opac t::lib::Page::Opac::LeftNavigation);
27
27
28
use Koha::Exception::BadParameter;
28
use Koha::Exception::BadParameter;
29
29
(-)a/t/lib/Page/Opac/OpacMessaging.pm (-1 / +101 lines)
Line 0 Link Here
0
- 
1
package t::lib::Page::Opac::OpacMessaging;
2
3
# Copyright 2015 Open Source Freedom Fighters
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public Lice strongnse
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use Scalar::Util qw(blessed);
22
use Test::More;
23
24
use t::lib::Page::Opac::OpacUser;
25
26
use base qw(t::lib::Page::Opac t::lib::Page::Opac::LeftNavigation);
27
28
use Koha::Exception::BadParameter;
29
30
=head NAME t::lib::Page::Opac::OpacMessaging
31
32
=head SYNOPSIS
33
34
PageObject providing page functionality as a service!
35
36
=cut
37
38
=head new
39
40
    my $opacmemberentry = t::lib::Page::Opac::OpacMessaging->new();
41
42
Instantiates a WebDriver and loads the opac/opac-messaging.pl.
43
@PARAM1 HASHRef of optional and MANDATORY parameters
44
MANDATORY extra parameters:
45
    none atm.
46
47
@RETURNS t::lib::Page::Opac::OpacMessaging, ready for user actions!
48
=cut
49
50
sub new {
51
    my ($class, $params) = @_;
52
    unless (ref($params) eq 'HASH' || (blessed($params) && $params->isa('t::lib::Page') )) {
53
        $params = {};
54
    }
55
    $params->{resource} = '/cgi-bin/koha/opac-messaging.pl';
56
    $params->{type}     = 'opac';
57
58
    my $self = $class->SUPER::new($params);
59
60
    return $self;
61
}
62
63
sub _getMessagingPreferenceCheckboxes {
64
    my ($self) = @_;
65
    my $d = $self->getDriver();
66
67
    my @email_prefs = $d->find_elements('input[type="checkbox"][id^="email"]');
68
    my @phone_prefs = $d->find_elements('input[type="checkbox"][id^="phone"]');
69
    my @sms_prefs = $d->find_elements('input[type="checkbox"][id^="sms"]');
70
    
71
    return  { email => \@email_prefs, phone => \@phone_prefs, sms => \@sms_prefs };
72
}
73
74
################################################################################
75
=head UI Mapping helper subroutines
76
See. Selenium documentation best practices for UI element mapping to common language descriptions.
77
=cut
78
################################################################################
79
80
sub checkMessagingPreferencesSet {
81
    my ($self, $valid, @prefs) = @_;
82
    my $d = $self->getDriver();
83
    $self->debugTakeSessionSnapshot();
84
    
85
    foreach my $type (@prefs){
86
        my @this_pref = $d->find_elements('input[type="checkbox"][id^="'.$type.'"]');
87
        
88
        my $ok = 0;
89
        
90
        foreach my $checkbox (@this_pref){
91
            ok(0, "Opac Messaging $type checkbox ".$checkbox->get_attribute('id')." not checked") if !$checkbox->is_selected() and $valid;
92
            ok(0, "Opac Messaging $type checkbox ".$checkbox->get_attribute('id')." checked (not supposed to be)") if $checkbox->is_selected() and !$valid;
93
            $ok = 1;
94
        }
95
        ok($ok, "Opac Messaging $type checkboxes ok (all " . (($valid) ? 'checked':'unchecked') . ")");
96
    }
97
    
98
    return $self;
99
}
100
101
1;

Return to bug 14590