From b569f09fc1c94f439a0251ce7995ca2a7731bc5b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 25 Apr 2024 16:10:24 +0100 Subject: [PATCH] Bug 35628: Unit tests for addition to tickets API This patch updates the unit test for the ticket_updates api to catch both the missing test 'state' for the existing state change functionality and also the new 'status' functionality introduced with this patchset. Signed-off-by: Martin Renvoize --- t/db_dependent/api/v1/ticket_updates.t | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/ticket_updates.t b/t/db_dependent/api/v1/ticket_updates.t index 93e8d6968e3..7349c2761e8 100755 --- a/t/db_dependent/api/v1/ticket_updates.t +++ b/t/db_dependent/api/v1/ticket_updates.t @@ -118,7 +118,7 @@ subtest 'list_updates() tests' => sub { subtest 'add_update() tests' => sub { - plan tests => 34; + plan tests => 37; $schema->storage->txn_begin; @@ -145,7 +145,12 @@ subtest 'add_update() tests' => sub { my $ticket = $builder->build_object( { class => 'Koha::Tickets', - value => { reporter_id => $patron->id } + value => { + reporter_id => $patron->id, + resolver_id => undef, + resolved_date => undef, + status => 'new' + } } ); my $ticket_id = $ticket->id; @@ -233,7 +238,9 @@ subtest 'add_update() tests' => sub { ); $THE_notice->delete; + # Check that state change triggers correct notice $update->{state} = 'resolved'; + $update->{status} = 'TEST'; $update_id = $t->post_ok( "//$userid:$password@/api/v1/tickets/$ticket_id/updates" => json => @@ -253,5 +260,19 @@ subtest 'add_update() tests' => sub { 'Notice queued was a TICKET_RESOLVED for status changing update' ); + # Check that state change is carried over to ticket + $ticket = $ticket->get_from_storage; + is( + $ticket->resolver_id, $librarian->id, + "Ticket was given resolver_id matching the librarian id of the update when state was changed to 'resolved'" + ); + isnt( $ticket->resolved_date, undef, "Ticket was given resolved_date when state was updated to 'resolved'" ); + + # Check that status change is carried over to ticket + is( + $ticket->status, 'TEST', + "Ticket status was updated in line with status change in update" + ); + $schema->storage->txn_rollback; }; -- 2.44.0