Skip to content

Commit d819dc0

Browse files
committed
that should fix that test
1 parent c555d19 commit d819dc0

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

app/Http/Controllers/ProjectController.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ public function store()
6565
$validated['team_id'] = auth()->user()->current_team_id;
6666
$project = Project::create($validated);
6767

68-
Chat::create([
68+
$chat = Chat::create([
6969
'chatable_id' => $project->id,
7070
'chatable_type' => Project::class,
7171
'chat_driver' => $chat_driver,
7272
'user_id' => auth()->user()->id,
7373
'embedding_driver' => $embedding_driver,
7474
]);
7575

76-
return redirect()->route('projects.show', $project);
76+
return to_route('projects.showWithChat', [
77+
'project' => $project,
78+
'chat' => $chat,
79+
]);
7780
}
7881

7982
public function show(Project $project)
@@ -138,8 +141,6 @@ public function update(Project $project)
138141
'system_prompt' => 'required',
139142
'status' => 'required',
140143
'content' => 'required',
141-
'chat_driver' => 'required',
142-
'embedding_driver' => 'required',
143144
]);
144145

145146
$project->update($validated);

tests/Feature/Http/Controllers/ProjectControllerTest.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Feature\Http\Controllers;
44

55
use App\Domains\Projects\StatusEnum;
6+
use App\Models\Chat;
67
use App\Models\Project;
78
use App\Models\Team;
89
use App\Models\User;
@@ -96,14 +97,20 @@ public function test_show(): void
9697

9798
$campaign = Project::factory()->create();
9899

99-
$this->assertDatabaseCount('chats', 0);
100+
Chat::factory()->create([
101+
'chatable_id' => $campaign->id,
102+
'chatable_type' => Project::class,
103+
'chat_driver' => DriversEnum::Claude->value,
104+
'embedding_driver' => DriversEnum::Claude->value,
105+
]);
100106

101107
$this->actingAs($user)->get(
102108
route('projects.show', $campaign)
103-
)->assertStatus(200)
104-
->assertInertia(fn (Assert $assert) => $assert
105-
->has('project.data')
106-
);
109+
)->assertStatus(302)
110+
->assertRedirect(route('projects.showWithChat', [
111+
'project' => $campaign,
112+
'chat' => $campaign->chats->first(),
113+
]));
107114

108115
$this->assertDatabaseCount('chats', 1);
109116
}

0 commit comments

Comments
 (0)