Bugzilla – Attachment 41460 Details for
Bug 14536
PageObject-pattern base implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14536: (follow-up) Add Memberentry PageObject and navigations
Bug-14536-follow-up-Add-Memberentry-PageObject-and.patch (text/plain), 12.64 KB, created by
Lari Taskula
on 2015-08-12 12:15:20 UTC
(
hide
)
Description:
Bug 14536: (follow-up) Add Memberentry PageObject and navigations
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2015-08-12 12:15:20 UTC
Size:
12.64 KB
patch
obsolete
>From ea79bc0fc4af0e1d76678630cc476292d393ccf0 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <larit@student.uef.fi> >Date: Wed, 12 Aug 2015 13:59:52 +0300 >Subject: [PATCH] Bug 14536: (follow-up) Add Memberentry PageObject and > navigations > >--- > t/lib/Page/Members/Memberentry.pm | 151 ++++++++++++++++++++++++++++++++++ > t/lib/Page/Members/Toolbar.pm | 11 +++ > t/lib/Page/Opac/LeftNavigation.pm | 18 +++++ > t/lib/Page/Opac/OpacMemberentry.pm | 161 +++++++++++++++++++++++++++++++++++++ > 4 files changed, 341 insertions(+) > create mode 100644 t/lib/Page/Members/Memberentry.pm > create mode 100644 t/lib/Page/Opac/OpacMemberentry.pm > >diff --git a/t/lib/Page/Members/Memberentry.pm b/t/lib/Page/Members/Memberentry.pm >new file mode 100644 >index 0000000..2599042 >--- /dev/null >+++ b/t/lib/Page/Members/Memberentry.pm >@@ -0,0 +1,151 @@ >+package t::lib::Page::Members::Memberentry; >+ >+# Copyright 2015 Open Source Freedom Fighters >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Scalar::Util qw(blessed); >+use Test::More; >+ >+use base qw(t::lib::Page::Intra t::lib::Page::Members::Toolbar); >+ >+use Koha::Exception::BadParameter; >+ >+ >+sub new { >+ my ($class, $params) = @_; >+ unless (ref($params) eq 'HASH' || (blessed($params) && $params->isa('t::lib::Page') )) { >+ $params = {}; >+ } >+ $params->{resource} = '/cgi-bin/koha/members/memberentry.pl'; >+ $params->{type} = 'staff'; >+ >+ $params->{getParams} = []; >+ #Handle MANDATORY parameters >+ if ($params->{borrowernumber}) { >+ push @{$params->{getParams}}, "borrowernumber=".$params->{borrowernumber}; >+ } >+ else { >+ Koha::Exception::BadParameter->throw(error => __PACKAGE__."->new():> Parameter 'borrowernumber' is missing."); >+ } >+ push @{$params->{getParams}}, "destination=".$params->{destination} if $params->{destination}; >+ push @{$params->{getParams}}, "op=".$params->{op} if $params->{op}; >+ push @{$params->{getParams}}, "categorycode=".$params->{categorycode} if $params->{categorycode}; >+ my $self = $class->SUPER::new($params); >+ >+ return $self; >+} >+ >+################################################################################ >+=head UI Mapping helper subroutines >+See. Selenium documentation best practices for UI element mapping to common language descriptions. >+=cut >+################################################################################ >+ >+ >+sub _getInputFieldsForValidation { >+ my ($self) = @_; >+ my $d = $self->getDriver(); >+ >+ my $emailInput = $d->find_element('#email'); >+ my $emailProInput = $d->find_element('#emailpro'); >+ my $email_BInput = $d->find_element('#B_email'); >+ >+ my $phoneInput = $d->find_element('#phone'); >+ my $phoneProInput = $d->find_element('#phonepro'); >+ my $phone_BInput = $d->find_element('#B_phone'); >+ >+ return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput); >+} >+ >+ >+################################################################################ >+=head PageObject Services >+ >+=cut >+################################################################################ >+ >+sub setEmail { >+ my ($self, $input) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); >+ >+ $emailInput->clear(); >+ $emailProInput->clear(); >+ $email_BInput->clear(); >+ $emailInput->send_keys($input); >+ $emailProInput->send_keys($input); >+ $email_BInput->send_keys($input); >+ ok(1, "Intra Memberentry Wrote \"$input\" to email fields."); >+ >+ return $self; >+} >+ >+sub setPhone { >+ my ($self, $input) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); >+ >+ $phoneInput->clear(); >+ $phoneProInput->clear(); >+ $phone_BInput->clear(); >+ $phoneInput->send_keys($input); >+ $phoneProInput->send_keys($input); >+ $phone_BInput->send_keys($input); >+ ok(1, "Intra Memberentry Wrote \"$input\" to phone fields."); >+ >+ return $self; >+} >+ >+sub submitForm { >+ my ($self, $valid) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my $submitButton = $d->find_element('form#entryform input[type="submit"]'); >+ $submitButton->click(); >+ >+ $self->debugTakeSessionSnapshot(); >+ >+ if ($valid) { >+ my $submitted = $d->find_element("#editpatron", 'css'); >+ ok(1, "Intra Memberentry Submit changes success"); >+ return t::lib::Page::Members::Moremember->rebrandFromPageObject($self); >+ } else { >+ my @notsubmitted = $d->find_elements('form#entryform label[class="error"]', 'css'); >+ my $error_ids = ""; >+ >+ foreach my $el_id (@notsubmitted){ >+ my $attr_id = $el_id->get_attribute("for"); >+ $error_ids .= "'".$attr_id . "' "; >+ } >+ >+ ok(1, "Intra Memberentry Submit changes ". $error_ids .", validation error (as expected)."); >+ $d->refresh(); >+ return $self; >+ } >+ >+ >+ >+ >+} >+ >+1; >\ No newline at end of file >diff --git a/t/lib/Page/Members/Toolbar.pm b/t/lib/Page/Members/Toolbar.pm >index 2bd8b84..61ecd98 100644 >--- a/t/lib/Page/Members/Toolbar.pm >+++ b/t/lib/Page/Members/Toolbar.pm >@@ -128,8 +128,19 @@ sub navigateManageApiKeys { > > return t::lib::Page::Members::ApiKeys->rebrandFromPageObject($self); > } >+sub navigateEditPatron { >+ my ($self) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); > >+ my $elements = $self->_getToolbarActionElements(); >+ $elements->{edit}->click(); >+ ok($d->get_title() =~ m/Modify patron/, "Intra Navigate to Modify patron"); > >+ $self->debugTakeSessionSnapshot(); >+ >+ return t::lib::Page::Members::Memberentry->rebrandFromPageObject($self); >+} > > > 1; #Make the compiler happy! >\ No newline at end of file >diff --git a/t/lib/Page/Opac/LeftNavigation.pm b/t/lib/Page/Opac/LeftNavigation.pm >index f39c685..2f344a8 100644 >--- a/t/lib/Page/Opac/LeftNavigation.pm >+++ b/t/lib/Page/Opac/LeftNavigation.pm >@@ -106,4 +106,22 @@ sub navigateYourAPIKeys { > return t::lib::Page::Opac::OpacApiKeys->rebrandFromPageObject($self); > } > >+sub navigateYourPersonalDetails { >+ my ($self) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my $elements = $self->_getLeftNavigationActionElements(); >+ $elements->{yourPersonalDetails}->click(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my $breadcrumbs = $self->_getBreadcrumbLinks(); >+ >+ ok(ref($breadcrumbs) eq 'ARRAY' && >+ $breadcrumbs->[scalar(@$breadcrumbs)-1]->get_text() =~ m/Your personal details/i, >+ "Opac Navigate to Your personal details"); >+ >+ return t::lib::Page::Opac::OpacMemberentry->rebrandFromPageObject($self); >+} >+ > 1; #Make the compiler happy! >diff --git a/t/lib/Page/Opac/OpacMemberentry.pm b/t/lib/Page/Opac/OpacMemberentry.pm >new file mode 100644 >index 0000000..2dc3a21 >--- /dev/null >+++ b/t/lib/Page/Opac/OpacMemberentry.pm >@@ -0,0 +1,161 @@ >+package t::lib::Page::Opac::OpacMemberentry; >+ >+# Copyright 2015 Open Source Freedom Fighters >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public Lice strongnse >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Scalar::Util qw(blessed); >+use Test::More; >+ >+use t::lib::Page::Opac::OpacUser; >+ >+use base qw(t::lib::Page::Opac); >+ >+use Koha::Exception::BadParameter; >+ >+=head NAME t::lib::Page::Opac::OpacMemberentry >+ >+=head SYNOPSIS >+ >+PageObject providing page functionality as a service! >+ >+=cut >+ >+=head new >+ >+ my $opacmemberentry = t::lib::Page::Opac::OpacMemberentry->new(); >+ >+Instantiates a WebDriver and loads the opac/opac-memberentry.pl. >+@PARAM1 HASHRef of optional and MANDATORY parameters >+MANDATORY extra parameters: >+ none atm. >+ >+@RETURNS t::lib::Page::Opac::OpacMemberentry, ready for user actions! >+=cut >+ >+sub new { >+ my ($class, $params) = @_; >+ unless (ref($params) eq 'HASH' || (blessed($params) && $params->isa('t::lib::Page') )) { >+ $params = {}; >+ } >+ $params->{resource} = '/cgi-bin/koha/opac-memberentry.pl'; >+ $params->{type} = 'opac'; >+ >+ my $self = $class->SUPER::new($params); >+ >+ return $self; >+} >+ >+################################################################################ >+=head UI Mapping helper subroutines >+See. Selenium documentation best practices for UI element mapping to common language descriptions. >+=cut >+################################################################################ >+ >+sub _getInputFieldsForValidation { >+ my ($self) = @_; >+ my $d = $self->getDriver(); >+ >+ my $emailInput = $d->find_element('#borrower_email'); >+ my $emailProInput = $d->find_element('#borrower_emailpro'); >+ my $email_BInput = $d->find_element('#borrower_B_email'); >+ >+ my $phoneInput = $d->find_element('#borrower_phone'); >+ my $phoneProInput = $d->find_element('#borrower_phonepro'); >+ my $phone_BInput = $d->find_element('#borrower_B_phone'); >+ >+ return ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput); >+} >+ >+ >+################################################################################ >+=head PageObject Services >+ >+=cut >+################################################################################ >+ >+=head isFieldsAvailable >+ >+ $page->isFieldsAvailable(); >+ >+@RETURN t::lib::Page-object >+@CROAK if unable to find required fields. >+=cut >+ >+sub setEmail { >+ my ($self, $input) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); >+ >+ $emailInput->send_keys($input); >+ $emailProInput->send_keys($input); >+ $email_BInput->send_keys($input); >+ ok(1, "OpacMemberentry Wrote \"$input\" to email fields."); >+ >+ return $self; >+} >+ >+sub setPhone { >+ my ($self, $input) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my ($emailInput, $emailProInput, $email_BInput, $phoneInput, $phoneProInput, $phone_BInput) = $self->_getInputFieldsForValidation(); >+ >+ $phoneInput->send_keys($input); >+ $phoneProInput->send_keys($input); >+ $phone_BInput->send_keys($input); >+ ok(1, "OpacMemberentry Wrote \"$input\" to phone fields."); >+ >+ return $self; >+} >+ >+sub submitForm { >+ my ($self, $valid) = @_; >+ my $d = $self->getDriver(); >+ $self->debugTakeSessionSnapshot(); >+ >+ my $submitButton = $d->find_element('form#memberentry-form input[type="submit"]'); >+ $submitButton->click(); >+ >+ $self->debugTakeSessionSnapshot(); >+ >+ if ($valid) { >+ my $submitted = $d->find_element('#update-submitted'); >+ ok(1, "OpacMemberentry Submit changes success"); >+ } else { >+ my @notsubmitted = $d->find_elements('form#memberentry-form label[id^="borrower_"][id$="-error"]', 'css'); >+ my $error_ids = ""; >+ >+ foreach my $el_id (@notsubmitted){ >+ my $attr_id = $el_id->get_attribute("id"); >+ $attr_id =~ s/borrower_//g; >+ $attr_id =~ s/-error//g; >+ $error_ids .= "'".$attr_id . "' "; >+ } >+ >+ ok(1, "OpacMemberentry Submit changes ". $error_ids .", validation error (as expected)."); >+ } >+ >+ >+ >+ return t::lib::Page::Opac::OpacUser->rebrandFromPageObject($self); >+} >+ >+1; >\ No newline at end of file >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14536
:
41023
|
41052
|
41057
|
41121
|
41156
|
41254
|
41460
|
41524
|
41525
|
41534
|
41678
|
42060
|
42111
|
42118
|
42136
|
42160
|
42433
|
42435
|
42716
|
44410
|
47254
|
63245