<?php

namespace Tests\Feature\Api\Event;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class PublicEventErrorResponseTest extends TestCase
{
    use RefreshDatabase;

    public function test_invalid_join_token_returns_structured_error(): void
    {
        $response = $this->getJson('/api/v1/events/not-a-token/stats');

        $response->assertStatus(404);
        $response->assertJsonStructure([
            'error' => ['code', 'title', 'message', 'meta'],
        ]);

        $response->assertJsonPath('error.code', 'invalid_token');

        $this->assertSame('not-a-token', $response->json('error.meta.token'));
    }
}
