]> BookStack Code Mirror - bookstack/blob - tests/Entity/PageEditorTest.php
Removed browserkit from a couple of classess
[bookstack] / tests / Entity / PageEditorTest.php
1 <?php
2
3 namespace Tests\Entity;
4
5 use BookStack\Entities\Models\Page;
6 use Tests\TestCase;
7
8 class PageEditorTest extends TestCase
9 {
10     /** @var Page  */
11     protected $page;
12
13     public function setUp(): void
14     {
15         parent::setUp();
16         $this->page = Page::query()->first();
17     }
18
19     public function test_default_editor_is_wysiwyg()
20     {
21         $this->assertEquals('wysiwyg', setting('app-editor'));
22         $this->asAdmin()->get($this->page->getUrl() . '/edit')
23             ->assertElementExists('#html-editor');
24     }
25
26     public function test_markdown_setting_shows_markdown_editor()
27     {
28         $this->setSettings(['app-editor' => 'markdown']);
29         $this->asAdmin()->get($this->page->getUrl() . '/edit')
30             ->assertElementNotExists('#html-editor')
31             ->assertElementExists('#markdown-editor');
32     }
33
34     public function test_markdown_content_given_to_editor()
35     {
36         $this->setSettings(['app-editor' => 'markdown']);
37
38         $mdContent = '# hello. This is a test';
39         $this->page->markdown = $mdContent;
40         $this->page->save();
41
42         $this->asAdmin()->get($this->page->getUrl() . '/edit')
43             ->assertElementContains('[name="markdown"]', $mdContent);
44     }
45
46     public function test_html_content_given_to_editor_if_no_markdown()
47     {
48         $this->setSettings(['app-editor' => 'markdown']);
49         $this->asAdmin()->get($this->page->getUrl() . '/edit')
50             ->assertElementContains('[name="markdown"]', $this->page->html);
51     }
52 }