3 class UserProfileTest extends BrowserKitTest
7 public function setUp()
10 $this->user = \BookStack\Auth\User::all()->last();
13 public function test_profile_page_shows_name()
16 ->visit('/user/' . $this->user->id)
17 ->see($this->user->name);
20 public function test_profile_page_shows_recent_entities()
22 $content = $this->createEntityChainBelongingToUser($this->user, $this->user);
25 ->visit('/user/' . $this->user->id)
26 // Check the recently created page is shown
27 ->see($content['page']->name)
28 // Check the recently created chapter is shown
29 ->see($content['chapter']->name)
30 // Check the recently created book is shown
31 ->see($content['book']->name);
34 public function test_profile_page_shows_created_content_counts()
36 $newUser = $this->getNewBlankUser();
38 $this->asAdmin()->visit('/user/' . $newUser->id)
40 ->seeInElement('#content-counts', '0 Books')
41 ->seeInElement('#content-counts', '0 Chapters')
42 ->seeInElement('#content-counts', '0 Pages');
44 $this->createEntityChainBelongingToUser($newUser, $newUser);
46 $this->asAdmin()->visit('/user/' . $newUser->id)
48 ->seeInElement('#content-counts', '1 Book')
49 ->seeInElement('#content-counts', '1 Chapter')
50 ->seeInElement('#content-counts', '1 Page');
53 public function test_profile_page_shows_recent_activity()
55 $newUser = $this->getNewBlankUser();
56 $this->actingAs($newUser);
57 $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
58 \Activity::add($entities['book'], 'book_update', $entities['book']->id);
59 \Activity::add($entities['page'], 'page_create', $entities['book']->id);
61 $this->asAdmin()->visit('/user/' . $newUser->id)
62 ->seeInElement('#recent-user-activity', 'updated book')
63 ->seeInElement('#recent-user-activity', 'created page')
64 ->seeInElement('#recent-user-activity', $entities['page']->name);
67 public function test_clicking_user_name_in_activity_leads_to_profile_page()
69 $newUser = $this->getNewBlankUser();
70 $this->actingAs($newUser);
71 $entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
72 \Activity::add($entities['book'], 'book_update', $entities['book']->id);
73 \Activity::add($entities['page'], 'page_create', $entities['book']->id);
75 $this->asAdmin()->visit('/')->clickInElement('#recent-activity', $newUser->name)
76 ->seePageIs('/user/' . $newUser->id)
77 ->see($newUser->name);
80 public function test_guest_profile_shows_limited_form()
83 ->visit('/settings/users')
85 ->dontSeeElement('#password');
88 public function test_guest_profile_cannot_be_deleted()
90 $guestUser = \BookStack\Auth\User::getDefault();
91 $this->asAdmin()->visit('/settings/users/' . $guestUser->id . '/delete')
92 ->see('Delete User')->see('Guest')
94 ->seePageIs('/settings/users/' . $guestUser->id)
95 ->see('cannot delete the guest user');
98 public function test_books_view_is_list()
100 $editor = $this->getEditor();
101 setting()->putUser($editor, 'books_view_type', 'list');
103 $this->actingAs($editor)
105 ->pageNotHasElement('.featured-image-container')
106 ->pageHasElement('.content-wrap .entity-list-item');
109 public function test_books_view_is_grid()
111 $editor = $this->getEditor();
112 setting()->putUser($editor, 'books_view_type', 'grid');
114 $this->actingAs($editor)
116 ->pageHasElement('.featured-image-container');