]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageTest.php
Updated attachment links to have dropdown for open type
[bookstack] / tests / Entity / PageTest.php
index 313fc77f060f51e7ddb0c15bf9eba8070a18a1ed..efe5400a0f6f8b2701a17d670927a5b116fa3a18 100644 (file)
@@ -14,7 +14,7 @@ class PageTest extends TestCase
     {
         /** @var Chapter $chapter */
         $chapter = Chapter::query()->first();
-        $page = factory(Page::class)->make([
+        $page = Page::factory()->make([
             'name' => 'My First Page',
         ]);
 
@@ -261,6 +261,57 @@ class PageTest extends TestCase
             ->assertElementContains('.entity-list .page:nth-child(1)', $content['page']->name);
     }
 
+    public function test_recently_updated_pages_view_shows_updated_by_details()
+    {
+        $user = $this->getEditor();
+        /** @var Page $page */
+        $page = Page::query()->first();
+
+        $this->actingAs($user)->put($page->getUrl(), [
+            'name' => 'Updated title',
+            'html' => '<p>Updated content</p>',
+        ]);
+
+        $resp = $this->asAdmin()->get('/pages/recently-updated');
+        $resp->assertElementContains('.entity-list .page:nth-child(1)', 'Updated 1 second ago by ' . $user->name);
+    }
+
+    public function test_recently_updated_pages_view_shows_parent_chain()
+    {
+        $user = $this->getEditor();
+        /** @var Page $page */
+        $page = Page::query()->whereNotNull('chapter_id')->first();
+
+        $this->actingAs($user)->put($page->getUrl(), [
+            'name' => 'Updated title',
+            'html' => '<p>Updated content</p>',
+        ]);
+
+        $resp = $this->asAdmin()->get('/pages/recently-updated');
+        $resp->assertElementContains('.entity-list .page:nth-child(1)', $page->chapter->getShortName(42));
+        $resp->assertElementContains('.entity-list .page:nth-child(1)', $page->book->getShortName(42));
+    }
+
+    public function test_recently_updated_pages_view_does_not_show_parent_if_not_visible()
+    {
+        $user = $this->getEditor();
+        /** @var Page $page */
+        $page = Page::query()->whereNotNull('chapter_id')->first();
+
+        $this->actingAs($user)->put($page->getUrl(), [
+            'name' => 'Updated title',
+            'html' => '<p>Updated content</p>',
+        ]);
+
+        $this->setEntityRestrictions($page->book);
+        $this->setEntityRestrictions($page, ['view'], [$user->roles->first()]);
+
+        $resp = $this->get('/pages/recently-updated');
+        $resp->assertDontSee($page->book->getShortName(42));
+        $resp->assertDontSee($page->chapter->getShortName(42));
+        $resp->assertElementContains('.entity-list .page:nth-child(1)', 'Updated title');
+    }
+
     public function test_recently_updated_pages_on_home()
     {
         /** @var Page $page */