Merge pull request #6057 from BookStackApp/v25-12

V25.12 changes v3
This commit is contained in:
Dan Brown
2026-03-15 12:51:02 +00:00
committed by GitHub
5 changed files with 202 additions and 121 deletions

View File

@@ -47,6 +47,20 @@ class PageRevisionTest extends TestCase
$revisionView->assertSee('new revision content');
}
public function test_page_revision_preview_filters_html_content()
{
$this->asEditor();
$page = $this->entities->page();
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => '<script>dontwantthishere</script><style>dontwantthishere</style><p>expectthisthough</p>']);
$pageRevision = $page->revisions->last();
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => '<p>Updated content</p>']);
$revisionView = $this->get($page->getUrl() . '/revisions/' . $pageRevision->id);
$revisionView->assertStatus(200);
$revisionView->assertSee('expectthisthough');
$revisionView->assertDontSee('dontwantthishere');
}
public function test_page_revision_restore_updates_content()
{
$this->asEditor();
@@ -215,6 +229,34 @@ class PageRevisionTest extends TestCase
$html->assertElementContains('.item-list > .item-list-row:nth-child(2)', 'Changes');
}
public function test_revision_changes_view_shows_diff()
{
$this->asEditor();
$page = $this->entities->page();
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => '<p id="bkmrk-hello">Hello there dog</p>']);
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => '<p id="bkmrk-hello">Hello there cat</p>']);
$pageRevision = $page->revisions()->orderBy('id', 'desc')->first();
$revisionView = $this->get("{$page->getUrl()}/revisions/{$pageRevision->id}/changes");
$revisionView->assertStatus(200);
$revisionView->assertSee('<p id="bkmrk-hello">Hello there <del class="diffmod">dog</del><ins class="diffmod">cat</ins></p>', false);
}
public function test_revision_changes_view_filters_html_content()
{
$this->asEditor();
$page = $this->entities->page();
$html = '<script>dontwantthishere</script><style>dontwantthishere</style><p>expectthisthough</p>';
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => $html]);
$this->createRevisions($page, 1, ['name' => 'updated page', 'html' => $html]);
$pageRevision = $page->revisions()->orderBy('id', 'desc')->first();
$revisionView = $this->get("{$page->getUrl()}/revisions/{$pageRevision->id}/changes");
$revisionView->assertStatus(200);
$revisionView->assertSee('expectthisthough');
$revisionView->assertDontSee('dontwantthishere');
}
public function test_revision_restore_action_only_visible_with_permission()
{
$page = $this->entities->page();

View File

@@ -153,6 +153,26 @@ class UserPreferencesTest extends TestCase
->assertElementNotExists('.content-wrap .entity-list-item');
}
public function test_redirect_on_preference_change_checks_host()
{
$expectedByRedirect = [
'http://localhost/beans' => 'http://localhost/beans',
'https://localhost/beans' => 'http://localhost',
'http://localhost:9090/beans' => 'http://localhost',
'http://localhost.example.com/beans' => 'http://localhost',
'http://localhost@example.com/beans' => 'http://localhost',
];
$this->asEditor();
foreach ($expectedByRedirect as $url => $expected) {
$req = $this->patch("/preferences/change-view/bookshelf", [
'view' => 'grid',
'_return' => $url,
]);
$req->assertRedirect($expected);
}
}
public function test_update_code_language_favourite()
{
$editor = $this->users->editor();