mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-04 17:04:32 +08:00
Updated view-change endpoints to be clearer, separated books and shelf
- Separated books-list and shelf-show view types to be saved separately. During review of #1755
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
<?php namespace Test\User;
|
||||
|
||||
use Activity;
|
||||
use BookStack\Auth\User;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use Tests\BrowserKitTest;
|
||||
|
||||
class UserProfileTest extends BrowserKitTest
|
||||
@ -9,7 +12,7 @@ class UserProfileTest extends BrowserKitTest
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = \BookStack\Auth\User::all()->last();
|
||||
$this->user = User::all()->last();
|
||||
}
|
||||
|
||||
public function test_profile_page_shows_name()
|
||||
@ -57,8 +60,8 @@ class UserProfileTest extends BrowserKitTest
|
||||
$newUser = $this->getNewBlankUser();
|
||||
$this->actingAs($newUser);
|
||||
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
|
||||
\Activity::add($entities['book'], 'book_update', $entities['book']->id);
|
||||
\Activity::add($entities['page'], 'page_create', $entities['book']->id);
|
||||
Activity::add($entities['book'], 'book_update', $entities['book']->id);
|
||||
Activity::add($entities['page'], 'page_create', $entities['book']->id);
|
||||
|
||||
$this->asAdmin()->visit('/user/' . $newUser->id)
|
||||
->seeInElement('#recent-user-activity', 'updated book')
|
||||
@ -71,8 +74,8 @@ class UserProfileTest extends BrowserKitTest
|
||||
$newUser = $this->getNewBlankUser();
|
||||
$this->actingAs($newUser);
|
||||
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
|
||||
\Activity::add($entities['book'], 'book_update', $entities['book']->id);
|
||||
\Activity::add($entities['page'], 'page_create', $entities['book']->id);
|
||||
Activity::add($entities['book'], 'book_update', $entities['book']->id);
|
||||
Activity::add($entities['page'], 'page_create', $entities['book']->id);
|
||||
|
||||
$this->asAdmin()->visit('/')->clickInElement('#recent-activity', $newUser->name)
|
||||
->seePageIs('/user/' . $newUser->id)
|
||||
@ -89,7 +92,7 @@ class UserProfileTest extends BrowserKitTest
|
||||
|
||||
public function test_guest_profile_cannot_be_deleted()
|
||||
{
|
||||
$guestUser = \BookStack\Auth\User::getDefault();
|
||||
$guestUser = User::getDefault();
|
||||
$this->asAdmin()->visit('/settings/users/' . $guestUser->id . '/delete')
|
||||
->see('Delete User')->see('Guest')
|
||||
->press('Confirm')
|
||||
@ -118,4 +121,24 @@ class UserProfileTest extends BrowserKitTest
|
||||
->pageHasElement('.featured-image-container');
|
||||
}
|
||||
|
||||
public function test_shelf_view_type_change()
|
||||
{
|
||||
$editor = $this->getEditor();
|
||||
$shelf = Bookshelf::query()->first();
|
||||
setting()->putUser($editor, 'bookshelf_view_type', 'list');
|
||||
|
||||
$this->actingAs($editor)->visit($shelf->getUrl())
|
||||
->pageNotHasElement('.featured-image-container')
|
||||
->pageHasElement('.content-wrap .entity-list-item')
|
||||
->see('Grid View');
|
||||
|
||||
$req = $this->patch("/settings/users/{$editor->id}/switch-shelf-view", ['view_type' => 'grid']);
|
||||
$req->assertRedirectedTo($shelf->getUrl());
|
||||
|
||||
$this->actingAs($editor)->visit($shelf->getUrl())
|
||||
->pageHasElement('.featured-image-container')
|
||||
->pageNotHasElement('.content-wrap .entity-list-item')
|
||||
->see('List View');
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user