diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index f6a433fc..89bf4b9e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -65,7 +65,7 @@ public function store() $validated['team_id'] = auth()->user()->current_team_id; $project = Project::create($validated); - Chat::create([ + $chat = Chat::create([ 'chatable_id' => $project->id, 'chatable_type' => Project::class, 'chat_driver' => $chat_driver, @@ -73,7 +73,10 @@ public function store() 'embedding_driver' => $embedding_driver, ]); - return redirect()->route('projects.show', $project); + return to_route('projects.showWithChat', [ + 'project' => $project, + 'chat' => $chat, + ]); } public function show(Project $project) @@ -138,8 +141,6 @@ public function update(Project $project) 'system_prompt' => 'required', 'status' => 'required', 'content' => 'required', - 'chat_driver' => 'required', - 'embedding_driver' => 'required', ]); $project->update($validated); diff --git a/tests/Feature/Http/Controllers/ProjectControllerTest.php b/tests/Feature/Http/Controllers/ProjectControllerTest.php index e5878e43..84bf3c1e 100644 --- a/tests/Feature/Http/Controllers/ProjectControllerTest.php +++ b/tests/Feature/Http/Controllers/ProjectControllerTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Http\Controllers; use App\Domains\Projects\StatusEnum; +use App\Models\Chat; use App\Models\Project; use App\Models\Team; use App\Models\User; @@ -96,14 +97,20 @@ public function test_show(): void $campaign = Project::factory()->create(); - $this->assertDatabaseCount('chats', 0); + Chat::factory()->create([ + 'chatable_id' => $campaign->id, + 'chatable_type' => Project::class, + 'chat_driver' => DriversEnum::Claude->value, + 'embedding_driver' => DriversEnum::Claude->value, + ]); $this->actingAs($user)->get( route('projects.show', $campaign) - )->assertStatus(200) - ->assertInertia(fn (Assert $assert) => $assert - ->has('project.data') - ); + )->assertStatus(302) + ->assertRedirect(route('projects.showWithChat', [ + 'project' => $campaign, + 'chat' => $campaign->chats->first(), + ])); $this->assertDatabaseCount('chats', 1); }