<?php

namespace Tests\Feature\Marketing;

use App\Models\Event;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Inertia\Testing\AssertableInertia as Assert;
use Tests\TestCase;

class DemoPageTest extends TestCase
{
    use RefreshDatabase;

    public function test_demo_page_uses_marketing_demo_event(): void
    {
        $event = Event::factory()->create([
            'settings' => ['marketing_demo' => true],
        ]);

        $joinToken = $event->joinTokens()->latest('id')->first();

        $this->assertNotNull($joinToken);

        $response = $this->get('/de/demo');

        $response->assertOk();
        $response->assertInertia(fn (Assert $page) => $page
            ->component('marketing/Demo')
            ->where('demoToken', $joinToken->token)
        );
    }

    public function test_demo_page_renders_without_marketing_demo_event(): void
    {
        $response = $this->get('/de/demo');

        $response->assertOk();
        $response->assertInertia(fn (Assert $page) => $page
            ->component('marketing/Demo')
            ->where('demoToken', null)
        );
    }
}
