Skip to content

Commit

Permalink
that should fix that test
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Sep 10, 2024
1 parent c555d19 commit d819dc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 5 additions & 4 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ 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,
'user_id' => auth()->user()->id,
'embedding_driver' => $embedding_driver,
]);

return redirect()->route('projects.show', $project);
return to_route('projects.showWithChat', [
'project' => $project,
'chat' => $chat,
]);
}

public function show(Project $project)
Expand Down Expand Up @@ -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);
Expand Down
17 changes: 12 additions & 5 deletions tests/Feature/Http/Controllers/ProjectControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit d819dc0

Please sign in to comment.