{tresc}'); Settings::set('email_footer', 'Pozdrawiamy, Wsparcie'); Settings::set('company_name', 'Acme'); $html = Settings::renderEmailLayout('
Treść zgłoszenia
'); expect($html)->not->toContain('should-be-ignored') ->and($html)->toBe(strtr(Settings::default('email_layout_html'), [ '{tresc}' => 'Treść zgłoszenia
', '{stopka}' => 'Pozdrawiamy, Wsparcie', '{firma}' => 'Acme', ])); }); test('the default footer is not empty and its own {firma} placeholder resolves through the layout', function () { Settings::set('company_name', 'Acme'); $html = Settings::renderEmailLayout('Treść
'); expect(Settings::default('email_footer'))->not->toBeEmpty() ->and($html)->toContain('Acme') ->and($html)->not->toContain('{firma}'); }); test('admin can reset the email footer back to its default, remounting the editor with a fresh key', function () { $admin = adminUser(); $component = Livewire::actingAs($admin)->test(Panel::class) ->call('setTab', 'email') ->call('saveEmailFooter', 'Coś innego') ->assertSet('emailFooterVersion', 0); $component->call('resetEmailFooter') ->assertOk() ->assertSet('emailFooterHtml', Settings::default('email_footer')) ->assertSet('emailFooterVersion', 1) ->assertSee('email-footer-1', escape: false); expect(Settings::get('email_footer'))->toBe(Settings::default('email_footer')); }); test('admin can save the email footer from the E-MAIL tab', function () { $admin = adminUser(); Livewire::actingAs($admin)->test(Panel::class) ->call('setTab', 'email') ->call('saveEmailFooter', 'Pozdrawiamy, Zespół Wsparcia
') ->assertOk() ->assertSet('emailFooterHtml', 'Pozdrawiamy, Zespół Wsparcia
'); expect(Settings::get('email_footer'))->toBe('Pozdrawiamy, Zespół Wsparcia
'); }); test('the live example preview reflects the currently saved footer', function () { $admin = adminUser(); $component = Livewire::actingAs($admin)->test(Panel::class) ->call('setTab', 'email') ->call('saveEmailFooter', 'Stopka na żywo'); expect($component->instance()->emailPreviewHtml)->toContain('Stopka na żywo') ->and($component->instance()->emailPreviewHtml)->toContain('#1234'); }); test('there is no more editor for the box layout itself, only for its footer', function () { expect(method_exists(Panel::class, 'saveEmailLayout'))->toBeFalse() ->and(method_exists(Panel::class, 'resetEmailLayout'))->toBeFalse(); }); test('a rendered ticket notification embeds its template body inside the fixed box layout', function () { seedStatusesAndPriorities(); $template = EmailTemplate::query()->create([ 'key' => 'tpl-layout-test', 'name' => 'x', 'trigger_label' => 'x', 'subject' => 'S', 'body' => 'Zgłoszenie #{numer} zostało utworzone.
', ]); $ticket = makeTicket(); $mail = (new TicketNotification($ticket, $template->id))->toMail((object) ['routes' => ['mail' => $ticket->email]]); expect($mail->viewData['html'])->toBe(Settings::renderEmailLayout('Zgłoszenie #'.$ticket->number.' zostało utworzone.
')) ->and($mail->view)->toBe('emails.ticket-notification'); });