<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminDashboardKpiCardsShouldLinkToListsWithBackTest extends TestCase
{
    use RefreshDatabase;

    protected function loginAsPlatformAdmin(): void
    {
        $this->seed();

        $this->post('/admin/login', [
            'email' => 'platform.admin@demo.local',
            'password' => 'Platform@123456',
        ])->assertRedirect('/admin');
    }

    public function test_dashboard_kpi_cards_should_link_to_lists_with_back(): void
    {
        $this->loginAsPlatformAdmin();

        $res = $this->get('/admin');
        $res->assertOk();

        $res->assertSee('href="/admin/merchants?back=%2Fadmin"', false);
        $res->assertSee('href="/admin/plans?back=%2Fadmin"', false);
        $res->assertSee('href="/admin/site-subscriptions?back=%2Fadmin"', false);
        $res->assertSee('href="/admin/platform-orders?back=%2Fadmin"', false);

        $res->assertDontSee('&amp;back=', false);
    }
}
