To ensure consistenent behaviour before/after changes.
Added tests to cover.
*/
public function descriptionHtml(): string
{
- $html = $this->description_html ?: '<p>' . e($this->description) . '</p>';
+ $html = $this->description_html ?: '<p>' . nl2br(e($this->description)) . '</p>';
return HtmlContentFilter::removeScriptsFromHtmlString($html);
}
}
<main class="content-wrap card">
<h1 class="break-text">{{$book->name}}</h1>
<div refs="entity-search@contentView" class="book-content">
- <p class="text-muted">{!! $book->descriptionHtml() !!}</p>
+ <div class="text-muted break-text">{!! $book->descriptionHtml() !!}</div>
@if(count($bookChildren) > 0)
<div class="entity-list book-contents">
@foreach($bookChildren as $childElement)
<main class="content-wrap card">
<h1 class="break-text">{{ $chapter->name }}</h1>
<div refs="entity-search@contentView" class="chapter-content">
- <p class="text-muted break-text">{!! $chapter->descriptionHtml() !!}</p>
+ <div class="text-muted break-text">{!! $chapter->descriptionHtml() !!}</div>
@if(count($pages) > 0)
<div class="entity-list book-contents">
@foreach($pages as $page)
</div>
<div class="book-content">
- <p class="text-muted">{!! $shelf->descriptionHtml() !!}</p>
+ <div class="text-muted break-text">{!! $shelf->descriptionHtml() !!}</div>
@if(count($sortedVisibleShelfBooks) > 0)
@if($view === 'list')
<div class="entity-list">
$resp = $this->asEditor()->get($shelf->getUrl('/create-book'));
$this->withHtml($resp)->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel');
}
+
+ public function test_show_view_displays_description_if_no_description_html_set()
+ {
+ $shelf = $this->entities->shelf();
+ $shelf->description_html = '';
+ $shelf->description = "My great\ndescription\n\nwith newlines";
+ $shelf->save();
+
+ $resp = $this->asEditor()->get($shelf->getUrl());
+ $resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
+ }
}
$this->assertEquals($expected, $book->description_html);
}
+ public function test_show_view_displays_description_if_no_description_html_set()
+ {
+ $book = $this->entities->book();
+ $book->description_html = '';
+ $book->description = "My great\ndescription\n\nwith newlines";
+ $book->save();
+
+ $resp = $this->asEditor()->get($book->getUrl());
+ $resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
+ }
+
public function test_show_view_has_copy_button()
{
$book = $this->entities->book();
$resp->assertSee($chapter->description_html, false);
}
+ public function test_show_view_displays_description_if_no_description_html_set()
+ {
+ $chapter = $this->entities->chapter();
+ $chapter->description_html = '';
+ $chapter->description = "My great\ndescription\n\nwith newlines";
+ $chapter->save();
+
+ $resp = $this->asEditor()->get($chapter->getUrl());
+ $resp->assertSee("<p>My great<br>\ndescription<br>\n<br>\nwith newlines</p>", false);
+ }
+
public function test_delete()
{
$chapter = Chapter::query()->whereHas('pages')->first();