From 8618b862651403311bf3ae0918b3b124704bff5e Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Wed, 11 Dec 2024 14:09:28 -0300
Subject: [PATCH] Bug 38678: Regression tests
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
---
t/db_dependent/api/v1/deleted_biblios.t | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/t/db_dependent/api/v1/deleted_biblios.t b/t/db_dependent/api/v1/deleted_biblios.t
index 2f13fb71898..625e64fac48 100755
--- a/t/db_dependent/api/v1/deleted_biblios.t
+++ b/t/db_dependent/api/v1/deleted_biblios.t
@@ -36,6 +36,7 @@ use C4::Circulation qw( AddIssue AddReturn );
use Koha::Biblios;
use Koha::Database;
+use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Checkouts;
use Koha::Old::Checkouts;
@@ -164,7 +165,7 @@ subtest 'get() tests' => sub {
subtest 'list() tests' => sub {
- plan tests => 17;
+ plan tests => 21;
$schema->storage->txn_begin;
@@ -228,6 +229,27 @@ subtest 'list() tests' => sub {
$t->get_ok( "//$userid:$password@/api/v1/deleted/biblios?q=$query" => { Accept => 'text/plain' } )->status_is(200);
+ my $old_biblio_1 = Koha::Old::Biblios->find($biblio_id_1);
+ my $old_biblio_2 = Koha::Old::Biblios->find($biblio_id_2);
+
+ $old_biblio_1->set( { timestamp => dt_from_string('2024-12-12T17:33:57+00:00') } )->store();
+ $old_biblio_2->set( { timestamp => dt_from_string('2024-12-11T17:33:57+00:00') } )->store();
+
+ $query = encode_json(
+ {
+ "-and" => [
+ { 'me.deleted_on' => { '>=' => '2024-12-12T00:00:00+00:00' } },
+ [
+ { biblio_id => $old_biblio_1->id },
+ { biblio_id => $old_biblio_2->id },
+ ]
+ ]
+ }
+ );
+
+ $t->get_ok( "//$userid:$password@/api/v1/deleted/biblios?q=$query" => { Accept => 'application/json' } )
+ ->status_is(200)->json_is( '/0/biblio_id' => $old_biblio_1->id )->json_is( '/1/biblio_id' => undef );
+
# DELETE any biblio with ISBN = TOMAS
Koha::Biblios->search( { 'biblioitem.isbn' => 'TOMAS' }, { join => ['biblioitem'] } )->delete;
--
2.39.5 (Apple Git-154)