From bce37851cf16e314dae810f26c5bb924aaeb8e63 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 9 Jul 2024 13:23:50 +0000 Subject: [PATCH] Bug 37289: Add sorting to test Ensure the order of embedded records returned. Dont apply the DONT PUSH patch. prove ./t/db_dependent/api/v1/authorised_values.t ---> Notice if passes Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- t/db_dependent/api/v1/authorised_values.t | 38 ++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/api/v1/authorised_values.t b/t/db_dependent/api/v1/authorised_values.t index 067701e1be..1a322112f4 100755 --- a/t/db_dependent/api/v1/authorised_values.t +++ b/t/db_dependent/api/v1/authorised_values.t @@ -104,18 +104,48 @@ subtest 'list_av_from_category() tests' => sub { # Test the query webservice endpoint for multiple av_cats with authorised_values embedded my $av_2 = $builder->build_object( - { class => 'Koha::AuthorisedValues', value => { category => $av_cat_2->category_name, lib => undef } } ); + { + class => 'Koha::AuthorisedValues', + value => { + category => $av_cat_2->category_name, + authorised_value => 'a', + lib => undef + } + } + ); my $av_3 = $builder->build_object( { class => 'Koha::AuthorisedValues', - value => { category => $av_cat_2->category_name, lib => 'description_value' } + value => { + category => $av_cat_2->category_name, + authorised_value => 'c', + lib => 'description_value' + } + } + ); + my $av_4 = $builder->build_object( + { + class => 'Koha::AuthorisedValues', + value => { + category => $av_cat_2->category_name, + authorised_value => 'b', + lib => 'description_value' + } } ); my $embedded_av_query = { "me.category_name" => [ $av_cat_2->category_name ] }; - $t->get_ok( "//$userid:$password@/api/v1/authorised_value_categories?q=" + $t->get_ok( "//$userid:$password@/api/v1/authorised_value_categories?_order_by=authorised_values.authorised_value&q=" . encode_json($embedded_av_query) => { 'x-koha-embed' => 'authorised_values' } )->status_is(200) - ->json_is( [ { %{ $av_cat_2->to_api }, authorised_values => [ $av_2->to_api, $av_3->to_api ] } ] ); + ->json_is( + [ + { + %{ $av_cat_2->to_api }, + authorised_values => + [ $av_2->to_api, $av_4->to_api, $av_3->to_api ] + } + ] + ); $schema->storage->txn_rollback; }; -- 2.39.5