From 87a919b3c155e05af10c4ec6aa185b2e920e88dd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 25 Jun 2018 16:48:59 -0300 Subject: [PATCH] Bug 20921: Add selenium tests for .loggedinusername Signed-off-by: Jonathan Druart --- t/db_dependent/selenium/regressions.t | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 t/db_dependent/selenium/regressions.t diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t new file mode 100644 index 0000000000..cdb49ff51f --- /dev/null +++ b/t/db_dependent/selenium/regressions.t @@ -0,0 +1,61 @@ +#!/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 . + +use Modern::Perl; + +use C4::Context; + +use Test::More tests => 1; + +use Koha::AuthUtils; +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 $base_url = $s->base_url; +my $builder = t::lib::TestBuilder->new; + +our @cleanup; +subtest 'OPAC - borrowernumber and branchcode as html attributes' => sub { + plan tests => 2; + + my $patron = $builder->build_object( + { class => 'Koha::Patrons', value => { flags => 1 } } ); + my $password = Koha::AuthUtils::generate_password(); + my $digest = Koha::AuthUtils::hash_password($password); + $patron->update_password( $patron->userid, $digest ); + $s->opac_auth( $patron->userid, $password ); + my $elt = $driver->find_element('//span[@class="loggedinusername"]'); + is( $elt->get_attribute('data-branchcode'), $patron->library->branchcode, + "Since bug 20921 span.loggedinusername should contain data-branchcode" + ); + is( $elt->get_attribute('data-borrowernumber'), $patron->borrowernumber, +"Since bug 20921 span.loggedinusername should contain data-borrowernumber" + ); + push @cleanup, $patron; + push @cleanup, $patron->category; + push @cleanup, $patron->library; +}; + +END { + $_->delete for @cleanup; +}; -- 2.11.0