From 2a34adc515ba29dd25f4ecb6809d5a94c8cf2e33 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Thu, 18 Jun 2026 08:27:44 +0000 Subject: [PATCH] QuickStatus: Hinweistext beim Wechsel auf Auto beibehalten. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gespeicherte Headline und Subtext bleiben erhalten und stehen beim erneuten Umschalten auf Hinweis wieder zur Verfügung. Co-authored-by: Cursor --- app/Livewire/Cabinet/QuickStatus.php | 7 ------- tests/Feature/CabinetQuickStatusTest.php | 23 ++++++++++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/Livewire/Cabinet/QuickStatus.php b/app/Livewire/Cabinet/QuickStatus.php index d9968785..13340bce 100644 --- a/app/Livewire/Cabinet/QuickStatus.php +++ b/app/Livewire/Cabinet/QuickStatus.php @@ -92,13 +92,6 @@ class QuickStatus extends Component 'noticeSubtext.max' => 'Subtext max. 80 Zeichen.', ]); - $showsNotice = in_array($this->storeStatus, ['notice', 'warning'], true); - - if (! $showsNotice) { - $this->noticeHeadline = ''; - $this->noticeSubtext = ''; - } - CabinetTabletSetting::current()->update([ 'store_status' => $this->storeStatus, 'notice_headline' => $this->noticeHeadline ?: null, diff --git a/tests/Feature/CabinetQuickStatusTest.php b/tests/Feature/CabinetQuickStatusTest.php index 63c73819..b2c43ccc 100644 --- a/tests/Feature/CabinetQuickStatusTest.php +++ b/tests/Feature/CabinetQuickStatusTest.php @@ -73,10 +73,11 @@ test('save persists status and headline to database', function () { expect($settings->notice_subtext)->toBe('Heute nur bis 14 Uhr'); }); -test('save clears headline when switching to auto', function () { +test('save preserves headline when switching to auto', function () { CabinetTabletSetting::factory()->create([ 'store_status' => 'notice', 'notice_headline' => 'Alter Text', + 'notice_subtext' => 'Alter Subtext', ]); Livewire::test(QuickStatus::class, ['k' => VALID_KEY]) @@ -84,8 +85,24 @@ test('save clears headline when switching to auto', function () { ->call('save') ->assertHasNoErrors(); - expect(CabinetTabletSetting::current()->store_status)->toBe('auto'); - expect(CabinetTabletSetting::current()->notice_headline)->toBeNull(); + $settings = CabinetTabletSetting::current(); + expect($settings->store_status)->toBe('auto'); + expect($settings->notice_headline)->toBe('Alter Text'); + expect($settings->notice_subtext)->toBe('Alter Subtext'); +}); + +test('switching back to notice restores saved headline from database', function () { + CabinetTabletSetting::factory()->create([ + 'store_status' => 'notice', + 'notice_headline' => 'Gespeicherter Hinweis', + 'notice_subtext' => 'Gespeicherter Subtext', + ]); + + Livewire::test(QuickStatus::class, ['k' => VALID_KEY]) + ->call('selectStatus', 'auto') + ->call('selectStatus', 'notice') + ->assertSet('noticeHeadline', 'Gespeicherter Hinweis') + ->assertSet('noticeSubtext', 'Gespeicherter Subtext'); }); test('save validates headline max length', function () {