<?php

declare(strict_types=1);

use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\User;

uses(RefreshDatabase::class);

it('renders seo tags on public blade pages', function (): void {
    $response = $this->get('/');

    $response->assertOk();

    $html = $response->getContent();
    $this->assertNotFalse($html);
    $this->assertStringContainsString('<title>', $html);
    $this->assertStringContainsString('meta name="description"', $html);
    $this->assertStringContainsString('meta property="og:title"', $html);
    $this->assertStringContainsString('meta name="twitter:card"', $html);
});

it('renders seo tags on auth blade pages', function (): void {
    $response = $this->get('/login');

    $response->assertOk();

    $html = $response->getContent();
    $this->assertNotFalse($html);
    $this->assertStringContainsString('<title>', $html);
    $this->assertStringContainsString('meta name="description"', $html);
    $this->assertStringContainsString('meta property="og:title"', $html);
    $this->assertStringContainsString('meta name="robots" content="noindex,nofollow"', $html);
});

it('renders seo tags on upload and studio pages', function (): void {
    $user = User::factory()->create();

    $uploadResponse = $this->actingAs($user)->get('/upload');
    $uploadResponse->assertOk();

    $uploadHtml = $uploadResponse->getContent();
    $this->assertNotFalse($uploadHtml);
    $this->assertStringContainsString('<title>Upload Artwork — Creator Studio</title>', $uploadHtml);
    $this->assertStringContainsString('meta name="description"', $uploadHtml);
    $this->assertStringContainsString('meta property="og:title"', $uploadHtml);
    $this->assertStringContainsString('meta name="robots" content="noindex, nofollow"', $uploadHtml);

    $studioResponse = $this->actingAs($user)->get('/studio/artworks');
    $studioResponse->assertOk();

    $studioHtml = $studioResponse->getContent();
    $this->assertNotFalse($studioHtml);
    $this->assertStringContainsString('Creator Studio', $studioHtml);
    $this->assertStringContainsString('meta name="description"', $studioHtml);
    $this->assertStringContainsString('meta property="og:title"', $studioHtml);
    $this->assertStringContainsString('meta name="robots" content="noindex, nofollow"', $studioHtml);
});
