QuickStatus: Hinweistext beim Wechsel auf Auto beibehalten.
Gespeicherte Headline und Subtext bleiben erhalten und stehen beim erneuten Umschalten auf Hinweis wieder zur Verfügung. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7491d20d39
commit
2a34adc515
2 changed files with 20 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue