'Super Admin']); Permission::firstOrCreate(['name' => 'projects.access']); $this->user = User::factory()->create([ 'status' => 'active', 'user_type' => 'admin', ]); $this->user->assignRole($role); // Standard Material $this->material = Material::create([ 'name' => 'Test Cement Bag', 'sku' => 'CEM-TST-101', 'unit' => 'bag', 'unit_cost' => 300.00, 'category' => 'cement', 'type' => 'raw', 'status' => 'active', ]); // Create Project (step = 8, status = in_progress) $this->project = Project::create([ 'name' => 'Approved Active Project', 'code' => 'PRJ-ACT-2026', 'status' => ProjectStatus::InProgress, 'project_type' => 'standard', 'is_unprofitable' => false, 'contract_value' => 500000.00, 'current_wizard_step' => 8, ]); // Create estimation for project $this->project->materialsEstimates()->create([ 'material_id' => $this->material->id, 'estimated_qty' => 100, 'unit_cost' => 300.00, ]); } public function test_can_load_requisition_create_form_with_prefilled_items(): void { $response = $this->actingAs($this->user)->get(route('requisitions.create', [ 'project_ulid' => $this->project->ulid ])); $response->assertStatus(200); // Assert prefilledItems exists and contains the estimated materials $prefilled = $response->viewData('page')['props']['prefilledItems']; $this->assertCount(1, $prefilled); $this->assertEquals($this->material->ulid, $prefilled[0]['material_ulid']); $this->assertEquals(100, $prefilled[0]['quantity']); } }