From 48c6b73f2d86fcdaf9c58d3814f3332747499cc8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 May 2022 07:20:46 +0200 Subject: [PATCH] Expose shareWithDisplayNameUnique also on autocomplete endpoint Signed-off-by: Joas Schilling --- core/Controller/AutoCompleteController.php | 1 + .../Controller/AutoCompleteControllerTest.php | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/core/Controller/AutoCompleteController.php b/core/Controller/AutoCompleteController.php index 6cbca91ec0f..9f0e43dedd6 100644 --- a/core/Controller/AutoCompleteController.php +++ b/core/Controller/AutoCompleteController.php @@ -118,6 +118,7 @@ class AutoCompleteController extends Controller { 'source' => $type, 'status' => $result['status'] ?? '', 'subline' => $result['subline'] ?? '', + 'shareWithDisplayNameUnique' => $result['shareWithDisplayNameUnique'] ?? '', ]; } } diff --git a/tests/Core/Controller/AutoCompleteControllerTest.php b/tests/Core/Controller/AutoCompleteControllerTest.php index 61fc90e3c82..0775fbbd818 100644 --- a/tests/Core/Controller/AutoCompleteControllerTest.php +++ b/tests/Core/Controller/AutoCompleteControllerTest.php @@ -75,8 +75,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], ], '', 'files', @@ -96,8 +96,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], ], '', null, @@ -117,8 +117,8 @@ class AutoCompleteControllerTest extends TestCase { ], // expected [ - [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], - [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], ], '', 'files', @@ -138,14 +138,35 @@ class AutoCompleteControllerTest extends TestCase { ], ], [ - [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], - [ 'id' => 'bobby', 'label' => 'Robert R.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => ''], + [ 'id' => 'bob', 'label' => 'Bob Y.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], + [ 'id' => 'bobby', 'label' => 'Robert R.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => ''], ], 'bob', 'files', '42', null - ] + ], + [ #4 – with unique name + [ + 'exact' => [ + 'users' => [], + 'robots' => [], + ], + 'users' => [ + ['label' => 'Alice A.', 'value' => ['shareWith' => 'alice'], 'shareWithDisplayNameUnique' => 'alica@nextcloud.com'], + ['label' => 'Alice A.', 'value' => ['shareWith' => 'alicea'], 'shareWithDisplayNameUnique' => 'alicaa@nextcloud.com'], + ], + ], + // expected + [ + [ 'id' => 'alice', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => 'alica@nextcloud.com'], + [ 'id' => 'alicea', 'label' => 'Alice A.', 'icon' => '', 'source' => 'users', 'status' => '', 'subline' => '', 'shareWithDisplayNameUnique' => 'alicaa@nextcloud.com'], + ], + '', + 'files', + '42', + 'karma|bus-factor' + ], ]; } -- 2.39.5