Add feature test coverage for the core domain

Only Breeze's default auth/profile tests existed - nothing covered
Workouts, Sessions, Exercises, Yoga, Favorites, Blog, or the Admin
panel, which is the actual product. Adds factories for the domain
models and 45 new feature tests covering the main flows plus
authorization boundaries (owner-only access on workouts/sessions,
admin-only access on /admin, drafts hidden from the public blog).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-10 11:47:51 +03:00
co-authored by Claude Sonnet 5
parent 221493e56f
commit 0a36afbfdc
17 changed files with 861 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
<?php
namespace Tests\Feature;
use App\Models\Post;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class BlogTest extends TestCase
{
use RefreshDatabase;
public function test_index_only_lists_published_posts(): void
{
$published = Post::factory()->create(['published_at' => now()->subDay()]);
Post::factory()->draft()->create();
$response = $this->get(route('blog.index'));
$response->assertOk();
$response->assertSee($published->title);
$response->assertViewHas('posts', function ($posts) {
return $posts->total() === 1;
});
}
public function test_index_excludes_future_scheduled_posts(): void
{
Post::factory()->create(['published_at' => now()->addDay()]);
$response = $this->get(route('blog.index'));
$response->assertOk();
$response->assertViewHas('posts', function ($posts) {
return $posts->total() === 0;
});
}
public function test_show_displays_a_published_post(): void
{
$post = Post::factory()->create([
'title' => 'How to Train Consistently',
'published_at' => now()->subDay(),
]);
$response = $this->get(route('blog.show', $post->slug));
$response->assertOk();
$response->assertSee('How to Train Consistently');
}
public function test_show_returns_404_for_a_draft_post(): void
{
$post = Post::factory()->draft()->create();
$response = $this->get(route('blog.show', $post->slug));
$response->assertNotFound();
}
public function test_show_returns_404_for_unknown_slug(): void
{
$response = $this->get('/blog/does-not-exist');
$response->assertNotFound();
}
}