From e207818321a98dd00e58e60a9287558f0ff66f3f Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 28 Mar 2018 12:42:19 +0000
Subject: [PATCH] Bug 19564: (QA follow-up) Make commented out tests pass

We likely shoudln't pass through an uncoverted sort order for now, but
it does allow us to look ahead to implementing the orders directly so
seems a good option to have.

Either this patch should be used, or the commented out tests should be
removed

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 Koha/SearchEngine/Elasticsearch/QueryBuilder.pm      |  2 +-
 .../Koha_SearchEngine_Elasticsearch_Search.t         | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
index 98a2d59..8a0ead1 100644
--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
@@ -487,7 +487,7 @@ sub _convert_sort_fields {
         pubdate     => 'pubdate',
     );
     my %sort_order_convert =
-      ( qw( dsc desc ), qw( asc asc ), qw( az asc ), qw( za desc ) );
+      ( qw( desc desc ), qw( dsc desc ), qw( asc asc ), qw( az asc ), qw( za desc ) );
 
     # Convert the fields and orders, drop anything we don't know about.
     grep { $_->{field} } map {
diff --git a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t b/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t
index de7ef95..5085690 100644
--- a/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t
+++ b/t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t
@@ -230,7 +230,7 @@ subtest 'build_query tests' => sub {
 };
 
 subtest "_convert_sort_fields" => sub {
-    plan tests => 1;
+    plan tests => 2;
     my @sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_dsc ));
     is_deeply(
         \@sort_by,
@@ -242,13 +242,13 @@ subtest "_convert_sort_fields" => sub {
     );
 
     # We could expect this to pass, but direction is undef instead of 'desc'
-    #@sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_desc ));
-    #is_deeply(
-    #    \@sort_by,
-    #    [
-    #        { field => 'callnum', direction => 'asc' },
-    #        { field => 'author',  direction => 'desc' }
-    #    ],
-    #    'sort fields should have been split correctly'
-    #);
+    @sort_by = $builder->_convert_sort_fields(qw( call_number_asc author_desc ));
+    is_deeply(
+        \@sort_by,
+        [
+            { field => 'callnum', direction => 'asc' },
+            { field => 'author',  direction => 'desc' }
+        ],
+        'sort fields should have been split correctly'
+    );
 };
-- 
2.1.4