]> BookStack Code Mirror - bookstack/blob - tests/Entity/MarkdownTest.php
fix image delete confirm text
[bookstack] / tests / Entity / MarkdownTest.php
1 <?php namespace Tests\Entity;
2
3 use Tests\BrowserKitTest;
4
5 class MarkdownTest extends BrowserKitTest
6 {
7     protected $page;
8
9     public function setUp(): void
10     {
11         parent::setUp();
12         $this->page = \BookStack\Entities\Models\Page::first();
13     }
14
15     protected function setMarkdownEditor()
16     {
17         $this->setSettings(['app-editor' => 'markdown']);
18     }
19
20     public function test_default_editor_is_wysiwyg()
21     {
22         $this->assertEquals(setting('app-editor'), 'wysiwyg');
23         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
24             ->pageHasElement('#html-editor');
25     }
26     
27     public function test_markdown_setting_shows_markdown_editor()
28     {
29         $this->setMarkdownEditor();
30         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
31             ->pageNotHasElement('#html-editor')
32             ->pageHasElement('#markdown-editor');
33     }
34
35     public function test_markdown_content_given_to_editor()
36     {
37         $this->setMarkdownEditor();
38         $mdContent = '# hello. This is a test';
39         $this->page->markdown = $mdContent;
40         $this->page->save();
41         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
42             ->seeInField('markdown', $mdContent);
43     }
44
45     public function test_html_content_given_to_editor_if_no_markdown()
46     {
47         $this->setMarkdownEditor();
48         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
49             ->seeInField('markdown', $this->page->html);
50     }
51
52 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.