Bugzilla – Attachment 89900 Details for
Bug 22928
"Update child to adult patron" link no longer displayed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22928: Add selenium tests
Bug-22928-Add-selenium-tests.patch (text/plain), 7.06 KB, created by
Kyle M Hall (khall)
on 2019-05-17 13:16:13 UTC
(
hide
)
Description:
Bug 22928: Add selenium tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2019-05-17 13:16:13 UTC
Size:
7.06 KB
patch
obsolete
>From 3be8d55fd2f192ef568aae2da7250bd2638de6bc Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 16 May 2019 12:22:13 -0500 >Subject: [PATCH] Bug 22928: Add selenium tests > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > .../selenium/update_child_to_adult.t | 152 ++++++++++++++++++ > 1 file changed, 152 insertions(+) > create mode 100644 t/db_dependent/selenium/update_child_to_adult.t > >diff --git a/t/db_dependent/selenium/update_child_to_adult.t b/t/db_dependent/selenium/update_child_to_adult.t >new file mode 100644 >index 0000000000..1443e91de8 >--- /dev/null >+++ b/t/db_dependent/selenium/update_child_to_adult.t >@@ -0,0 +1,152 @@ >+#!/usr/bin/perl >+ >+# 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 C4::Context; >+ >+use Test::More tests => 1; >+use Test::MockModule; >+ >+use C4::Context; >+use Koha::AuthUtils; >+use t::lib::Mocks; >+use t::lib::Selenium; >+use t::lib::TestBuilder; >+ >+eval { require Selenium::Remote::Driver; }; >+skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@; >+ >+my $s = t::lib::Selenium->new; >+my $driver = $s->driver; >+my $opac_base_url = $s->opac_base_url; >+my $base_url = $s->base_url; >+my $builder = t::lib::TestBuilder->new; >+ >+our @cleanup; >+subtest 'Update child to patron' => sub { >+ plan tests => 3; >+ # We are going to test 3 scénarios: >+ # 1. There are no adults in the DB => no "Update child" link appear >+ # 2. There are at least 2 adults in the DB => a window popup is displayed, letting the librarian choosing the adult category they want >+ # 3.An adult will not be able to click the "Update child" link >+ >+ $s->auth; >+ >+ # Creating the child >+ my $patron_category_C = $builder->build_object( >+ { class => 'Koha::Patron::Categories', value => { category_type => 'C' } } ); >+ >+ my $child = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $patron_category_C->categorycode, >+ } >+ } >+ ); >+ my $child_borrowernumber = $child->borrowernumber; >+ >+ subtest 'No adult categories' => sub { >+ plan tests => 1; >+ >+ # That's pretty ugly, but we need 0 adult in the DB to really test the whole behaviorà >+ Koha::Patron::Categories->search({ category_type => 'A' })->update({ category_type => 'Z' }); >+ >+ $driver->get( $base_url . "/members/moremember.pl?borrowernumber=" . $child_borrowernumber ); >+ # Find the "More" button group, it's the last one >+ # Do not use "More" to select the button, to make it works even when translated >+ $driver->find_element('//div[@id="toolbar"]/div[@class="btn-group"][last()]')->click; >+ >+ $s->remove_error_handler; >+ # Why ->id is needed to make it fail? >+ # We should expect ->find_element to return 0, but it returns a WebElement (??) >+ my $update_link_id = eval { $driver->find_element('//a[@id="updatechild"]')->id; }; >+ $s->add_error_handler; >+ is ( $update_link_id, undef, 'No update link should be displayed' ); >+ >+ # Resetting the patrons to adult >+ Koha::Patron::Categories->search({ category_type => 'Z' })->update({ category_type => 'A' }); >+ }; >+ >+ my $patron_category_A = $builder->build_object( >+ { class => 'Koha::Patron::Categories', value => { category_type => 'A' } } ); >+ my $adult_1 = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $patron_category_A->categorycode, >+ } >+ } >+ ); >+ my $adult_2 = $builder->build_object( # We want at least 2 adults to display the popup window >+ { >+ class => 'Koha::Patrons', >+ value => { >+ categorycode => $patron_category_A->categorycode, >+ } >+ } >+ ); >+ my $adult_borrowernumber = $adult_1->borrowernumber; >+ >+ subtest 'Update child to adult' => sub { >+ plan tests => 3; >+ $driver->get( $base_url . "/members/moremember.pl?borrowernumber=" . $child_borrowernumber ); >+ $driver->find_element('//div[@id="toolbar"]/div[@class="btn-group"][last()]')->click; # More button group >+ my $update_link = $driver->find_element('//a[@id="updatechild"]'); >+ >+ is($update_link->get_attribute('data-toggle'), undef, 'The update link should not have a data-toggle attribute => not a tooltip and can be clickable'); >+ $update_link->click; >+ like( $driver->get_current_url, qr{/members/moremember\.pl\?borrowernumber=$child_borrowernumber\#$}, 'Current window has a "#" in the URL, event has been triggered'); >+ >+ # Switch to the popup window >+ # Note that if there is only 1 adult in the DB the popup does not appears, but an alert instead. Not tested so far. >+ my $handles = $driver->get_window_handles; >+ $driver->switch_to_window($handles->[1]); >+ $driver->find_element('//input[@id="catcode'.$patron_category_A->categorycode.'"]')->click; >+ $s->submit_form; >+ >+ is( $child->get_from_storage->categorycode, $patron_category_A->categorycode, 'The child should now be an adult!' ); >+ >+ # Switching back to the main window >+ $driver->switch_to_window($handles->[0]); >+ }; >+ >+ subtest 'Cannot update an adult' => sub { >+ plan tests => 2; >+ >+ # Go to the adult detail view >+ $driver->get( $base_url . "/members/moremember.pl?borrowernumber=$adult_borrowernumber" ); >+ $driver->find_element('//div[@id="toolbar"]/div[@class="btn-group"][last()]')->click; # More button group >+ >+ my $update_link = $driver->find_element('//a[@id="updatechild"]'); >+ is($update_link->get_attribute('data-toggle'), 'tooltip', q|The update link should have a data-toggle attribute => it's a tooltip, not clickable|); >+ $update_link->click; >+ like( $driver->get_current_url, qr{/members/moremember\.pl\?borrowernumber=$adult_borrowernumber$}, 'After clicking the link, nothing happens, no # in the URL'); >+ }; >+ >+ my @patrons = ( $adult_1, $adult_2, $child ); >+ push @cleanup, $_, $_->library, for @patrons; >+ push @cleanup, $patron_category_A, $patron_category_C; >+}; >+ >+END { >+ # Resetting the patrons to adult, in case it has not been done earlier (if failures happened) >+ Koha::Patron::Categories->search({ category_type => 'Z' })->update({ category_type => 'A' }); >+ >+ $_->delete for @cleanup; >+} >-- >2.20.1 (Apple Git-117)
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 22928
:
89851
|
89862
|
89866
|
89867
|
89899
| 89900