<?php

declare(strict_types=1);

use App\Models\Category;
use App\Models\ContentType;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

it('renders content-type landing pages with collection, image gallery, breadcrumb, and item list structured data', function (): void {
    $pages = [
        [
            'name' => 'Wallpapers',
            'slug' => 'wallpapers',
            'description' => 'Discover desktop and mobile wallpapers from the Skinbase creative community.',
        ],
        [
            'name' => 'Skins',
            'slug' => 'skins',
            'description' => 'Browse classic and modern skins from the Skinbase creative community.',
        ],
        [
            'name' => 'Digital Art',
            'slug' => 'digital-art',
            'description' => 'Explore digital art from the Skinbase creative community.',
        ],
        [
            'name' => 'Other',
            'slug' => 'other',
            'description' => 'Discover other creative works shared on Skinbase.',
        ],
    ];

    foreach ($pages as $page) {
        ContentType::query()->create($page);

        $html = $this->get('/' . $page['slug'])
            ->assertOk()
            ->getContent();

        expect($html)
            ->toContain('application/ld+json')
            ->toContain('CollectionPage')
            ->toContain('ImageGallery')
            ->toContain('BreadcrumbList')
            ->toContain('ItemList')
            ->toContain($page['name'])
            ->toContain('/explore');
    }
});

it('renders category discovery pages with collection, image gallery, breadcrumb, and item list structured data', function (): void {
    $contentType = ContentType::query()->create([
        'name' => 'Wallpapers',
        'slug' => 'wallpapers',
        'description' => 'Discover desktop and mobile wallpapers from the Skinbase creative community.',
    ]);

    $category = Category::query()->create([
        'content_type_id' => $contentType->id,
        'parent_id' => null,
        'name' => 'Fantasy',
        'slug' => 'fantasy',
        'description' => 'Fantasy wallpapers and scenes.',
        'is_active' => true,
        'sort_order' => 1,
    ]);

    $html = $this->get('/wallpapers/' . $category->slug)
        ->assertOk()
        ->getContent();

    expect($html)
        ->toContain('application/ld+json')
        ->toContain('CollectionPage')
        ->toContain('ImageGallery')
        ->toContain('BreadcrumbList')
        ->toContain('ItemList')
        ->toContain('Fantasy')
        ->toContain('/explore')
        ->toContain('/wallpapers');
});