- blog_paginate: 纯列表模式每页 50 条(list_per_page 可调),其余模式仍走 per_page - 图文(card)模式:卡片网格改为左图右文横排,小屏回退竖排;摘要放宽到 100 字 - 新增 covers:generate:复用 AI 设置的 LLM 配置调 /image_generation(默认 image-01), 为无封面文章批量生成封面存入 media cover 集合;支持 --all/--limit/--post/--style/--dry-run - AI 设置页新增图片模型、封面风格两项配置 - 修正 HomeViewModeTest:列表模式为纯标题(不再显示摘要),并断言每页 50 条与图文布局
90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Category;
|
|
use App\Models\Post;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class HomeViewModeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private Post $post;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->seed();
|
|
|
|
$user = User::create(['name' => '作者', 'email' => 'view@test.com', 'password' => bcrypt('x')]);
|
|
$category = Category::create(['name' => '技术', 'slug' => 'tech-view']);
|
|
$this->post = Post::create([
|
|
'user_id' => $user->id,
|
|
'category_id' => $category->id,
|
|
'title' => '浏览模式测试文',
|
|
'slug' => 'view-mode-test',
|
|
'excerpt' => '列表摘要文字',
|
|
'content' => '这是完整正文内容 FULL_BODY_ONLY_TOKEN',
|
|
'content_format' => 'markdown',
|
|
'status' => 'published',
|
|
'published_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function test_list_mode_is_title_only(): void
|
|
{
|
|
$this->get('/?view=list')
|
|
->assertOk()
|
|
->assertSee('浏览模式', false)
|
|
->assertSee('浏览模式测试文', false)
|
|
->assertDontSee('列表摘要文字', false)
|
|
->assertDontSee('FULL_BODY_ONLY_TOKEN', false);
|
|
}
|
|
|
|
public function test_full_mode_shows_article_body(): void
|
|
{
|
|
$this->get('/?view=full')
|
|
->assertOk()
|
|
->assertSee('浏览模式', false)
|
|
->assertSee('FULL_BODY_ONLY_TOKEN', false);
|
|
}
|
|
|
|
public function test_compact_pagination_shows_page_info(): void
|
|
{
|
|
$userId = $this->post->user_id;
|
|
$categoryId = $this->post->category_id;
|
|
|
|
for ($index = 1; $index <= 12; $index++) {
|
|
Post::create([
|
|
'user_id' => $userId,
|
|
'category_id' => $categoryId,
|
|
'title' => '分页文章 '.$index,
|
|
'slug' => 'pager-'.$index,
|
|
'content' => '正文 '.$index,
|
|
'content_format' => 'markdown',
|
|
'status' => 'published',
|
|
'published_at' => now()->subMinutes($index),
|
|
]);
|
|
}
|
|
|
|
// 列表模式每页 50 条:13 篇文章应在同一页
|
|
$this->get('/')
|
|
->assertOk()
|
|
->assertSee('pagination-info', false)
|
|
->assertSee('1 / 1', false);
|
|
}
|
|
|
|
public function test_card_mode_uses_left_image_layout(): void
|
|
{
|
|
$this->get('/?view=card')
|
|
->assertOk()
|
|
->assertSee('post-list-card', false)
|
|
->assertSee('post-card-card', false)
|
|
->assertSee('post-card-body', false);
|
|
}
|
|
}
|