Zentriert mit grün und groß.
Normal
'; public function test_the_website_profile_keeps_alignment_size_and_color_in_the_form_the_editor_reads_again(): void { $html = FormattedText::canonical(self::EDITOR, true); $this->assertSame('Zentriert mit grün und groß.
Normal
', $html); $this->assertSame($html, FormattedText::canonical($html, true), 'Die kanonische Form ist stabil, ein erneutes Öffnen erzeugt keine Änderung.'); } public function test_the_catalog_profile_drops_all_three(): void { foreach ([FormattedText::canonical(self::EDITOR), FormattedText::canonical(FormattedText::canonical(self::EDITOR, true))] as $html) { $this->assertStringNotContainsString('style', $html); $this->assertStringNotContainsString('assertStringNotContainsString('data-', $html); $this->assertStringContainsString('A rosa riesig frei beides
', true, ); $this->assertSame('A rosa riesig frei beides
', $html); } public function test_alignment_survives_in_list_items_table_cells_and_quotes(): void { $html = FormattedText::canonical( 'Punkt
Zelle |
', true, ); $this->assertStringContainsString('Zitat
Punkt
Zelle
', $html); } public function test_left_alignment_is_the_default_and_is_not_stored(): void { $this->assertSame('Zitat
Links
Links
', FormattedText::canonical('Links
Links
', true)); $this->assertSame('Rechts
', FormattedText::canonical('Rechts
', true)); } private function field(): RichEditor { $livewire = new class extends Component implements HasSchemas { use InteractsWithSchemas; public function render(): string { return ''; } }; $field = RichField::make('body', 'Text', website: true); $field->container(Schema::make($livewire)); return $field; } public function test_every_value_of_the_editor_survives_the_real_state_round_trip(): void { $editor = $this->field(); $cast = new RichEditorStateCast($editor); $stored = FormattedText::canonical(self::EDITOR, true); $json = $cast->set($stored); $back = FormattedText::canonical($cast->get($json), true); $this->assertSame($stored, $back, 'Öffnen und Speichern im Editor ändert Ausrichtung, Größe und Farbe nicht.'); } public function test_the_editor_offers_size_color_and_alignment_only_for_website_texts(): void { $website = $this->field(); $plainField = RichField::make('body', 'Text'); $plainField->container($website->getContainer()); $plain = array_merge(...$plainField->getToolbarButtons()); $buttons = array_merge(...array_map(fn (array $group): array => $group, $website->getToolbarButtons())); foreach (['fontSize', 'textColor', 'alignStart', 'alignCenter', 'alignEnd'] as $tool) { $this->assertNotContains($tool, $plain, "Die Verwaltung bietet $tool nicht."); $this->assertContains($tool, $buttons, "Der Fließtext bietet $tool."); } $this->assertSame(array_keys(FormattedText::SITE_COLORS), array_keys($website->getTextColors()), 'Nur die festen Farben, in dieser Reihenfolge.'); $this->assertFalse($website->hasCustomTextColors(), 'Keine freie Farbe.'); $this->assertArrayHasKey('fontSize', $website->getTools()); } public function test_the_page_shows_classes_instead_of_inline_styles(): void { $page = Page::query()->create(['path' => '/formatiert']); $service = app(PageService::class); $service->publish($page, $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'prose', 'v' => 2, 'settings' => [], 'data' => ['body' => self::EDITOR]]]]], null, null, null)); $html = $this->get('/formatiert')->assertOk()->getContent(); $this->assertStringContainsString('Zentriert mit grün und groß.
', $html); $this->assertStringContainsString('x
', ProseWidget::render('x
')); } public function test_the_stylesheet_knows_every_size_and_color(): void { $css = (string) file_get_contents(resource_path('css/widgets.css')); foreach (array_keys(FormattedText::SITE_SIZES) as $size) { $this->assertStringContainsString("span[data-size='$size']", $css); } foreach (array_keys(FormattedText::SITE_COLORS) as $color) { $this->assertStringContainsString("span.color[data-color='$color']", $css); $this->assertStringContainsString("--tc-$color:", $css); } $this->assertFileExists(public_path('js/rich-font-size.js')); $script = (string) file_get_contents(public_path('js/rich-font-size.js')); foreach (array_keys(FormattedText::SITE_SIZES) as $size) { $this->assertStringContainsString($size.':', $script, 'Die JS-Erweiterung kennt jede Größe.'); } } }