From feed7892a8a7097f30ee7f3c757cc47edb553a51 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Dec 2021 07:02:08 +0100 Subject: [PATCH] Bug 29696: Add tests Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall (cherry picked from commit 146c1e1d9f8d94e10d189fb601f71f6683963b7d) Bug 29696: correct number of tests for 21.05.x Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit c467f3facad11655b4c817e88a48a3cb17d6547d) Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/selenium/regressions.t | 37 +++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t index 4972515cbf..68027d18f4 100755 --- a/t/db_dependent/selenium/regressions.t +++ b/t/db_dependent/selenium/regressions.t @@ -19,7 +19,7 @@ use Modern::Perl; use C4::Context; -use Test::More tests => 6; +use Test::More tests => 7; use Test::MockModule; use C4::Context; @@ -253,10 +253,43 @@ subtest 'XSS vulnerabilities in pagination' => sub { like( $second_page->get_attribute('href'), qr{(?|&)category=2(&|$)}, 'The second page should display category without the invalid value' ); push @cleanup, $patron, $patron->category, $patron->library; +}; + +subtest 'OPAC - Suggest for purchase' => sub { + plan tests => 4; + + my $builder = t::lib::TestBuilder->new; - $driver->quit(); + my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); + my $password = Koha::AuthUtils::generate_password( $patron->category ); + t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); + $patron->set_password( { password => $password } ); + $s->opac_auth( $patron->userid, $password ); + + my ( $biblionumber, $biblioitemnumber ) = add_biblio(); + my $biblio = Koha::Biblios->find($biblionumber); + $driver->get( $opac_base_url . "opac-detail.pl?biblionumber=$biblionumber" ); + + $s->click({ href => '/opac-suggestions.pl?op=add&biblionumber=' . $biblionumber }); + is( $driver->find_element('//input[@id="title"]')->get_value(), + $biblio->title, + "Suggestion's title correctly filled in with biblio's title" ); + + $driver->find_element('//textarea[@id="note"]')->send_keys('some notes'); + $s->submit_form; + + my $suggestions = Koha::Suggestions->search( { biblionumber => $biblio->biblionumber } ); + is( $suggestions->count, 1, 'Suggestion created' ); + my $suggestion = $suggestions->next; + is( $suggestion->title, $biblio->title, q{suggestion's title has biblio's title} ); + is( $suggestion->note, 'some notes', q{suggestion's note correctly saved} ); + + push @cleanup, $biblio, $suggestion; }; + +$driver->quit(); + END { C4::Context->set_preference('SearchEngine', $SearchEngine_value); C4::Context->set_preference('AudioAlerts', $AudioAlerts_value); -- 2.39.5