1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Page Drafts: Added new "Delete Draft" action to draft menu

Provides a way for users to actually delte their user drafts where
required.
For #3927

Added test to cover new endpoint.

Makes update to MD editor #setText so that new selection is within new
range, otherwise it errors and fails operation.
This commit is contained in:
Dan Brown
2023-06-13 15:13:07 +01:00
parent f39938c4e3
commit b01bbf9c89
9 changed files with 101 additions and 14 deletions

View File

@ -166,6 +166,30 @@ class PageDraftTest extends TestCase
]);
}
public function test_user_draft_removed_on_user_drafts_delete_call()
{
$editor = $this->users->editor();
$page = $this->entities->page();
$this->actingAs($editor)->put('/ajax/page/' . $page->id . '/save-draft', [
'name' => $page->name,
'html' => '<p>updated draft again</p>',
]);
$revisionData = [
'type' => 'update_draft',
'created_by' => $editor->id,
'page_id' => $page->id,
];
$this->assertDatabaseHas('page_revisions', $revisionData);
$resp = $this->delete("/page-revisions/user-drafts/{$page->id}");
$resp->assertOk();
$this->assertDatabaseMissing('page_revisions', $revisionData);
}
public function test_updating_page_draft_with_markdown_retains_markdown_content()
{
$book = $this->entities->book();