test(project): Add Phase 1 pending tests for Project Lifecycle

Capability 3: Project Lifecycle Management - Phase 1 (RED)

E2E Tests (12 test.fixme):
- Create project with unique code
- Reject duplicate project code
- Valid/invalid status transitions
- Estimate approved requires estimate > 0
- Workflow progression
- Estimate rework path
- Project on hold
- Cancelled project
- Set approved estimate
- Update forecasted effort
- Validate forecasted effort

API Tests (9 markTestIncomplete):
- POST /api/projects
- Project code uniqueness
- Status transition validation
- Estimate/forecast endpoints

Unit Tests (3 markTestIncomplete):
- Project status state machine
- ProjectPolicy authorization
- Forecasted effort validation

All 173 tests passing (31 backend, 32 frontend, 110 E2E)
This commit is contained in:
2026-02-18 23:50:48 -05:00
parent 32b524bff0
commit 8f70e81d29
6 changed files with 384 additions and 28 deletions

View File

@@ -0,0 +1,91 @@
<?php
namespace Tests\Feature\Project;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Models\User;
use App\Models\Project;
use App\Models\ProjectStatus;
use App\Models\ProjectType;
class ProjectTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
}
protected function loginAsManager()
{
$user = User::factory()->create([
'email' => 'manager@example.com',
'password' => bcrypt('password123'),
'role' => 'manager',
'active' => true,
]);
$response = $this->postJson('/api/auth/login', [
'email' => 'manager@example.com',
'password' => 'password123',
]);
return $response->json('access_token');
}
// 3.1.13 API test: POST /api/projects creates project
public function test_post_projects_creates_project()
{
$this->markTestIncomplete('3.1.13: Implement POST /api/projects endpoint');
}
// 3.1.14 API test: Project code must be unique
public function test_project_code_must_be_unique()
{
$this->markTestIncomplete('3.1.14: Implement project code uniqueness validation');
}
// 3.1.15 API test: Status transition validation
public function test_status_transition_validation()
{
$this->markTestIncomplete('3.1.15: Implement status state machine validation');
}
// 3.1.16 API test: Estimate approved requires estimate value
public function test_estimate_approved_requires_estimate_value()
{
$this->markTestIncomplete('3.1.16: Implement estimate approved validation');
}
// 3.1.17 API test: Full workflow state machine
public function test_full_workflow_state_machine()
{
$this->markTestIncomplete('3.1.17: Implement full workflow progression');
}
// 3.1.18 API test: PUT /api/projects/{id}/status transitions
public function test_put_projects_status_transitions()
{
$this->markTestIncomplete('3.1.18: Implement PUT /api/projects/{id}/status endpoint');
}
// 3.1.19 API test: PUT /api/projects/{id}/estimate sets approved
public function test_put_projects_estimate_sets_approved()
{
$this->markTestIncomplete('3.1.19: Implement PUT /api/projects/{id}/estimate endpoint');
}
// 3.1.20 API test: PUT /api/projects/{id}/forecast updates effort
public function test_put_projects_forecast_updates_effort()
{
$this->markTestIncomplete('3.1.20: Implement PUT /api/projects/{id}/forecast endpoint');
}
// 3.1.21 API test: Validate forecasted sum equals approved
public function test_validate_forecasted_sum_equals_approved()
{
$this->markTestIncomplete('3.1.21: Implement forecasted effort validation');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\Unit\Models;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Models\Project;
use App\Models\ProjectStatus;
class ProjectForecastTest extends TestCase
{
use RefreshDatabase;
// 3.1.24 Unit test: Forecasted effort validation
public function test_forecasted_effort_validation()
{
$this->markTestIncomplete('3.1.24: Implement forecasted effort validation tests');
}
public function test_forecasted_sum_must_equal_approved_estimate()
{
$this->markTestIncomplete('3.1.24: Test forecasted sum equals approved');
}
public function test_forecasted_effort_tolerance()
{
$this->markTestIncomplete('3.1.24: Test 5% tolerance for forecasted effort');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Tests\Unit\Models;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Models\Project;
use App\Models\ProjectStatus;
use App\Models\ProjectType;
class ProjectModelTest extends TestCase
{
use RefreshDatabase;
// 3.1.22 Unit test: Project status state machine
public function test_project_status_state_machine()
{
$this->markTestIncomplete('3.1.22: Implement project status state machine tests');
}
public function test_project_can_transition_to_valid_status()
{
$this->markTestIncomplete('3.1.22: Test valid status transitions');
}
public function test_project_cannot_transition_to_invalid_status()
{
$this->markTestIncomplete('3.1.22: Test invalid status transitions are rejected');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\Unit\Policies;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Models\User;
use App\Models\Project;
class ProjectPolicyTest extends TestCase
{
use RefreshDatabase;
// 3.1.23 Unit test: ProjectPolicy ownership checks
public function test_project_policy_authorization()
{
$this->markTestIncomplete('3.1.23: Implement ProjectPolicy authorization tests');
}
public function test_superuser_can_manage_all_projects()
{
$this->markTestIncomplete('3.1.23: Test superuser full access');
}
public function test_manager_can_edit_own_projects()
{
$this->markTestIncomplete('3.1.23: Test manager project ownership');
}
}