mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-06 12:02:45 +03:00
@@ -22,7 +22,7 @@ class PageEditorTest extends TestCase
|
||||
{
|
||||
$this->assertEquals('wysiwyg', setting('app-editor'));
|
||||
$resp = $this->asAdmin()->get($this->page->book->getUrl('/create-page'));
|
||||
$this->followRedirects($resp)->assertElementExists('#html-editor');
|
||||
$this->withHtml($this->followRedirects($resp))->assertElementExists('#html-editor');
|
||||
}
|
||||
|
||||
public function test_markdown_setting_shows_markdown_editor_for_new_pages()
|
||||
@@ -30,7 +30,7 @@ class PageEditorTest extends TestCase
|
||||
$this->setSettings(['app-editor' => 'markdown']);
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->book->getUrl('/create-page'));
|
||||
$this->followRedirects($resp)
|
||||
$this->withHtml($this->followRedirects($resp))
|
||||
->assertElementNotExists('#html-editor')
|
||||
->assertElementExists('#markdown-editor');
|
||||
}
|
||||
@@ -42,8 +42,8 @@ class PageEditorTest extends TestCase
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementContains('[name="markdown"]', $mdContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementContains('[name="markdown"]', $mdContent);
|
||||
}
|
||||
|
||||
public function test_html_content_given_to_editor_if_no_markdown()
|
||||
@@ -51,8 +51,8 @@ class PageEditorTest extends TestCase
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl() . '/edit')
|
||||
->assertElementContains('[name="markdown"]', $this->page->html);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl() . '/edit');
|
||||
$this->withHtml($resp)->assertElementContains('[name="markdown"]', $this->page->html);
|
||||
}
|
||||
|
||||
public function test_empty_markdown_still_saves_without_error()
|
||||
@@ -91,19 +91,19 @@ class PageEditorTest extends TestCase
|
||||
|
||||
// Book draft goes back to book
|
||||
$resp = $this->get($book->getUrl("/draft/{$draft->id}"));
|
||||
$resp->assertElementContains('a[href="' . $book->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $book->getUrl() . '"]', 'Back');
|
||||
|
||||
// Chapter draft goes back to chapter
|
||||
$draft->chapter_id = $chapter->id;
|
||||
$draft->save();
|
||||
$resp = $this->get($book->getUrl("/draft/{$draft->id}"));
|
||||
$resp->assertElementContains('a[href="' . $chapter->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $chapter->getUrl() . '"]', 'Back');
|
||||
|
||||
// Saved page goes back to page
|
||||
$this->post($book->getUrl("/draft/{$draft->id}"), ['name' => 'Updated', 'html' => 'Updated']);
|
||||
$draft->refresh();
|
||||
$resp = $this->get($draft->getUrl('/edit'));
|
||||
$resp->assertElementContains('a[href="' . $draft->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $draft->getUrl() . '"]', 'Back');
|
||||
}
|
||||
|
||||
public function test_switching_from_html_to_clean_markdown_works()
|
||||
@@ -116,7 +116,7 @@ class PageEditorTest extends TestCase
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=markdown-clean'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee("## A Header\n\nSome **bold** content.");
|
||||
$resp->assertElementExists('#markdown-editor');
|
||||
$this->withHtml($resp)->assertElementExists('#markdown-editor');
|
||||
}
|
||||
|
||||
public function test_switching_from_html_to_stable_markdown_works()
|
||||
@@ -129,7 +129,7 @@ class PageEditorTest extends TestCase
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=markdown-stable'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee('<h2>A Header</h2><p>Some <strong>bold</strong> content.</p>', true);
|
||||
$resp->assertElementExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_switching_from_markdown_to_wysiwyg_works()
|
||||
@@ -142,40 +142,40 @@ class PageEditorTest extends TestCase
|
||||
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=wysiwyg'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$resp->assertSee("<h2>A Header</h2>\n<p>Some content with <strong>bold</strong> text!</p>", true);
|
||||
}
|
||||
|
||||
public function test_page_editor_changes_with_editor_property()
|
||||
{
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
|
||||
$this->page->markdown = "## A Header\n\nSome content with **bold** text!";
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$resp->assertElementExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_editor_type_switch_options_show()
|
||||
{
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
|
||||
$resp->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit?editor=markdown-stable'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
||||
}
|
||||
|
||||
public function test_editor_type_switch_options_dont_show_if_without_change_editor_permissions()
|
||||
{
|
||||
$resp = $this->asEditor()->get($this->page->getUrl('/edit'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementNotExists("a[href*=\"${editLink}\"]");
|
||||
$this->withHtml($resp)->assertElementNotExists("a[href*=\"${editLink}\"]");
|
||||
}
|
||||
|
||||
public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions()
|
||||
@@ -187,8 +187,8 @@ class PageEditorTest extends TestCase
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/edit?editor=markdown-stable'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$resp->assertElementNotExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementNotExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_page_save_does_not_change_active_editor_without_change_editor_permissions()
|
||||
|
Reference in New Issue
Block a user