Files
ladill-events/tests/Feature/QrSettingsTest.php
T
isaaccladandCursor 2c1c3cdd3e
Deploy Ladill Events / deploy (push) Successful in 30s
Enforce Events favicon everywhere and fix deploy pipeline failures.
Add favicon partial to all standalone pages, regenerate the Events icon asset, and stop marking deploys failed when the nginx vhost step cannot sudo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-07 11:56:27 +00:00

89 lines
2.7 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\QrCode;
use App\Models\QrSetting;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Tests\TestCase;
class QrSettingsTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Http::preventStrayRequests();
}
private function user(): User
{
return User::create(['public_id' => (string) Str::uuid(), 'name' => 'A', 'email' => 'a+'.uniqid().'@x.com']);
}
public function test_settings_page_renders_for_authenticated_user(): void
{
$this->actingAs($this->user())
->get(route('account.settings'))
->assertOk()
->assertSee('favicon.ico', false)
->assertSee('New code defaults')
->assertSee('Notifications');
}
public function test_can_save_qr_settings(): void
{
$user = $this->user();
$this->actingAs($user)
->put(route('account.settings.update'), [
'notify_email' => 'alerts@example.com',
'product_updates' => '1',
'low_balance_alerts' => '0',
'default_style' => [
'foreground' => '#112233',
'background' => '#ffffff',
'module_style' => 'dots',
'frame_style' => 'scan_me',
'frame_color' => '#445566',
'frame_text' => 'SCAN ME',
],
])
->assertRedirect(route('account.settings'));
$settings = QrSetting::where('user_id', $user->id)->first();
$this->assertNotNull($settings);
$this->assertSame('alerts@example.com', $settings->notify_email);
$this->assertTrue($settings->product_updates);
$this->assertFalse($settings->low_balance_alerts);
$this->assertSame('#112233', $settings->resolvedDefaultStyle()['foreground']);
$this->assertSame('scan_me', $settings->resolvedDefaultStyle()['frame_style']);
}
public function test_create_page_uses_saved_defaults(): void
{
$user = $this->user();
QrSetting::create([
'user_id' => $user->id,
'default_type' => QrCode::TYPE_EVENT,
'default_style' => ['foreground' => '#aabbcc', 'module_style' => 'dots'],
]);
Http::fake([
config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
]);
$this->actingAs($user)
->get(route('events.create'))
->assertOk()
->assertSee('favicon.ico', false)
->assertSee('#aabbcc', false)
->assertSee('"event"', false);
}
}