feat(cms): sync site assets, revalidate webhook, and document download naming

This commit is contained in:
2026-02-10 23:38:31 +08:00
parent c4969cd4d2
commit b6e18a83ec
27 changed files with 1019 additions and 26 deletions

View 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);
}
}