Skip to content

Commit

Permalink
multi-space test
Browse files Browse the repository at this point in the history
  • Loading branch information
vd1992 committed May 22, 2024
1 parent 90c0524 commit 50037b0
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions api/tests/Feature/KeywordSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
'current_city' => 'abc',
]);
$user2 = User::factory()->create([
'first_name' => 'bob',
'last_name' => 'johnson',
'email' => '[email protected]',
'current_city' => 'efg',
]);
$user3 = User::factory()->create([
'first_name' => 'jones',
'last_name' => 'hall',
'email' => '[email protected]',
'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');
}
}

0 comments on commit 50037b0

Please sign in to comment.