<?php

namespace Tests\Unit\DTOs;

use App\DTOs\PromptLandingPageBrief;
use Tests\TestCase;

class PromptLandingPageBriefTest extends TestCase
{
    public function test_round_trips_logo_fields(): void
    {
        $payload = [
            'brand_name' => 'Austin Yoga',
            'offering' => 'Studio membership',
            'features' => ['Small classes'],
            'benefits' => ['Less stress'],
            'pricing' => '$99 / month',
            'audience' => 'Busy professionals',
            'usps' => ['Downtown location'],
            'pain_points' => ['Crowded gyms'],
            'tone' => 'Calm and warm',
            'cta' => 'Book a class',
            'headline' => 'Find your calm in Austin',
            'notes' => 'Earth tones',
            'purpose' => '',
            'primary_color' => '#0f766e',
            'secondary_color' => '#14b8a6',
            'accent_color' => '#0d9488',
            'background_color' => '#f7fffc',
            'text_color' => '#0f172a',
            'logo_present' => true,
            'logo_type' => 'combination-mark',
            'logo_wordmark_text' => 'Austin Yoga',
            'logo_description' => 'A teal lotus icon beside the wordmark Austin Yoga.',
            'logo_exact_svg' => '',
            'logo_url' => 'https://brand.example.com/logo.png',
            'favicon_url' => 'https://brand.example.com/favicon.ico',
            'font_family' => 'Inter',
            'font_stylesheet_url' => 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap',
        ];

        $brief = PromptLandingPageBrief::fromArray($payload);

        $this->assertTrue($brief->logoPresent);
        $this->assertSame('combination-mark', $brief->logoType);
        $this->assertSame('Austin Yoga', $brief->logoWordmarkText);
        $this->assertSame('A teal lotus icon beside the wordmark Austin Yoga.', $brief->logoDescription);
        $this->assertSame('https://brand.example.com/logo.png', $brief->logoUrl);
        $this->assertSame('https://brand.example.com/favicon.ico', $brief->faviconUrl);
        $this->assertSame('Inter', $brief->fontFamily);
        $this->assertSame(
            'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap',
            $brief->fontStylesheetUrl,
        );
        $this->assertSame($payload, $brief->toArray());
    }

    public function test_defaults_missing_logo_fields_so_older_briefs_still_load(): void
    {
        $brief = PromptLandingPageBrief::fromArray([
            'brand_name' => 'Austin Yoga',
            'offering' => 'Studio membership',
        ]);

        $this->assertFalse($brief->logoPresent);
        $this->assertSame('unknown', $brief->logoType);
        $this->assertSame('', $brief->logoWordmarkText);
        $this->assertSame('', $brief->logoDescription);
        $this->assertSame('', $brief->logoExactSvg);
        $this->assertSame('', $brief->logoUrl);
        $this->assertSame('', $brief->faviconUrl);
        $this->assertSame('', $brief->fontFamily);
        $this->assertSame('', $brief->fontStylesheetUrl);
        $this->assertSame('', $brief->purpose);
    }

    public function test_falls_back_to_unknown_for_an_invalid_logo_type(): void
    {
        $brief = PromptLandingPageBrief::fromArray([
            'logo_type' => 'mascot',
        ]);

        $this->assertSame('unknown', $brief->logoType);
    }
}
