<?php

namespace Tests\Browser;

use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class WarehousesUiTest extends DuskTestCase
{
    public function test_warehouse_create_minimal(): void
    {
        $this->browse(function (Browser $browser) {
            $user = \App\Models\User::where('email', 'owner@erp.local')->first();

            if ($user) { $user->forceFill(['email_verified_at'=>now(),'is_active'=>1])->save(); }

            $browser->loginAs($user)
                ->visit('/warehouses/create')
                ->waitFor('form', 10)
                ->type('#code', 'WH'.mt_rand(100,999))
                ->type('#name', 'Dusk Warehouse '.uniqid())
                ->select('#type', 'warehouse')
                ->press('Create Warehouse')
                ->waitForLocation('/warehouses', 10);
        });
    }
}


