feat: get my meal posts
This commit is contained in:
@@ -97,6 +97,36 @@ it('returns workouts for the authenticated user', function () {
|
||||
]);
|
||||
});
|
||||
|
||||
it('filters workouts by date', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
$todayWorkoutSession = WorkoutSessions::factory()->for($user, 'user')->create([
|
||||
'calories_burned' => 450,
|
||||
'started_at' => '2026-05-19 07:30:00',
|
||||
]);
|
||||
$eveningWorkoutSession = WorkoutSessions::factory()->for($user, 'user')->create([
|
||||
'calories_burned' => 120,
|
||||
'started_at' => '2026-05-19 19:30:00',
|
||||
]);
|
||||
$yesterdayWorkoutSession = WorkoutSessions::factory()->for($user, 'user')->create([
|
||||
'calories_burned' => 320,
|
||||
'started_at' => '2026-05-18 10:00:00',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$response = $this->getJson('/api/workouts?date=2026-05-19');
|
||||
|
||||
$response
|
||||
->assertOk()
|
||||
->assertJsonCount(2, 'data')
|
||||
->assertJsonPath('data.0.id', $eveningWorkoutSession->id)
|
||||
->assertJsonPath('data.1.id', $todayWorkoutSession->id)
|
||||
->assertJsonMissing([
|
||||
'id' => $yesterdayWorkoutSession->id,
|
||||
]);
|
||||
});
|
||||
|
||||
it('validates the workouts pagination size', function () {
|
||||
Sanctum::actingAs(User::factory()->create());
|
||||
|
||||
@@ -106,6 +136,15 @@ it('validates the workouts pagination size', function () {
|
||||
->assertJsonValidationErrors(['per_page']);
|
||||
});
|
||||
|
||||
it('validates the workouts date filter', function () {
|
||||
Sanctum::actingAs(User::factory()->create());
|
||||
|
||||
$this
|
||||
->getJson('/api/workouts?date=2026-13-01')
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['date']);
|
||||
});
|
||||
|
||||
it('validates workout creation data', function () {
|
||||
Sanctum::actingAs(User::factory()->create());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user