From 2595bc7092d48d7e25830cfb7b4cd3a66b351f5b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Nov 2018 15:12:32 -0300 Subject: [PATCH] Bug 21775: [18.05.x] Add selenium tests for audio alerts To prevent future regressions --- t/db_dependent/selenium/regressions.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t index 3cc62d17cf..8c95824cd2 100644 --- a/t/db_dependent/selenium/regressions.t +++ b/t/db_dependent/selenium/regressions.t @@ -19,9 +19,10 @@ use Modern::Perl; use C4::Context; -use Test::More tests => 1; +use Test::More tests => 2; use t::lib::Selenium; +use t::lib::TestBuilder; eval { require Selenium::Remote::Driver; }; skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@; @@ -30,11 +31,16 @@ my $s = t::lib::Selenium->new; my $driver = $s->driver; my $opac_base_url = $s->opac_base_url; +my $base_url = $s->base_url; # It seems that we do not have enough records indexed with ES my $SearchEngine_value = C4::Context->preference('SearchEngine'); C4::Context->set_preference('SearchEngine', 'Zebra'); +my $AudioAlerts_value = C4::Context->preference('AudioAlerts'); +C4::Context->set_preference('AudioAlerts', '1'); + +my @data_to_cleanup; subtest 'OPAC - Remove from cart' => sub { plan tests => 4; @@ -69,6 +75,26 @@ subtest 'OPAC - Remove from cart' => sub { 2, '1 element should have been removed from the cart' ); }; +subtest 'Play sound on the circulation page' => sub { + plan tests => 1; + + my $builder = t::lib::TestBuilder->new; + my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0 }}); + + my $mainpage = $s->base_url . q|mainpage.pl|; + $driver->get($mainpage); + like( $driver->get_title(), qr(Log in to Koha), ); + $s->auth; + + $driver->get( $base_url . "/circ/circulation.pl?borrowernumber=" . $patron->borrowernumber ); + + my $audio_node = $driver->find_element('//span[@id="audio-alert"]/audio[@src="/intranet-tmpl/prog/sound/beep.ogg"]'); + + push @data_to_cleanup, $patron, $patron->category, $patron->library; +}; + END { C4::Context->preference('SearchEngine', $SearchEngine_value); + C4::Context->preference('AudioAlerts', $AudioAlerts_value); + $_->delete for @data_to_cleanup; }; -- 2.11.0