<?php

namespace Tests\Feature\Admin;

use App\Models\Payment;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class PaymentResourceTest extends TestCase
{
    use RefreshDatabase;

    public function test_admin_payment_table_displays_amount_in_rupees_not_paise(): void
    {
        $admin = User::factory()->create([
            'role' => 'admin',
        ]);
        $user = User::factory()->create();

        Payment::query()->create([
            'user_id' => $user->id,
            'provider' => 'razorpay',
            'razorpay_order_id' => 'order_test_123',
            'amount_paise' => 49900,
            'currency' => 'INR',
            'status' => Payment::STATUS_CAPTURED,
            'verified_at' => now(),
            'unlocked_at' => now(),
        ]);

        $this
            ->actingAs($admin, 'admin')
            ->get('/admin/payments')
            ->assertOk()
            ->assertSee('Amount (Rupees)')
            ->assertSee('INR 499.00')
            ->assertDontSee('Amount paise')
            ->assertDontSee('49900');
    }
}
