create('Stopp sagen', CompositionKind::Exercise); $component = Livewire::actingAs($this->editor(), 'staff') ->test(EditPractice::class, ['record' => $practice->getKey()]) ->assertOk(); $component->set('rich.summary', [ 'type' => 'doc', 'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Fester ', 'marks' => []], ['type' => 'text', 'text' => 'Stand', 'marks' => [['type' => 'bold']]]]]], ]); $this->assertSame('

Fester Stand

', $component->get('summary')); $component->set('summary', '

Vom Server

')->assertOk(); $this->assertSame('doc', $component->get('rich.summary.type')); $this->assertSame('Vom Server', $component->get('rich.summary.content.0.content.0.text')); } public function test_legacy_plain_text_appears_formatted_but_opening_it_changes_nothing(): void { $practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise); $practice->forceFill(['summary' => "Erste Zeile.\n\n- Punkt A\n- Punkt B"])->save(); $component = Livewire::actingAs($this->editor(), 'staff') ->test(EditPractice::class, ['record' => $practice->getKey()]) ->assertOk(); $this->assertSame("Erste Zeile.\n\n- Punkt A\n- Punkt B", $component->get('summary'), 'Die Eigenschaft bleibt, was gespeichert ist.'); $this->assertSame('bulletList', $component->get('rich.summary.content.1.type'), 'Der Editor zeigt die Liste.'); $this->assertFalse($component->instance()->textFieldsChanged(), 'Öffnen markiert nichts als geändert.'); $this->assertSame("Erste Zeile.\n\n- Punkt A\n- Punkt B", $practice->fresh()->summary); } public function test_saving_stores_canonical_html_and_an_untouched_legacy_field_is_not_reported_as_changed(): void { $practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise); $component = Livewire::actingAs($this->editor(), 'staff') ->test(EditPractice::class, ['record' => $practice->getKey()]) ->set('summary', '

Kurz fett

') ->set('description', '

Lang

'); $this->assertTrue($component->instance()->textFieldsChanged()); $component->call('saveRedaktion'); $practice->refresh(); $this->assertSame(FormattedText::canonicalHtml('

Kurz fett

'), $practice->summary); $this->assertSame('

Lang

', $practice->description); } public function test_a_list_and_a_nested_list_pass_the_payload_depth_guard(): void { $practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise); $item = fn (string $text, array $more = []): array => ['type' => 'listItem', 'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => $text]]], ...$more]]; $component = Livewire::actingAs($this->editor(), 'staff') ->test(EditPractice::class, ['record' => $practice->getKey()]) ->set('rich.summary', ['type' => 'doc', 'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Davor']]], ['type' => 'bulletList', 'content' => [$item('Eins', [['type' => 'bulletList', 'content' => [$item('Eins eins')]]]), $item('Zwei')]]]]) ->assertHasNoErrors(); $this->assertSame('

Davor

', $component->get('summary')); $component->set('rich.summary.content.1.content.0.content.0.content.0.text', 'Geändert'); $this->assertStringContainsString('Geändert', $component->get('summary')); } public function test_a_formatted_summary_reads_as_plain_text_wherever_a_card_or_list_uses_it(): void { $practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise); $practice->forceFill([ 'summary' => '

Kurz fett & klar

', 'description' => '

Lang erklärt

', ])->save(); $text = app(LibraryCatalog::class)->text($practice->fresh()); $this->assertSame('Kurz fett & klar - Eins - Zwei', $text['summary']); $this->assertSame('Lang erklärt', $text['description']); $this->assertStringContainsString('fett', $text['summary_html']); $this->assertStringContainsString('erklärt', $text['description_html']); $profile = app(EditorialProfileReader::class)->read($practice->fresh(), 'bibliothek'); $this->assertStringNotContainsString('<', (string) $profile->value('summary')); $this->assertStringContainsString('