Bugzilla – Attachment 175307 Details for
Bug 38441
ILL - Allow for a history check workflow stage
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38441: Add tests
Bug-38441-Add-tests.patch (text/plain), 9.42 KB, created by
Pedro Amorim
on 2024-12-09 12:09:59 UTC
(
hide
)
Description:
Bug 38441: Add tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-12-09 12:09:59 UTC
Size:
9.42 KB
patch
obsolete
>From 4d6a7ef0bfacf4a5781a2aadd7fc63a6ab73d5d0 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 14 Nov 2024 13:55:16 +0000 >Subject: [PATCH] Bug 38441: Add tests > >Test plan: >1) Apply patches >2) Run (ignore if using a sandbox): > $ reset_all >3) Visit ILL system preferences: > <staff_url>/cgi-bin/koha/admin/preferences.pl?tab=interlibrary_loans >4) Enable ILLModule and ILLHistoryCheck system preferences > >-- STAFF testing -- > >5) Create a new ILL request, visit: > <staff_url>/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=Standard >6) Pick type = 'Journal article', enter '123' for ISSN, '42' for cardnumber and any library. Click create. >7) Repeat 5) and 6). Notice you're now on the 'Request history check' screen. Verify your previous ILL request is listed. Click 'Submit anyway'. >8) Repeat 5) and 6). But pick a different patron cardnumber this time e.g. '23529000035676'. >9) Verify you're shown the 'Request history check' screen listing the 2 previously created requests. Click 'Submit anyway'. >10) Repeat 5 and 6). Use cardnumber '23529000035676' again. >11) Verify you're shown the 'Request history check' screen. The listing now shows the requests found for this patron first, then lists the remaining found requests for other patrons. > >-- OPAC testing -- > >12) Place a new request through the OPAC, visit: > <opac_url>/cgi-bin/koha/opac-illrequests.pl?op=add_form&backend=Standard >13) Pick type = 'Journal article', enter '123' for ISSN. Click 'Create'. Notice it shows the 'history check' screen listing the existing 2 requests. Click 'Submit anyway'. >14) Return to the Staff UI: > <staff_url>/cgi-bin/koha/ill/ill-requests.pl >15) Click on the latest ILL request. Verify 'Staff notes' contain information relating to already existing ILL requests. > >-- Bonus testing -- >16) On the Staff UI, create a new request for cardnumber 23529000035676 with ISSN = 321 >17) On the OPAC, logged in as koha:koha, place a request with ISSN = 321. Verify you don't get shown the history check but the staff notes is still added >18) Play around with ILLModuleDisclaimerByType and > ILLOpacUnauthenticatedRequest (easy) >19) Play around with ILLCheckAvailability and AutoILLBackendPriority > (reach out for help using these preferences) > >Run tests: >$ prove t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t >--- > .../Koha/ILL/Request/Workflow/HistoryCheck.t | 209 ++++++++++++++++++ > 1 file changed, 209 insertions(+) > create mode 100755 t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t > >diff --git a/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t b/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t >new file mode 100755 >index 00000000000..72e33882ce2 >--- /dev/null >+++ b/t/db_dependent/Koha/ILL/Request/Workflow/HistoryCheck.t >@@ -0,0 +1,209 @@ >+#!/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 Test::More tests => 2; >+ >+use Test::MockModule; >+use Test::MockObject; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::ILL::Request::Workflow::HistoryCheck; >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+ >+my $issn = '321321321'; >+ >+subtest 'show_history_check' => sub { >+ >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ my $builder = t::lib::TestBuilder->new; >+ >+ use_ok('Koha::ILL::Request::Workflow::HistoryCheck'); >+ >+ my $metadata = { >+ title => 'This is a title', >+ author => 'This is an author', >+ issn => $issn >+ }; >+ >+ # Because hashes can reorder themselves, we need to make sure ours is in a >+ # predictable order >+ my $sorted = {}; >+ foreach my $key ( keys %{$metadata} ) { >+ $sorted->{$key} = $metadata->{$key}; >+ } >+ >+ my $history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $sorted, 'staff' ); >+ >+ isa_ok( $history_check, 'Koha::ILL::Request::Workflow::HistoryCheck' ); >+ >+ is( >+ $history_check->prep_metadata($sorted), >+ 'eyJhdXRob3IiOiJUaGlzIGlzIGFuIGF1dGhvciIsImlzc24iOiIzMjEzMjEzMjEiLCJ0aXRsZSI6%0AIlRoaXMgaXMgYSB0aXRsZSJ9%0A', >+ 'prep_metadata works' >+ ); >+ >+ # Mock capabilities and load_backend >+ my $backend = Test::MockObject->new; >+ $backend->set_always( 'capabilities', sub { return can_create_request => 1 } ); >+ my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); >+ $illreqmodule->mock( >+ 'load_backend', >+ sub { my $self = shift; $self->{_my_backend} = $backend; return $self } >+ ); >+ >+ # Mock ILLHistoryCheck enabled >+ t::lib::Mocks::mock_preference( 'ILLHistoryCheck', 1 ); >+ >+ my $ill_request = $builder->build_sample_ill_request(); >+ is( >+ $history_check->show_history_check($ill_request), >+ 0, 'Request with ISSN ' . $issn . ' does not exist even though syspref is on. Not showing history check screen' >+ ); >+ >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $ill_request->illrequest_id, type => 'issn', value => $issn } >+ } >+ ); >+ >+ is( >+ $history_check->show_history_check($ill_request), >+ 1, 'Request with ISSN ' . $issn . ' exists and syspref is on. Able to show history check screen' >+ ); >+ >+ # Mock ILLHistoryCheck disabled >+ t::lib::Mocks::mock_preference( 'ILLHistoryCheck', 0 ); >+ >+ is( >+ $history_check->show_history_check($ill_request), >+ 0, 'not able to show history check screen' >+ ); >+ >+ $schema->storage->txn_rollback; >+ >+}; >+ >+subtest 'after_request_created' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $builder = t::lib::TestBuilder->new; >+ >+ my $metadata = { >+ title => 'This is a title', >+ author => 'This is an author', >+ issn => $issn >+ }; >+ >+ my $authenticated_patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ } >+ ); >+ >+ my $other_patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ } >+ ); >+ >+ t::lib::Mocks::mock_userenv( { patron => $authenticated_patron } ); >+ >+ # Create an old request >+ my $existing_ill_request = >+ $builder->build_sample_ill_request( { borrowernumber => $other_patron->borrowernumber } ); >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $existing_ill_request->illrequest_id, type => 'issn', value => $issn } >+ } >+ ); >+ >+ # Create a new request with new issn >+ my $new_ill_request = >+ $builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); >+ my $original_staff_notes = $new_ill_request->notesstaff; >+ $metadata->{issn} = 'nonexistentissn'; >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $new_ill_request->illrequest_id, type => 'issn', value => $metadata->{issn} } >+ } >+ ); >+ my $opac_history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $metadata, 'opac' ); >+ $opac_history_check->after_request_created( $metadata, $new_ill_request ); >+ >+ is( >+ $new_ill_request->notesstaff, >+ $original_staff_notes, >+ 'History check didnt find any matching requests. Staff notes have not been updated.' >+ ); >+ >+ # Create a third request with preexisting issn by other patron >+ my $third_ill_request = >+ $builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); >+ $metadata->{issn} = $issn; >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $third_ill_request->illrequest_id, type => 'issn', value => $issn } >+ } >+ ); >+ $opac_history_check->after_request_created( $metadata, $third_ill_request ); >+ >+ like( >+ $third_ill_request->notesstaff, qr/Request has been submitted by other patrons in the past/, >+ 'Contains staffnotes related submissions by other patrons' >+ ); >+ >+ # Create a fourth request with preexisting issn by self patron and others >+ my $fourth_ill_request = >+ $builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); >+ $metadata->{issn} = $issn; >+ $builder->build( >+ { >+ source => 'Illrequestattribute', >+ value => { illrequest_id => $fourth_ill_request->illrequest_id, type => 'issn', value => $issn } >+ } >+ ); >+ $opac_history_check->after_request_created( $metadata, $fourth_ill_request ); >+ >+ like( >+ $fourth_ill_request->notesstaff, qr/Request has been submitted by other patrons in the past/, >+ 'Contains staffnotes related submissions by other patrons' >+ ); >+ >+ like( >+ $fourth_ill_request->notesstaff, qr/Request has been submitted by this patron in the past/, >+ 'Contains staffnotes related submissions by self patron' >+ ); >+ >+}; >+ >+1; >-- >2.39.5
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 38441
:
174604
|
174605
|
174606
|
174607
|
174608
|
174609
|
174610
|
174611
|
175300
|
175301
|
175302
|
175303
|
175304
|
175305
|
175306
|
175307
|
176507
|
176508
|
176509
|
176510
|
176511
|
176512
|
176513
|
176514
|
176561
|
176566
|
176573
|
176829