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

(-)a/t/lib/Page/Circulation/Circulation.pm (+76 lines)
Line 0 Link Here
1
package t::lib::Page::Circulation::Circulation;
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
20
use Modern::Perl;
21
use Scalar::Util qw(blessed);
22
use Test::More;
23
24
use base qw(t::lib::Page::Intra t::lib::Page::Members::Toolbar t::lib::Page::Members::LeftNavigation);
25
26
use Koha::Exception::BadParameter;
27
28
=head NAME t::lib::Page::Circulation::Circulation
29
30
=head SYNOPSIS
31
32
circulation.pl PageObject providing page functionality as a service!
33
34
=cut
35
36
=head new
37
38
    my $circulation = t::lib::Page::Circulation::Circulation->new({borrowernumber => "1"});
39
40
Instantiates a WebDriver and loads the circ/circulation.pl.
41
@PARAM1 HASHRef of optional and MANDATORY parameters
42
MANDATORY extra parameters:
43
    borrowernumber => loads the page to display Borrower matching the given borrowernumber
44
45
@RETURNS t::lib::Page::Circulation::Circulation, ready for user actions!
46
=cut
47
48
sub new {
49
    my ($class, $params) = @_;
50
    unless (ref($params) eq 'HASH' || (blessed($params) && $params->isa('t::lib::Page') )) {
51
        $params = {};
52
    }
53
    $params->{resource} = '/cgi-bin/koha/circ/circulation.pl';
54
    $params->{type}     = 'staff';
55
56
    $params->{getParams} = [];
57
    #Handle MANDATORY parameters
58
    if ($params->{borrowernumber}) {
59
        push @{$params->{getParams}}, "borrowernumber=".$params->{borrowernumber};
60
    }
61
    else {
62
        Koha::Exception::BadParameter->throw(error => __PACKAGE__."->new():> Parameter 'borrowernumber' is missing.");
63
    }
64
65
    my $self = $class->SUPER::new($params);
66
67
    return $self;
68
}
69
70
################################################################################
71
=head UI Mapping helper subroutines
72
See. Selenium documentation best practices for UI element mapping to common language descriptions.
73
=cut
74
################################################################################
75
76
1;
(-)a/t/lib/Page/Members/LeftNavigation.pm (+116 lines)
Line 0 Link Here
1
package t::lib::Page::Members::LeftNavigation;
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
20
use Modern::Perl;
21
use Scalar::Util qw(blessed);
22
use Test::More;
23
24
=head NAME t::lib::Page::Members::LeftNavigation
25
26
=head SYNOPSIS
27
28
Provides the services of the members/circulation left navigation column/frame for the implementing PageObject
29
30
=cut
31
32
################################################################################
33
=head UI Mapping helper subroutines
34
See. Selenium documentation best practices for UI element mapping to common language descriptions.
35
=cut
36
################################################################################
37
38
=head _getLeftNavigationActionElements
39
@RETURNS HASHRef of Selenium::Driver::Webelements matching all the clickable elements
40
                 in the left navigation frame/column at members and circulation pages.
41
=cut
42
43
sub _getLeftNavigationActionElements {
44
    my ($self) = @_;
45
    my $d = $self->getDriver();
46
47
    my $e = {};
48
    eval {
49
        $e->{checkOut} = $d->find_element("div#menu a[href*='circ/circulation.pl']", 'css');
50
    };
51
    eval {
52
        $e->{details}   = $d->find_element("div#menu a[href*='members/moremember.pl']", 'css');
53
    };
54
    eval {
55
        $e->{fines} = $d->find_element("div#menu a[href*='members/pay.pl']", 'css');
56
    };
57
    eval {
58
        $e->{routingLists}    = $d->find_element("div#menu a[href*='members/routing-lists.pl']", 'css');
59
    };
60
    eval {
61
        $e->{circulationHistory} = $d->find_element("div#menu a[href*='members/readingrec.pl']", 'css');
62
    };
63
    eval {
64
        $e->{modificationLog} = $d->find_element("div#menu a[href*='tools/viewlog.pl']", 'css');
65
    };
66
    eval {
67
        $e->{notices} = $d->find_element("div#menu a[href*='members/notices.pl']", 'css');
68
    };
69
    eval {
70
        $e->{statistics} = $d->find_element("div#menu a[href*='members/statistics.pl']", 'css');
71
    };
72
    eval {
73
        $e->{purchaseSuggestions} = $d->find_element("div#menu a[href*='members/purchase-suggestions.pl']", 'css');
74
    };
75
    return $e;
76
}
77
78
79
80
################################################################################
81
=head PageObject Services
82
83
=cut
84
################################################################################
85
86
sub navigateCheckout {
87
    my ($self) = @_;
88
    my $d = $self->getDriver();
89
    $self->debugTakeSessionSnapshot();
90
91
    my $elements = $self->_getLeftNavigationActionElements();
92
    $elements->{checkOut}->click();
93
    $self->debugTakeSessionSnapshot();
94
95
    ok($d->get_title() =~ m/Checking out to/i,
96
       "Intra Navigate to Check out");
97
98
    return t::lib::Page::Circulation::Circulation->rebrandFromPageObject($self);
99
}
100
101
sub navigateToDetails {
102
    my ($self) = @_;
103
    my $d = $self->getDriver();
104
    $self->debugTakeSessionSnapshot();
105
106
    my $elements = $self->_getLeftNavigationActionElements();
107
    $elements->{details}->click();
108
    $self->debugTakeSessionSnapshot();
109
110
    ok($d->get_title() =~ m/Patron details for/i,
111
       "Intra Navigate to Details");
112
113
    return t::lib::Page::Members::Moremember->rebrandFromPageObject($self);
114
}
115
116
1; #Make the compiler happy!
(-)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 14536