<?php

namespace Tests\Browser;

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

class PurchaseOrderFlowTest extends DuskTestCase
{
    public function test_po_create_form_partial_order_behaviour(): 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('/purchase-orders/create')
                ->waitFor('#purchase_request_id', 10);

            // PR select should be present and items table should render after selection via ajax
            $browser->assertPresent('#purchase_request_id');
        });
    }
}


