Add profile picture removal
linter / quality (pull_request) Successful in 1m36s
tests / ci (8.4) (pull_request) Successful in 1m54s

This commit is contained in:
2026-06-24 15:30:11 +02:00
parent 62e4a8487c
commit 0d26113ba7
4 changed files with 81 additions and 15 deletions
@@ -104,6 +104,37 @@ class ProfileUpdateTest extends TestCase
Storage::disk('public')->assertExists($user->avatar_path);
}
public function test_user_can_delete_their_uploaded_profile_picture()
{
Storage::fake('public');
$user = User::factory()->create([
'name' => 'Upload User',
'avatar_path' => 'avatars/uploads/current.png',
'avatar_color' => '#06B6D4',
'avatar_is_generated' => false,
]);
Storage::disk('public')->put($user->avatar_path, 'uploaded image');
$response = $this
->actingAs($user)
->delete(route('profile.avatar.destroy'));
$response
->assertSessionHasNoErrors()
->assertRedirect(route('profile.edit'));
$user->refresh();
$this->assertTrue($user->avatar_is_generated);
$this->assertSame('#06B6D4', $user->avatar_color);
$this->assertNotSame('avatars/uploads/current.png', $user->avatar_path);
$this->assertStringStartsWith('avatars/generated/', $user->avatar_path);
Storage::disk('public')->assertMissing('avatars/uploads/current.png');
Storage::disk('public')->assertExists($user->avatar_path);
$this->assertStringContainsString('UU', Storage::disk('public')->get($user->avatar_path));
}
public function test_name_change_regenerates_the_default_profile_picture()
{
Storage::fake('public');