From 50037b07b2f65ac733a08e281b7cbe0775b6afde Mon Sep 17 00:00:00 2001 From: vd1992 <40485260+vd1992@users.noreply.github.com> Date: Wed, 22 May 2024 16:19:58 -0600 Subject: [PATCH] multi-space test --- api/tests/Feature/KeywordSearchTest.php | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/api/tests/Feature/KeywordSearchTest.php b/api/tests/Feature/KeywordSearchTest.php index dce0ff87d86..a312478c37a 100644 --- a/api/tests/Feature/KeywordSearchTest.php +++ b/api/tests/Feature/KeywordSearchTest.php @@ -905,4 +905,66 @@ public function testUserSearchPartialNamesEmailsWithPunctuation() 'id' => $user2->id, ])->assertJsonCount(2, 'data.usersPaginated.data'); } + + public function testUserSearchMultiSpacing() + { + $user1 = User::factory()->create([ + 'first_name' => 'john', + 'last_name' => 'smith', + 'email' => 'john@test.com', + 'current_city' => 'abc', + ]); + $user2 = User::factory()->create([ + 'first_name' => 'bob', + 'last_name' => 'johnson', + 'email' => 'bob@test.com', + 'current_city' => 'efg', + ]); + $user3 = User::factory()->create([ + 'first_name' => 'jones', + 'last_name' => 'hall', + 'email' => 'johnson@test.com', + 'current_city' => 'hij', + ]); + + // search operators unaffected by multiple spaces being present, two users returned regardless of spacing + $this->actingAs($this->platformAdmin, 'api')->graphQL( + /** @lang GraphQL */ + ' + query getUsersPaginated($where: UserFilterInput) { + usersPaginated(where: $where) { + data { + id + } + } + } + ', [ + 'where' => [ + 'generalSearch' => '"johnson" OR john@', + ], + ])->assertJsonFragment([ + 'id' => $user1->id, + ])->assertJsonFragment([ + 'id' => $user2->id, + ])->assertJsonCount(2, 'data.usersPaginated.data'); + $this->actingAs($this->platformAdmin, 'api')->graphQL( + /** @lang GraphQL */ + ' + query getUsersPaginated($where: UserFilterInput) { + usersPaginated(where: $where) { + data { + id + } + } + } + ', [ + 'where' => [ + 'generalSearch' => ' "johnson" OR john@ ', + ], + ])->assertJsonFragment([ + 'id' => $user1->id, + ])->assertJsonFragment([ + 'id' => $user2->id, + ])->assertJsonCount(2, 'data.usersPaginated.data'); + } }