<?php

declare(strict_types=1);

use App\Models\NovaCard;
use App\Models\NovaCardAsset;
use App\Models\NovaCardAssetPack;
use App\Models\NovaCardChallenge;
use App\Models\NovaCardChallengeEntry;
use App\Models\NovaCardCollection;
use App\Models\User;
use Database\Seeders\DatabaseSeeder;

it('seeds official demo cards when the hook is enabled', function (): void {
    config()->set('nova_cards.seed_demo_cards.enabled', true);
    config()->set('nova_cards.seed_demo_cards.user.username', 'nova.cards');
    config()->set('nova_cards.seed_demo_cards.user.email', 'nova-cards-demo@skinbase.test');

    $this->seed(DatabaseSeeder::class);

    $demoUser = User::query()->where('email', 'nova-cards-demo@skinbase.test')->first();

    expect($demoUser)->not->toBeNull();
    expect(NovaCard::query()->where('user_id', $demoUser->id)->count())->toBe(6);
    expect(NovaCard::query()->where('user_id', $demoUser->id)->where('featured', true)->exists())->toBeTrue();
    expect(NovaCard::query()->where('user_id', $demoUser->id)->where('status', NovaCard::STATUS_PUBLISHED)->count())->toBe(6);
    expect(NovaCardCollection::query()->where('user_id', $demoUser->id)->where('official', true)->count())->toBeGreaterThanOrEqual(2);
    expect(NovaCardChallenge::query()->where('user_id', $demoUser->id)->where('official', true)->count())->toBeGreaterThanOrEqual(2);
    expect(NovaCardChallengeEntry::query()->count())->toBeGreaterThanOrEqual(6);
    expect(NovaCardAssetPack::query()->where('official', true)->count())->toBeGreaterThanOrEqual(4);
    expect(NovaCardAsset::query()->where('official', true)->count())->toBeGreaterThan(0);
});
