-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from thedevdojo/fix-background-uploads
Fix background and logo uploads
- Loading branch information
Showing
7 changed files
with
304 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
use Devdojo\Auth\Livewire\Setup\Background; | ||
use Illuminate\Http\UploadedFile; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
beforeEach(function () { | ||
Storage::fake('public'); | ||
config()->set('devdojo.auth.appearance.background', [ | ||
'color' => '#ffffff', | ||
'image' => '', | ||
'image_overlay_color' => '#000000', | ||
'image_overlay_opacity' => '0.5', | ||
]); | ||
}); | ||
|
||
it('loads initial background settings from config', function () { | ||
Livewire::test(Background::class) | ||
->assertSet('color', '#ffffff') | ||
->assertSet('image', '') | ||
->assertSet('image_overlay_color', '#000000') | ||
->assertSet('image_overlay_opacity', 50); | ||
}); | ||
|
||
it('updates background color and triggers config update', function () { | ||
Livewire::test(Background::class) | ||
->set('color', '#ff0000') | ||
->assertSet('color', '#ff0000'); | ||
|
||
expect(config('devdojo.auth.appearance.background.color'))->toBe('#ff0000'); | ||
}); | ||
|
||
it('handles background image upload and storage', function () { | ||
$file = UploadedFile::fake()->image('background.jpg'); | ||
|
||
Livewire::test(Background::class) | ||
->set('image', $file) | ||
->assertSet('image', '/storage/auth/background.jpg'); | ||
|
||
Storage::disk('public')->assertExists('auth/background.jpg'); | ||
expect(config('devdojo.auth.appearance.background.image'))->toBe('/storage/auth/background.jpg'); | ||
}); | ||
|
||
it('updates image overlay opacity and converts to decimal', function () { | ||
Livewire::test(Background::class) | ||
->set('image_overlay_opacity', 75) | ||
->assertSet('image_overlay_opacity', 75); | ||
|
||
expect(config('devdojo.auth.appearance.background.image_overlay_opacity'))->toBe('0.75'); | ||
}); | ||
|
||
it('updates image overlay color', function () { | ||
Livewire::test(Background::class) | ||
->set('image_overlay_color', '#333333') | ||
->assertSet('image_overlay_color', '#333333'); | ||
|
||
expect(config('devdojo.auth.appearance.background.image_overlay_color'))->toBe('#333333'); | ||
}); | ||
|
||
it('handles different image file types during upload', function () { | ||
$file = UploadedFile::fake()->image('background.png'); | ||
|
||
Livewire::test(Background::class) | ||
->set('image', $file) | ||
->assertSet('image', '/storage/auth/background.png'); | ||
|
||
Storage::disk('public')->assertExists('auth/background.png'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
use Devdojo\Auth\Livewire\Setup\Logo; | ||
use Illuminate\Http\UploadedFile; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
beforeEach(function () { | ||
Storage::fake('public'); | ||
config()->set('devdojo.auth.appearance.logo', [ | ||
'type' => 'text', | ||
'image_src' => '', | ||
'svg_string' => '', | ||
'height' => '40', | ||
]); | ||
}); | ||
|
||
it('loads initial logo settings from config', function () { | ||
Livewire::test(Logo::class) | ||
->assertSet('logo_type', 'text') | ||
->assertSet('logo_image_src', '') | ||
->assertSet('logo_svg_string', '') | ||
->assertSet('logo_height', '40') | ||
->assertSet('logo_image', false); | ||
}); | ||
|
||
it('updates logo type', function () { | ||
Livewire::test(Logo::class) | ||
->set('logo_type', 'image') | ||
->assertSet('logo_type', 'image'); | ||
|
||
expect(config('devdojo.auth.appearance.logo.type'))->toBe('image'); | ||
}); | ||
|
||
it('handles logo image upload and storage', function () { | ||
$file = UploadedFile::fake()->image('logo.png'); | ||
|
||
Livewire::test(Logo::class) | ||
->set('logo_image', $file) | ||
->assertSet('logo_image_src', '/storage/auth/logo.png'); | ||
|
||
Storage::disk('public')->assertExists('auth/logo.png'); | ||
expect(config('devdojo.auth.appearance.logo.image_src'))->toBe('/storage/auth/logo.png'); | ||
}); | ||
|
||
it('updates logo height', function () { | ||
Livewire::test(Logo::class) | ||
->set('logo_height', '60') | ||
->assertSet('logo_height', '60'); | ||
|
||
expect(config('devdojo.auth.appearance.logo.height'))->toBe('60'); | ||
}); | ||
|
||
it('updates svg string', function () { | ||
$svgString = '<svg viewBox="0 0 100 100"><circle cx="50" cy="50" r="40"/></svg>'; | ||
|
||
Livewire::test(Logo::class) | ||
->call('updateSvg', $svgString); | ||
|
||
expect(config('devdojo.auth.appearance.logo.svg_string'))->toBe($svgString); | ||
}); | ||
|
||
it('handles different image file types during upload', function () { | ||
$file = UploadedFile::fake()->image('logo.jpg'); | ||
|
||
Livewire::test(Logo::class) | ||
->set('logo_image', $file) | ||
->assertSet('logo_image_src', '/storage/auth/logo.jpg'); | ||
|
||
Storage::disk('public')->assertExists('auth/logo.jpg'); | ||
}); | ||
|
||
it('sets logo_image to true when logo_image_src exists on mount', function () { | ||
config()->set('devdojo.auth.appearance.logo.image_src', '/storage/auth/existing-logo.png'); | ||
|
||
Livewire::test(Logo::class) | ||
->assertSet('logo_image', true); | ||
}); |