Add join token TTL policy and Live Show link sharing
This commit is contained in:
31
tests/Feature/Tenant/EventJoinTokenTtlPolicyTest.php
Normal file
31
tests/Feature/Tenant/EventJoinTokenTtlPolicyTest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Models\Event;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class EventJoinTokenTtlPolicyTest extends TenantTestCase
|
||||
{
|
||||
public function test_join_token_defaults_to_policy_ttl_when_expiry_missing(): void
|
||||
{
|
||||
Carbon::setTestNow(Carbon::parse('2026-01-05 12:00:00'));
|
||||
|
||||
$event = Event::factory()
|
||||
->for($this->tenant)
|
||||
->create([
|
||||
'name' => ['de' => 'Token TTL Test', 'en' => 'Token TTL Test'],
|
||||
'slug' => 'token-ttl-test',
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/join-tokens");
|
||||
|
||||
$response->assertCreated();
|
||||
|
||||
$expectedExpiry = now()->addDays(7)->toIso8601String();
|
||||
|
||||
$this->assertSame($expectedExpiry, $response->json('data.expires_at'));
|
||||
|
||||
Carbon::setTestNow();
|
||||
}
|
||||
}
|
||||
60
tests/Feature/Tenant/LiveShowLinkControllerTest.php
Normal file
60
tests/Feature/Tenant/LiveShowLinkControllerTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Tenant;
|
||||
|
||||
use App\Models\Event;
|
||||
|
||||
class LiveShowLinkControllerTest extends TenantTestCase
|
||||
{
|
||||
public function test_live_show_link_response_includes_qr_code_and_url(): void
|
||||
{
|
||||
$event = Event::factory()
|
||||
->for($this->tenant)
|
||||
->create([
|
||||
'name' => ['de' => 'Live-Show Test', 'en' => 'Live Show Test'],
|
||||
'slug' => 'live-show-link-test',
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('GET', "/api/v1/tenant/events/{$event->slug}/live-show/link");
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$data = $response->json('data');
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->assertArrayHasKey('token', $data);
|
||||
$this->assertArrayHasKey('url', $data);
|
||||
$this->assertArrayHasKey('qr_code_data_url', $data);
|
||||
$this->assertArrayHasKey('rotated_at', $data);
|
||||
|
||||
$this->assertIsString($data['token']);
|
||||
$this->assertIsString($data['url']);
|
||||
$this->assertIsString($data['qr_code_data_url']);
|
||||
$this->assertStringStartsWith('data:image/png;base64,', $data['qr_code_data_url']);
|
||||
$this->assertNotNull($data['rotated_at']);
|
||||
|
||||
$expectedBase = rtrim((string) config('app.url'), '/');
|
||||
$this->assertSame("{$expectedBase}/show/{$data['token']}", $data['url']);
|
||||
}
|
||||
|
||||
public function test_rotate_live_show_link_changes_token(): void
|
||||
{
|
||||
$event = Event::factory()
|
||||
->for($this->tenant)
|
||||
->create([
|
||||
'name' => ['de' => 'Live-Show Rotation', 'en' => 'Live Show Rotation'],
|
||||
'slug' => 'live-show-rotate-test',
|
||||
]);
|
||||
|
||||
$first = $this->authenticatedRequest('GET', "/api/v1/tenant/events/{$event->slug}/live-show/link");
|
||||
$first->assertOk();
|
||||
$firstToken = $first->json('data.token');
|
||||
|
||||
$rotated = $this->authenticatedRequest('POST', "/api/v1/tenant/events/{$event->slug}/live-show/link/rotate");
|
||||
$rotated->assertOk();
|
||||
|
||||
$rotatedToken = $rotated->json('data.token');
|
||||
$this->assertIsString($rotatedToken);
|
||||
$this->assertNotSame($firstToken, $rotatedToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user