feat(cms): sync site assets, revalidate webhook, and document download naming
This commit is contained in:
51
tests/Feature/Cms/HomepageApiTest.php
Normal file
51
tests/Feature/Cms/HomepageApiTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Cms;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Page;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HomepageApiTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_homepage_endpoint_returns_expected_sections(): void
|
||||
{
|
||||
Article::factory()->pinned(0)->create(['content_type' => Article::CONTENT_TYPE_BLOG]);
|
||||
Article::factory()->pinned(1)->create(['content_type' => Article::CONTENT_TYPE_NOTICE]);
|
||||
|
||||
Article::factory()->create(['content_type' => Article::CONTENT_TYPE_BLOG]);
|
||||
Article::factory()->create(['content_type' => Article::CONTENT_TYPE_NOTICE]);
|
||||
Article::factory()->create(['content_type' => Article::CONTENT_TYPE_DOCUMENT]);
|
||||
Article::factory()->create(['content_type' => Article::CONTENT_TYPE_RELATED_NEWS]);
|
||||
|
||||
$about = Page::factory()->create(['slug' => 'about']);
|
||||
|
||||
$this->getJson('/api/v1/homepage')
|
||||
->assertOk()
|
||||
->assertJsonStructure([
|
||||
'featured' => [
|
||||
'*' => ['id', 'title', 'slug', 'content_type'],
|
||||
],
|
||||
'latest_blog' => [
|
||||
'*' => ['id', 'title', 'slug', 'content_type'],
|
||||
],
|
||||
'latest_notice' => [
|
||||
'*' => ['id', 'title', 'slug', 'content_type'],
|
||||
],
|
||||
'latest_document' => [
|
||||
'*' => ['id', 'title', 'slug', 'content_type'],
|
||||
],
|
||||
'latest_related_news' => [
|
||||
'*' => ['id', 'title', 'slug', 'content_type'],
|
||||
],
|
||||
'about' => ['id', 'slug', 'content'],
|
||||
'categories' => [
|
||||
'*' => ['id', 'name', 'slug'],
|
||||
],
|
||||
])
|
||||
->assertJsonPath('about.slug', $about->slug);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user