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

(-)a/t/lib/Page/Members/LeftNavigation.pm (+20 lines)
Lines 113-116 sub navigateToDetails { Link Here
113
    return t::lib::Page::Members::Moremember->rebrandFromPageObject($self);
113
    return t::lib::Page::Members::Moremember->rebrandFromPageObject($self);
114
}
114
}
115
115
116
sub navigateToNotices {
117
    my ($self) = @_;
118
    my $d = $self->getDriver();
119
    $self->debugTakeSessionSnapshot();
120
121
    my $elements = $self->_getLeftNavigationActionElements();
122
    my $func = sub {
123
        $elements->{notices}->click();
124
    };
125
    my $success = sub {
126
        return $self->getDriver()->get_title() =~ m/Sent notices/;
127
    };
128
    $self->debugTakeSessionSnapshot();
129
130
    ok($d->get_title() =~ m/Sent notices/i,
131
       "Intra Navigate to Notices");
132
133
    return t::lib::Page::Members::Notices->rebrandFromPageObject($self);
134
}
135
116
1; #Make the compiler happy!
136
1; #Make the compiler happy!
(-)a/t/lib/Page/Members/Notices.pm (-1 / +156 lines)
Line 0 Link Here
0
- 
1
package t::lib::Page::Members::Notices;
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
use t::lib::Page::Circulation::Circulation;
29
30
31
sub new {
32
    my ($class, $params) = @_;
33
    unless (ref($params) eq 'HASH' || (blessed($params) && $params->isa('t::lib::Page') )) {
34
        $params = {};
35
    }
36
    $params->{resource} = '/cgi-bin/koha/members/notices.pl';
37
    $params->{type}     = 'staff';
38
39
    $params->{getParams} = [];
40
    #Handle MANDATORY parameters
41
    if ($params->{borrowernumber}) {
42
        push @{$params->{getParams}}, "borrowernumber=".$params->{borrowernumber};
43
    }
44
    else {
45
        Koha::Exception::BadParameter->throw(error => __PACKAGE__."->new():> Parameter 'borrowernumber' is missing.");
46
    }
47
    my $self = $class->SUPER::new($params);
48
49
    return $self;
50
}
51
52
################################################################################
53
=head UI Mapping helper subroutines
54
See. Selenium documentation best practices for UI element mapping to common language descriptions.
55
=cut
56
################################################################################
57
58
sub _getNoticesTable {
59
    my ($self) = @_;
60
    my $d = $self->getDriver();
61
62
    my $e = {};
63
64
    eval {
65
        $e->{noticestable_headers} = $d->find_elements("#noticestable th", 'css');
66
    };
67
    eval {
68
        $e->{noticestable_cells} = $d->find_elements("#noticestable td", 'css');
69
    };
70
    eval {
71
        $e->{noticestable_rows} = $d->find_elements("#noticestable tr", 'css');
72
    };
73
74
    return $e;
75
}
76
77
################################################################################
78
=head PageObject Services
79
80
=cut
81
################################################################################
82
83
sub getTextInColumnAtRow {
84
    my ($self, $searchText, $params) = @_;
85
    my $d = $self->getDriver();
86
    $self->debugTakeSessionSnapshot();
87
    
88
    if (not exists $params->{column} or not exists $params->{row} or
89
        not $params->{column} or not $params->{row}) {
90
        warn "t::lib::Page::Members::Notices->getColumnAtRow must be called with column and row numbers, e.g. {column => 1, row=1}";
91
    }
92
    
93
    my $col = $params->{column};
94
    my $row = $params->{row};
95
    
96
    my $cell = $d->find_element("#noticestable tr:nth-child($row) td:nth-child($col)");
97
    
98
    ok(($cell->get_text() =~ /^(.*)$searchText(.*)$/), "Intra Notices Text \"$searchText\" found at column ".
99
       $params->{column}." row ".$params->{row}." matches \"".$cell->get_text()."\".");
100
101
    return $self;
102
}
103
104
sub hasDeliveryNoteColumnInNoticesTable {
105
    my ($self) = @_;
106
    my $d = $self->getDriver();
107
    $self->debugTakeSessionSnapshot();
108
109
    my $elements = $self->_getNoticesTable();
110
111
    my $headers = $elements->{noticestable_headers};
112
113
    my $hasDeliveryNote = 0;
114
115
    foreach my $header(@$headers){
116
        $hasDeliveryNote = 1 if ($header->get_text() =~ /^Delivery note$/);
117
    }
118
119
    ok($hasDeliveryNote, "Intra Notices Table has all headings");
120
121
    return $self;
122
}
123
124
sub hasTextInTableCell {
125
    my ($self, $txt) = @_;
126
    my $d = $self->getDriver();
127
    $self->debugTakeSessionSnapshot();
128
129
    my $elements = $self->_getNoticesTable();
130
131
    my $cells = $elements->{noticestable_cells};
132
133
    my $hasText = 0;
134
135
    foreach my $cell(@$cells){
136
        $hasText = 1 if ($cell->get_text() =~ /^$txt$/);
137
    }
138
139
    ok($hasText, "Intra Notices Found text '$txt' from table");
140
141
    return $self;
142
}
143
144
sub verifyNoMessages {
145
    my ($self, $note) = @_;
146
    my $d = $self->getDriver();
147
    $self->debugTakeSessionSnapshot();
148
149
    my $dialog = $d->find_element("div.yui-b div.dialog", 'css')->get_text();
150
151
    ok($dialog =~ /^There is no record of any(.*)$/, "Intra Notices No messages sent");
152
153
    return $self;
154
}
155
156
1;

Return to bug 14536