Herzen und Kommentare schon in der Vorschau (0.44.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m3s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m26s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m49s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m41s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 45s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m3s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m26s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 9m49s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m41s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 45s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s
- NewsPost::withStats: Herzen (Anzahl, eigenes) und Kommentare (Anzahl) für alle Vorschau-Abfragen: Übersicht, Widgets, Slider, Block, Profil, „Weitere Beiträge“, API - NewsPostResource: „comments“ (null bei ausgeschalteten Kommentaren) - NewsStats.vue in Karte, Listeneintrag, Block-Layouts, Slider und Seitenleiste Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
60dd200300
commit
21307fc953
145 changed files with 471 additions and 358 deletions
|
|
@ -6,6 +6,7 @@ use App\Models\User;
|
|||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\News\Models\NewsComment;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
|
@ -72,4 +73,25 @@ class LikesAndReachTest extends TestCase
|
|||
$this->getJson("/api/v1/news/{$post->slug}", $headers)->assertJsonPath('data.liked', true);
|
||||
$this->deleteJson("/api/v1/news/{$post->slug}/like", [], $headers)->assertOk()->assertJsonPath('data.likes', 0);
|
||||
}
|
||||
|
||||
public function test_previews_show_hearts_and_comments_before_opening(): void
|
||||
{
|
||||
[$ada, $bob] = User::factory()->count(2)->create()->all();
|
||||
$post = NewsPost::factory()->create(['published_at' => now()->subHour(), 'title' => 'Sommerfest']);
|
||||
$quiet = NewsPost::factory()->create(['published_at' => now()->subHours(2), 'comments_enabled' => false]);
|
||||
DB::table('news_likes')->insert([['post_id' => $post->id, 'user_id' => $ada->id, 'created_at' => now()], ['post_id' => $post->id, 'user_id' => $bob->id, 'created_at' => now()]]);
|
||||
NewsComment::query()->create(['post_id' => $post->id, 'user_id' => $ada->id, 'body' => 'Super!']);
|
||||
NewsComment::query()->create(['post_id' => $post->id, 'user_id' => $bob->id, 'body' => 'Bin dabei']);
|
||||
NewsComment::query()->create(['post_id' => $post->id, 'user_id' => $bob->id, 'body' => 'Gelöscht'])->delete();
|
||||
|
||||
$this->actingAs($ada)->get('/neuigkeiten')->assertInertia(fn (Assert $page) => $page
|
||||
->where('posts.data.0.likes', 2)->where('posts.data.0.liked', true)->where('posts.data.0.comments', 2)
|
||||
->where('posts.data.1.comments', null));
|
||||
|
||||
// Startseite (Widget „Neuigkeiten“) und die App bekommen dieselben Zahlen
|
||||
$this->actingAs($bob)->get('/')->assertOk()->assertSee('"comments":2', false);
|
||||
$headers = ['Authorization' => 'Bearer '.$bob->createToken('App')->plainTextToken];
|
||||
$this->getJson('/api/v1/news', $headers)->assertJsonPath('data.0.likes', 2)->assertJsonPath('data.0.comments', 2)->assertJsonPath('data.1.comments', null);
|
||||
$this->assertSame($quiet->id, $this->getJson('/api/v1/news', $headers)->json('data.1.id'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue