<?php

namespace Tests\Unit\Services;

use App\Enums\LandingPageVersion;
use App\Models\LandingPage;
use App\Models\LandingPageGeneration;
use App\Services\PublicCatalogLandingPageDocument;
use Tests\TestCase;

class PublicCatalogLandingPageDocumentTest extends TestCase
{
    public function test_it_returns_the_rendered_catalog_document_without_tracking_tags(): void
    {
        $generation = new LandingPageGeneration([
            'website_url' => 'https://rateit.com',
            'google_conversion_send_to' => 'AW-16990837573/i9NRCNzf3PkcEMW27qU_',
            'meta_pixel_id' => '680344444359627',
        ]);

        $page = new LandingPage([
            'version' => LandingPageVersion::Benefits,
            'status' => 'completed',
            'html' => '<section><h1>Catalog page</h1></section>',
        ]);
        $page->setRelation('generation', $generation);

        $document = (new PublicCatalogLandingPageDocument)->render($page);

        $this->assertStringContainsString('<h1>Catalog page</h1>', $document);
        $this->assertStringNotContainsString('googletagmanager.com', $document);
        $this->assertStringNotContainsString('fbevents.js', $document);
    }
}
