From 146c1e1d9f8d94e10d189fb601f71f6683963b7d 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 --- t/db_dependent/selenium/regressions.t | 35 ++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t index ae2112f1cc..aa7717f806 100755 --- a/t/db_dependent/selenium/regressions.t +++ b/t/db_dependent/selenium/regressions.t @@ -20,7 +20,7 @@ use utf8; use C4::Context; -use Test::More tests => 6; +use Test::More tests => 7; use Test::MockModule; use C4::Context; @@ -299,6 +299,39 @@ subtest 'Encoding in session variables' => sub { }; +subtest 'OPAC - Suggest for purchase' => sub { + plan tests => 4; + + my $builder = t::lib::TestBuilder->new; + + 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 { -- 2.39.5