Skip to content

Commit f03c184

Browse files
committed
Fix HasManyDeep global search test expectation
- Update test to expect 20 unique users instead of 60 comment rows - Global search on HasManyDeep returns unique parent records when selecting from parent table - This matches the behavior of other has-many relationships in the codebase
1 parent b546989 commit f03c184

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/Integration/HasManyDeepRelationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ public function it_can_perform_global_search_on_the_relation()
5858
'search' => ['value' => 'Comment-1'],
5959
]);
6060

61-
// HasManyDeep can return multiple rows per user (one per comment matching the search)
62-
// Each user has 3 posts with 2 comments each. Searching for 'Comment-1' matches
63-
// one comment per post, so we expect at least 20 users × 3 posts = 60 results
61+
// Global search on HasManyDeep relationship returns unique users that have matching comments
62+
// Since we're selecting users.*, we get one row per user, not one row per matching comment
63+
// All 20 users have comments with 'Comment-1', so we expect 20 results
6464
$response->assertJson([
6565
'draw' => 0,
6666
'recordsTotal' => 20,
67+
'recordsFiltered' => 20,
6768
]);
6869

69-
$this->assertGreaterThanOrEqual(60, $response->json()['recordsFiltered']);
70-
$this->assertGreaterThanOrEqual(60, count($response->json()['data']));
70+
$this->assertCount(20, $response->json()['data']);
7171
}
7272

7373
#[Test]

0 commit comments

Comments
 (0)