Deploy Ladill Events / deploy (push) Successful in 31s
Meet can persist the agenda locally when linking, even if the service-to-service Meet sync fails. Co-authored-by: Cursor <cursoragent@cursor.com>
164 lines
5.8 KiB
PHP
164 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\QrCode;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
class ServiceMeetLinkTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected User $owner;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
config(['events.service_api_keys.meet' => 'test-meet-key']);
|
|
config(['meet.key' => 'test-meet-key']);
|
|
|
|
Http::fake([
|
|
config('meet.url').'/rooms' => Http::response([
|
|
'room' => ['uuid' => 'room-uuid-123'],
|
|
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
|
], 201),
|
|
config('meet.url').'/rooms/*' => Http::response([
|
|
'room' => ['uuid' => 'room-uuid-123'],
|
|
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
|
], 200),
|
|
]);
|
|
|
|
$this->owner = User::factory()->create(['public_id' => 'usr_meet_link']);
|
|
}
|
|
|
|
public function test_service_api_lists_virtual_events(): void
|
|
{
|
|
QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'evt-virtual-1',
|
|
'type' => QrCode::TYPE_EVENT,
|
|
'label' => 'Virtual summit',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Virtual summit',
|
|
'format' => 'virtual',
|
|
'virtual_sessions' => [],
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
$this->withToken('test-meet-key')
|
|
->getJson('/api/service/v1/events?owner_ref='.$this->owner->public_id)
|
|
->assertOk()
|
|
->assertJsonPath('events.0.title', 'Virtual summit');
|
|
}
|
|
|
|
public function test_service_api_links_existing_meet_room_to_event(): void
|
|
{
|
|
$event = QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'evt-link-1',
|
|
'type' => QrCode::TYPE_EVENT,
|
|
'label' => 'Hybrid day',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Hybrid day',
|
|
'format' => 'hybrid',
|
|
'virtual_sessions' => [],
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
$this->withToken('test-meet-key')
|
|
->postJson('/api/service/v1/events/'.$event->id.'/link-room', [
|
|
'owner_ref' => $this->owner->public_id,
|
|
'meet_room_uuid' => 'room-uuid-123',
|
|
'meet_room_type' => 'webinar',
|
|
'join_url' => 'https://meet.ladill.com/r/room-uuid-123',
|
|
'title' => 'Keynote stream',
|
|
])
|
|
->assertOk()
|
|
->assertJsonPath('event.meet_room_uuid', 'room-uuid-123');
|
|
|
|
$sessions = $event->fresh()->content()['virtual_sessions'];
|
|
$this->assertSame('room-uuid-123', $sessions[0]['meet_room_uuid'] ?? null);
|
|
}
|
|
|
|
public function test_link_room_patches_existing_meet_room_with_programme_snapshot(): void
|
|
{
|
|
$programme = QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'prog-link-1',
|
|
'type' => QrCode::TYPE_ITINERARY,
|
|
'label' => 'Summit programme',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Summit programme',
|
|
'days' => [
|
|
[
|
|
'label' => 'Day 1',
|
|
'items' => [
|
|
['ref' => 'item-1', 'time' => '09:00', 'title' => 'Opening keynote', 'host' => 'Alex'],
|
|
],
|
|
],
|
|
],
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
$event = QrCode::create([
|
|
'user_id' => $this->owner->id,
|
|
'short_code' => 'evt-prog-link',
|
|
'type' => QrCode::TYPE_EVENT,
|
|
'label' => 'Summit',
|
|
'payload' => [
|
|
'content' => [
|
|
'title' => 'Summit',
|
|
'format' => 'virtual',
|
|
'programme_qr_id' => $programme->id,
|
|
'virtual_sessions' => [],
|
|
],
|
|
'style' => [],
|
|
],
|
|
'is_active' => true,
|
|
]);
|
|
|
|
Http::fake([
|
|
config('meet.url').'/rooms/existing-room-uuid' => Http::response([
|
|
'room' => ['uuid' => 'existing-room-uuid'],
|
|
'join_url' => 'https://meet.ladill.com/r/existing-room-uuid',
|
|
], 200),
|
|
]);
|
|
|
|
$this->withToken('test-meet-key')
|
|
->postJson('/api/service/v1/events/'.$event->id.'/link-room', [
|
|
'owner_ref' => $this->owner->public_id,
|
|
'meet_room_uuid' => 'existing-room-uuid',
|
|
'meet_room_type' => 'town_hall',
|
|
'join_url' => 'https://meet.ladill.com/r/existing-room-uuid',
|
|
'title' => 'Opening keynote',
|
|
])
|
|
->assertOk()
|
|
->assertJsonPath('event.meet_room_uuid', 'existing-room-uuid')
|
|
->assertJsonPath('event.programme_snapshot.title', 'Summit programme')
|
|
->assertJsonPath('event.programme_snapshot.days.0.items.0.title', 'Opening keynote');
|
|
|
|
Http::assertSent(function ($request) {
|
|
return $request->method() === 'PATCH'
|
|
&& str_ends_with($request->url(), '/rooms/existing-room-uuid')
|
|
&& ($request['settings']['programme_snapshot']['title'] ?? '') === 'Summit programme'
|
|
&& ($request['settings']['programme_snapshot']['days'][0]['items'][0]['title'] ?? '') === 'Opening keynote';
|
|
});
|
|
}
|
|
}
|