<?php

namespace Tests\Browser;

use App\Models\User;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class SpeedButtonTest extends DuskTestCase
{
    /**
     * Verify that the speedbuttons for the developer role are correctly displayed.
     * Note: This test requires a properly configured environment (SESSION_DRIVER=file or database,
     * and shared database/session between the test runner and web server).
     */
    public function test_developer_sees_correct_speedbuttons(): void
    {
        $this->browse(function (Browser $browser) {
            $user = User::find(2); // developer user

            $browser->loginAs($user)
                ->visit('/')
                ->waitFor('#appContent', 30)
                // Expected buttons based on 'developer' role permissions
                ->assertVisible('.iconholderModulhome')
                ->assertVisible('.iconholderModulactiveOrder')
                ->assertVisible('.iconholderModulproductGroup')
                ->assertVisible('.iconholderModulproduct')
                ->assertVisible('.iconholderModulsupplier')
                ->assertVisible('.iconholderModulpriceList')
                ->assertVisible('.iconholderModulpriceListUser')
                ->assertVisible('.iconholderModulprofitCenter')
                ->assertVisible('.iconholderModulfileBatchUpload')
                ->assertVisible('.iconholderModulstatistics')
                ->assertVisible('.iconholderModulexport')
                ->assertVisible('.iconholderModulpriceListProcessor')
                // Buttons that should NOT be visible for 'developer' role
                ->assertMissing('.iconholderModulorder');
        });
    }
}
