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