Bug 36482: Add embed tests

prove t/db_dependent/api/v1/libraries.t

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2024-04-04 11:14:11 +00:00 committed by Katrin Fischer
parent 8cd64b5dd6
commit 39879cd5cf
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -111,7 +111,7 @@ subtest 'list() tests' => sub {
subtest 'get() tests' => sub {
plan tests => 6;
plan tests => 12;
$schema->storage->txn_begin;
@ -128,6 +128,19 @@ subtest 'get() tests' => sub {
->status_is( 200, 'SWAGGER3.2.2' )
->json_is( '' => $library->to_api, 'SWAGGER3.3.2' );
$t->get_ok( "//$userid:$password@/api/v1/libraries/"
. $library->branchcode => { 'x-koha-embed' => 'cash_registers,desks' } )->status_is(200)
->json_is( { %{ $library->to_api }, desks => [], cash_registers => [] } );
my $desk = $builder->build_object( { class => 'Koha::Desks', value => { branchcode => $library->id } } );
my $cash_register =
$builder->build_object( { class => 'Koha::Cash::Registers', value => { branch => $library->id } } );
$t->get_ok( "//$userid:$password@/api/v1/libraries/"
. $library->branchcode => { 'x-koha-embed' => 'cash_registers,desks' } )->status_is(200)
->json_is(
{ %{ $library->to_api }, desks => [ $desk->to_api ], cash_registers => [ $cash_register->to_api ] } );
my $non_existent_code = $library->branchcode;
$library->delete;