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\Policies;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use App\Policies\ProjectPolicy;
|
||||
use Database\Seeders\ProjectStatusSeeder;
|
||||
use Database\Seeders\ProjectTypeSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use App\Models\Project;
|
||||
|
||||
class ProjectPolicyTest extends TestCase
|
||||
{
|
||||
@@ -14,16 +17,43 @@ class ProjectPolicyTest extends TestCase
|
||||
// 3.1.23 Unit test: ProjectPolicy ownership checks
|
||||
public function test_project_policy_authorization()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.23: Implement ProjectPolicy authorization tests');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$policy = new ProjectPolicy;
|
||||
$roles = ['developer', 'manager', 'superuser'];
|
||||
|
||||
foreach ($roles as $role) {
|
||||
$user = User::factory()->create(['role' => $role]);
|
||||
$project = Project::factory()->create();
|
||||
|
||||
$this->assertTrue($policy->viewAny($user));
|
||||
$this->assertTrue($policy->view($user, $project));
|
||||
}
|
||||
}
|
||||
|
||||
public function test_superuser_can_manage_all_projects()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.23: Test superuser full access');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$policy = new ProjectPolicy;
|
||||
$user = User::factory()->create(['role' => 'superuser']);
|
||||
$project = Project::factory()->create();
|
||||
|
||||
$this->assertTrue($policy->create($user));
|
||||
$this->assertTrue($policy->update($user, $project));
|
||||
$this->assertTrue($policy->delete($user, $project));
|
||||
}
|
||||
|
||||
public function test_manager_can_edit_own_projects()
|
||||
{
|
||||
$this->markTestIncomplete('3.1.23: Test manager project ownership');
|
||||
$this->seed([ProjectStatusSeeder::class, ProjectTypeSeeder::class]);
|
||||
|
||||
$policy = new ProjectPolicy;
|
||||
$user = User::factory()->create(['role' => 'manager']);
|
||||
$project = Project::factory()->create();
|
||||
|
||||
$this->assertTrue($policy->create($user));
|
||||
$this->assertTrue($policy->update($user, $project));
|
||||
$this->assertTrue($policy->delete($user, $project));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user