Gruppen 1.1.0: Schnittstelle für die App, „Gefällt mir“ mit Symbol
- /api/v1/gruppen: Übersicht, entdecken, Gruppe, beitreten/verlassen, Benachrichtigungen, Beiträge, Reaktionen, Abstimmung, Kommentare, Melden, Fotos/Dateien/Titelbild mit Token - Datei- und Titelbild-Adressen zeigen bei API-Aufrufen auf die API - „Gefällt mir“ zeigt im Ruhezustand ein Daumen-Symbol statt eines Emojis (sieht auch ohne Emoji-Schrift richtig aus) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c2792f6a63
commit
b29f6ada71
12 changed files with 225 additions and 10 deletions
|
|
@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Storage;
|
|||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inhaus\Plugins\Gruppen\Models\Group;
|
||||
use Inhaus\Plugins\Gruppen\Models\Post;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -158,4 +159,38 @@ class GruppenTest extends TestCase
|
|||
$this->actingAs($ada)->post("/gruppen/{$group->slug}/verlassen");
|
||||
$this->assertSame('admin', $group->membership($bob)->role);
|
||||
}
|
||||
|
||||
public function test_app_api_with_token(): void
|
||||
{
|
||||
[$ada, $bob, $eve] = User::factory()->count(3)->create()->all();
|
||||
$open = $this->group($ada, 'open');
|
||||
$closed = $this->group($ada, 'closed', 'Vorstand');
|
||||
$secret = $this->group($ada, 'secret', 'Geheimrat');
|
||||
|
||||
Sanctum::actingAs($ada);
|
||||
$image = $this->post("/api/v1/gruppen/{$open->slug}/beitraege", ['body' => 'Mit Foto', 'files' => [UploadedFile::fake()->image('lauf.jpg', 60, 40)]], ['Accept' => 'application/json'])
|
||||
->assertCreated()->json('post.images.0.thumb_url');
|
||||
$this->assertStringContainsString('/api/v1/gruppen/dateien/', $image);
|
||||
$this->get($image)->assertOk();
|
||||
$this->postJson("/api/v1/gruppen/{$closed->slug}/beitraege", ['body' => 'Nur für uns'])->assertCreated();
|
||||
|
||||
Sanctum::actingAs($bob);
|
||||
$this->getJson('/api/v1/gruppen/entdecken')->assertOk()->assertJsonCount(2, 'data')->assertJsonMissing(['name' => 'Geheimrat']);
|
||||
$this->getJson("/api/v1/gruppen/{$secret->slug}")->assertNotFound();
|
||||
$this->getJson("/api/v1/gruppen/{$closed->slug}")->assertOk()->assertJsonCount(0, 'posts')->assertJsonPath('can.read', false)->assertJsonPath('members', []);
|
||||
$this->postJson("/api/v1/gruppen/{$closed->slug}/beitreten")->assertJsonPath('status', 'pending');
|
||||
|
||||
$post = $this->getJson("/api/v1/gruppen/{$open->slug}")->assertOk()->assertJsonPath('can.post', false)->json('posts.0.id');
|
||||
$this->postJson("/api/v1/gruppen/{$open->slug}/beitreten")->assertJsonPath('status', 'active');
|
||||
$this->postJson("/api/v1/gruppen/beitraege/{$post}/reaktion", ['emoji' => '👍'])->assertOk();
|
||||
$this->postJson("/api/v1/gruppen/beitraege/{$post}/kommentare", ['body' => 'Bin dabei!'])->assertOk()->assertJsonPath('comments.0.body', 'Bin dabei!');
|
||||
$this->getJson("/api/v1/gruppen/beitraege/{$post}")->assertJsonPath('post.my_reaction', '👍')->assertJsonPath('comments.0.user.id', $bob->id);
|
||||
$this->getJson('/api/v1/gruppen')->assertJsonCount(1, 'groups')->assertJsonCount(1, 'posts');
|
||||
|
||||
// Bilder aus fremden, geschlossenen Gruppen bleiben zu
|
||||
Sanctum::actingAs($eve);
|
||||
$this->get($image)->assertOk();
|
||||
$closedPost = Post::query()->where('group_id', $closed->id)->firstOrFail();
|
||||
$this->getJson("/api/v1/gruppen/beitraege/{$closedPost->id}")->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue