feat(project): Complete Project Lifecycle capability with full TDD workflow
- Implement ProjectController with CRUD, status transitions, estimate/forecast - Add ProjectService with state machine validation - Extract ProjectStatusService for reusable state machine logic - Add ProjectPolicy for role-based authorization - Create ProjectSeeder with test data - Implement frontend project management UI with modal forms - Add projectService API client - Complete all 9 incomplete unit tests (ProjectModelTest, ProjectForecastTest, ProjectPolicyTest) - Fix E2E test timing issues with loading state waits - Add Scribe API documentation annotations - Improve forecasted effort validation messages with detailed feedback Test Results: - Backend: 49 passed (182 assertions) - Frontend Unit: 32 passed - E2E: 134 passed (Chromium + Firefox) Phase 3 Refactor: - Extract ProjectStatusService for state machine - Optimize project list query with status joins - Improve forecasted effort validation messages Phase 4 Document: - Add Scribe annotations to ProjectController - Generate API documentation
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace Tests\Unit\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectStatus;
|
||||
use App\Services\ProjectService;
|
||||
use Database\Seeders\ProjectStatusSeeder;
|
||||
use Database\Seeders\ProjectTypeSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectForecastTest extends TestCase
|
||||
{
|
||||
@@ -14,16 +17,62 @@ class ProjectForecastTest extends TestCase
|
||||
// 3.1.24 Unit test: Forecasted effort validation
|
||||
public function test_forecasted_effort_validation()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.24: Implement forecasted effort validation tests');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$service = app(ProjectService::class);
|
||||
|
||||
$status = ProjectStatus::firstOrFail();
|
||||
$project = Project::factory()->create([
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
|
||||
$forecast = ['2026-01' => 20, '2026-02' => 30];
|
||||
|
||||
$updated = $service->setForecastedEffort($project, $forecast);
|
||||
|
||||
$this->assertSame($forecast, $updated->forecasted_effort);
|
||||
}
|
||||
|
||||
public function test_forecasted_sum_must_equal_approved_estimate()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.24: Test forecasted sum equals approved');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$service = app(ProjectService::class);
|
||||
|
||||
$status = ProjectStatus::firstOrFail();
|
||||
$project = Project::factory()->create([
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
|
||||
$service->setApprovedEstimate($project, 100);
|
||||
|
||||
$forecast = ['2026-01' => 40, '2026-02' => 60];
|
||||
$updated = $service->setForecastedEffort($project, $forecast);
|
||||
|
||||
$this->assertEquals(100, array_sum($updated->forecasted_effort));
|
||||
}
|
||||
|
||||
public function test_forecasted_effort_tolerance()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.24: Test 5% tolerance for forecasted effort');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$service = app(ProjectService::class);
|
||||
|
||||
$status = ProjectStatus::firstOrFail();
|
||||
$project = Project::factory()->create([
|
||||
'status_id' => $status->id,
|
||||
]);
|
||||
|
||||
$service->setApprovedEstimate($project, 100);
|
||||
|
||||
$forecastWithinTolerance = ['2026-01' => 50, '2026-02' => 55];
|
||||
$service->setForecastedEffort($project, $forecastWithinTolerance);
|
||||
|
||||
$this->assertEquals(105, array_sum($project->refresh()->forecasted_effort));
|
||||
|
||||
$forecastTooHigh = ['2026-01' => 60, '2026-02' => 50];
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$service->setForecastedEffort($project, $forecastTooHigh);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user