Add news article comments and reactions
This commit is contained in:
@@ -192,6 +192,7 @@ it('stores a newsroom draft with taxonomy links', function (): void {
|
||||
'editorial_status' => NewsArticle::EDITORIAL_STATUS_DRAFT,
|
||||
'published_at' => null,
|
||||
'tag_ids' => [$tag->id],
|
||||
'new_tag_names' => ['Studio Exclusive'],
|
||||
'is_featured' => true,
|
||||
'is_pinned' => false,
|
||||
'meta_title' => 'Stored newsroom draft meta',
|
||||
@@ -212,5 +213,89 @@ it('stores a newsroom draft with taxonomy links', function (): void {
|
||||
'status' => 'draft',
|
||||
]);
|
||||
|
||||
expect($article->tags()->pluck('news_tags.id')->all())->toBe([$tag->id]);
|
||||
expect($article->tags()->pluck('news_tags.name')->all())
|
||||
->toContain('Update')
|
||||
->toContain('Studio Exclusive');
|
||||
});
|
||||
|
||||
it('updates an existing newsroom article', function (): void {
|
||||
$moderator = User::factory()->create([
|
||||
'role' => 'moderator',
|
||||
]);
|
||||
$author = User::factory()->create();
|
||||
$category = studioNewsCategory([
|
||||
'name' => 'Editorial',
|
||||
'slug' => 'editorial',
|
||||
]);
|
||||
$tag = studioNewsTag([
|
||||
'name' => 'Feature',
|
||||
'slug' => 'feature',
|
||||
]);
|
||||
|
||||
$article = NewsArticle::query()->create([
|
||||
'title' => 'Original newsroom article',
|
||||
'slug' => 'original-newsroom-article',
|
||||
'excerpt' => 'Original excerpt.',
|
||||
'content' => 'Original content.',
|
||||
'author_id' => $author->id,
|
||||
'type' => NewsArticle::TYPE_ANNOUNCEMENT,
|
||||
'status' => 'draft',
|
||||
'editorial_status' => NewsArticle::EDITORIAL_STATUS_DRAFT,
|
||||
]);
|
||||
|
||||
$this->actingAs($moderator)
|
||||
->patch(route('studio.news.update', ['article' => $article->id]), [
|
||||
'title' => 'Updated newsroom article',
|
||||
'slug' => 'updated-newsroom-article',
|
||||
'excerpt' => 'Updated excerpt.',
|
||||
'content' => '<p>Updated content.</p>',
|
||||
'type' => NewsArticle::TYPE_EDITORIAL,
|
||||
'category_id' => $category->id,
|
||||
'author_id' => $author->id,
|
||||
'editorial_status' => NewsArticle::EDITORIAL_STATUS_IN_REVIEW,
|
||||
'tag_ids' => [$tag->id],
|
||||
'new_tag_names' => ['Deep Dive'],
|
||||
'is_featured' => true,
|
||||
'is_pinned' => true,
|
||||
])
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect();
|
||||
|
||||
$article->refresh();
|
||||
|
||||
expect($article->title)->toBe('Updated newsroom article')
|
||||
->and($article->slug)->toBe('updated-newsroom-article')
|
||||
->and($article->type)->toBe(NewsArticle::TYPE_EDITORIAL)
|
||||
->and($article->editorial_status)->toBe(NewsArticle::EDITORIAL_STATUS_IN_REVIEW)
|
||||
->and((int) $article->category_id)->toBe($category->id)
|
||||
->and((bool) $article->is_featured)->toBeTrue()
|
||||
->and((bool) $article->is_pinned)->toBeTrue()
|
||||
->and($article->tags()->pluck('news_tags.name')->all())->toContain('Feature')
|
||||
->and($article->tags()->pluck('news_tags.name')->all())->toContain('Deep Dive');
|
||||
});
|
||||
|
||||
it('soft deletes a newsroom article from studio', function (): void {
|
||||
$moderator = User::factory()->create([
|
||||
'role' => 'moderator',
|
||||
]);
|
||||
$author = User::factory()->create();
|
||||
|
||||
$article = NewsArticle::query()->create([
|
||||
'title' => 'Delete me softly',
|
||||
'slug' => 'delete-me-softly',
|
||||
'excerpt' => 'Soft delete test article.',
|
||||
'content' => 'Studio delete content.',
|
||||
'author_id' => $author->id,
|
||||
'type' => NewsArticle::TYPE_EDITORIAL,
|
||||
'status' => 'draft',
|
||||
'editorial_status' => NewsArticle::EDITORIAL_STATUS_DRAFT,
|
||||
]);
|
||||
|
||||
$this->actingAs($moderator)
|
||||
->delete(route('studio.news.destroy', ['article' => $article->id]))
|
||||
->assertRedirect(route('studio.news.index'));
|
||||
|
||||
$this->assertSoftDeleted('news_articles', [
|
||||
'id' => $article->id,
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user