]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageDraftTest.php
respective book and chapter structure added.
[bookstack] / tests / Entity / PageDraftTest.php
index 75b1933ea0e10d46fcd2e648081183d13b8abebf..e99ba9b8189423f85922e0fe066550f25e467ee5 100644 (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();