create(array_merge([ 'name' => 'Platform Updates', 'slug' => 'platform-updates-' . Str::lower(Str::random(6)), 'description' => 'Skinbase platform updates.', 'position' => 0, 'is_active' => true, ], $attributes)); } function newsTag(array $attributes = []): NewsTag { return NewsTag::query()->create(array_merge([ 'name' => 'Launch', 'slug' => 'launch-' . Str::lower(Str::random(6)), ], $attributes)); } function publishedNewsArticle(User $author, NewsCategory $category, array $attributes = []): NewsArticle { $article = NewsArticle::query()->create(array_merge([ 'title' => 'Nova newsroom launch', 'slug' => 'nova-newsroom-launch-' . Str::lower(Str::random(6)), 'excerpt' => 'A first-party newsroom for launches, tutorials, and editorials.', 'content' => "# Nova newsroom\n\nThis is the first newsroom article.", 'author_id' => $author->id, 'category_id' => $category->id, 'type' => NewsArticle::TYPE_PLATFORM_UPDATE, 'status' => 'published', 'editorial_status' => NewsArticle::EDITORIAL_STATUS_PUBLISHED, 'published_at' => now()->subHour(), 'is_featured' => true, 'is_pinned' => true, ], $attributes)); return $article; } it('renders published news across public discovery routes', function (): void { $author = User::factory()->create([ 'username' => 'newsauthor', 'name' => 'News Author', ]); $category = newsCategory([ 'name' => 'Announcements', 'slug' => 'announcements', ]); $tag = newsTag([ 'name' => 'Release', 'slug' => 'release', ]); $article = publishedNewsArticle($author, $category, [ 'title' => 'Skinbase Nova Newsroom', 'slug' => 'skinbase-nova-newsroom', ]); $article->tags()->sync([$tag->id]); publishedNewsArticle($author, $category, [ 'title' => 'Hidden Draft', 'slug' => 'hidden-draft', 'status' => 'draft', 'editorial_status' => NewsArticle::EDITORIAL_STATUS_DRAFT, 'published_at' => null, 'is_featured' => false, 'is_pinned' => false, ]); $this->get(route('news.index')) ->assertOk() ->assertSee('Skinbase Nova Newsroom') ->assertDontSee('Hidden Draft'); $this->get(route('news.show', ['slug' => $article->slug])) ->assertOk() ->assertSee('Skinbase Nova Newsroom') ->assertSee('News Author'); $this->get(route('news.category', ['slug' => $category->slug])) ->assertOk() ->assertSee('Skinbase Nova Newsroom'); $this->get(route('news.tag', ['slug' => $tag->slug])) ->assertOk() ->assertSee('Skinbase Nova Newsroom'); $this->get(route('news.archive', ['year' => $article->published_at->year, 'month' => $article->published_at->month])) ->assertOk() ->assertSee('Skinbase Nova Newsroom'); $this->get(route('news.author', ['username' => $author->username])) ->assertOk() ->assertSee('Skinbase Nova Newsroom'); }); it('renders a public news article when anonymous sessions are skipped', function (): void { Config::set('skinbase-sessions.enabled', true); Config::set('skinbase-sessions.debug_header', true); $author = User::factory()->create([ 'username' => 'guestnewsauthor', 'name' => 'Guest News Author', ]); $category = newsCategory([ 'name' => 'Guest Announcements', 'slug' => 'guest-announcements', ]); $article = publishedNewsArticle($author, $category, [ 'title' => 'Guest Sessionless News Page', 'slug' => 'guest-sessionless-news-page', ]); $this->get(route('news.show', ['slug' => $article->slug])) ->assertOk() ->assertHeader('X-Skinbase-Session', 'skipped') ->assertSee('Guest Sessionless News Page'); });