1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-21 05:26:10 +03:00

Updated tests to suit layout changes, Updated 404 page

- Also replaced 'or' usage in templates with null coalescing operator
This commit is contained in:
Dan Brown 2019-04-06 18:36:17 +01:00
parent 67ed4710b6
commit 7cda9b026e
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
14 changed files with 72 additions and 78 deletions

View File

@ -123,7 +123,7 @@ class HomeController extends Controller
*/ */
public function customHeadContent() public function customHeadContent()
{ {
return view('partials/custom-head-content'); return view('partials.custom-head-content');
} }
/** /**
@ -138,7 +138,7 @@ class HomeController extends Controller
$allowRobots = $sitePublic; $allowRobots = $sitePublic;
} }
return response() return response()
->view('common/robots', ['allowRobots' => $allowRobots]) ->view('common.robots', ['allowRobots' => $allowRobots])
->header('Content-Type', 'text/plain'); ->header('Content-Type', 'text/plain');
} }
@ -147,6 +147,6 @@ class HomeController extends Controller
*/ */
public function getNotFound() public function getNotFound()
{ {
return response()->view('errors/404', [], 404); return response()->view('errors.404', [], 404);
} }
} }

View File

@ -1,4 +1,4 @@
<div id="image-manager" image-type="{{ $imageType }}" uploaded-to="{{ $uploaded_to or 0 }}"> <div id="image-manager" image-type="{{ $imageType }}" uploaded-to="{{ $uploaded_to ?? 0 }}">
<div overlay v-cloak @click="hide"> <div overlay v-cloak @click="hide">
<div class="popup-body" @click.stop=""> <div class="popup-body" @click.stop="">

View File

@ -1,4 +1,4 @@
<div class="image-picker" image-picker="{{$name}}" data-default-image="{{ $defaultImage }}" data-resize-height="{{ $resizeHeight }}" data-resize-width="{{ $resizeWidth }}" data-current-id="{{ $currentId or '' }}" data-resize-crop="{{ $resizeCrop or '' }}"> <div class="image-picker" image-picker="{{$name}}" data-default-image="{{ $defaultImage }}" data-resize-height="{{ $resizeHeight }}" data-resize-width="{{ $resizeWidth }}" data-current-id="{{ $currentId ?? '' }}" data-resize-crop="{{ $resizeCrop ?? '' }}">
<div class="grid half"> <div class="grid half">
<div class="text-center"> <div class="text-center">

View File

@ -1,36 +1,45 @@
@extends('simple-layout') @extends('simple-layout')
@section('content') @section('content')
<div class="container"> <div class="container mt-l">
<p>&nbsp;</p> <div class="card mb-xl px-l pb-xl pt-l">
<div class="grid half v-center">
<div class="card"> <div>
<h3>@icon('danger') {{ $message or trans('errors.404_page_not_found') }}</h3> <h1 class="list-heading">{{ $message ?? trans('errors.404_page_not_found') }}</h1>
<div class="body"> <h5>{{ trans('errors.sorry_page_not_found') }}</h5>
<h5>{{ trans('errors.sorry_page_not_found') }}</h5> </div>
<p><a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a></p> <div class="text-right">
<a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a>
</div>
</div> </div>
</div> </div>
@if (setting('app-public') || !user()->isDefault()) @if (setting('app-public') || !user()->isDefault())
<div class="row"> <div class="grid third gap-xxl">
<div class="col-md-4"> <div>
<div class="card"> <div class="card mb-xl">
<h3 class="text-muted">@icon('page') {{ trans('entities.pages_popular') }}</h3> <h3>{{ trans('entities.pages_popular') }}</h3>
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Entities\Page::class]), 'style' => 'compact']) <div class="px-m">
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, 'page'), 'style' => 'compact'])
</div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div>
<div class="card"> <div class="card mb-xl">
<h3 class="text-muted">@icon('book') {{ trans('entities.books_popular') }}</h3> <h3>{{ trans('entities.books_popular') }}</h3>
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Entities\Book::class]), 'style' => 'compact']) <div class="px-m">
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, 'book'), 'style' => 'compact'])
</div>
</div> </div>
</div> </div>
<div class="col-md-4"> <div>
<div class="card"> <div class="card mb-xl">
<h3 class="text-muted">@icon('chapter') {{ trans('entities.chapters_popular') }}</h3> <h3>{{ trans('entities.chapters_popular') }}</h3>
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Entities\Chapter::class]), 'style' => 'compact']) <div class="px-m">
@include('partials.entity-list', ['entities' => Views::getPopular(10, 0, 'chapter'), 'style' => 'compact'])
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -6,7 +6,7 @@
<div class="card"> <div class="card">
<h3 class="text-muted">{{ trans('errors.error_occurred') }}</h3> <h3 class="text-muted">{{ trans('errors.error_occurred') }}</h3>
<div class="body"> <div class="body">
<h5>{{ $message or 'An unknown error occurred' }}</h5> <h5>{{ $message ?? 'An unknown error occurred' }}</h5>
<p><a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a></p> <p><a href="{{ baseUrl('/') }}" class="button outline">{{ trans('errors.return_home') }}</a></p>
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
</div> </div>
@if(userCan('attachment-create-all')) @if(userCan('attachment-create-all'))
<div toolbox-tab-content="files" id="attachment-manager" page-id="{{ $page->id or 0 }}"> <div toolbox-tab-content="files" id="attachment-manager" page-id="{{ $page->id ?? 0 }}">
<h4>{{ trans('entities.attachments') }}</h4> <h4>{{ trans('entities.attachments') }}</h4>
<div class="padded files"> <div class="padded files">

View File

@ -3,10 +3,10 @@
drafts-enabled="{{ $draftsEnabled ? 'true' : 'false' }}" drafts-enabled="{{ $draftsEnabled ? 'true' : 'false' }}"
drawio-enabled="{{ config('services.drawio') ? 'true' : 'false' }}" drawio-enabled="{{ config('services.drawio') ? 'true' : 'false' }}"
editor-type="{{ setting('app-editor') }}" editor-type="{{ setting('app-editor') }}"
page-id="{{ $model->id or 0 }}" page-id="{{ $model->id ?? 0 }}"
text-direction="{{ config('app.rtl') ? 'rtl' : 'ltr' }}" text-direction="{{ config('app.rtl') ? 'rtl' : 'ltr' }}"
page-new-draft="{{ $model->draft or 0 }}" page-new-draft="{{ $model->draft ?? 0 }}"
page-update-draft="{{ $model->isDraft or 0 }}"> page-update-draft="{{ $model->isDraft ?? 0 }}">
{{ csrf_field() }} {{ csrf_field() }}

View File

@ -197,11 +197,11 @@ class EntitySearchTest extends TestCase
$pageSearch = $this->get('/ajax/search/entities?term=' . urlencode($page->name)); $pageSearch = $this->get('/ajax/search/entities?term=' . urlencode($page->name));
$pageSearch->assertSee($page->name); $pageSearch->assertSee($page->name);
$pageSearch->assertSee($chapter->getShortName()); $pageSearch->assertSee($chapter->getShortName(42));
$pageSearch->assertSee($page->book->getShortName()); $pageSearch->assertSee($page->book->getShortName(42));
$chapterSearch = $this->get('/ajax/search/entities?term=' . urlencode($chapter->name)); $chapterSearch = $this->get('/ajax/search/entities?term=' . urlencode($chapter->name));
$chapterSearch->assertSee($chapter->name); $chapterSearch->assertSee($chapter->name);
$chapterSearch->assertSee($chapter->book->getShortName()); $chapterSearch->assertSee($chapter->book->getShortName(42));
} }
} }

View File

@ -65,9 +65,7 @@ class EntityTest extends BrowserKitTest
->click('Sort') ->click('Sort')
->seePageIs($bookToSort->getUrl() . '/sort') ->seePageIs($bookToSort->getUrl() . '/sort')
->seeStatusCode(200) ->seeStatusCode(200)
->see($bookToSort->name) ->see($bookToSort->name);
// Ensure page shows other books
->see($books[1]->name);
} }
public function test_book_sort_item_returns_book_content() public function test_book_sort_item_returns_book_content()
@ -224,15 +222,6 @@ class EntityTest extends BrowserKitTest
->click('Revisions')->seeStatusCode(200); ->click('Revisions')->seeStatusCode(200);
} }
public function test_recently_created_pages_view()
{
$user = $this->getEditor();
$content = $this->createEntityChainBelongingToUser($user);
$this->asAdmin()->visit('/pages/recently-created')
->seeInNthElement('.entity-list .page', 0, $content['page']->name);
}
public function test_recently_updated_pages_view() public function test_recently_updated_pages_view()
{ {
$user = $this->getEditor(); $user = $this->getEditor();

View File

@ -87,13 +87,13 @@ class PageDraftTest extends BrowserKitTest
->visit($book->getUrl() . '/create-page') ->visit($book->getUrl() . '/create-page')
->visit($chapter->getUrl() . '/create-page') ->visit($chapter->getUrl() . '/create-page')
->visit($book->getUrl()) ->visit($book->getUrl())
->seeInElement('.page-list', 'New Page'); ->seeInElement('.book-contents', 'New Page');
$this->asAdmin() $this->asAdmin()
->visit($book->getUrl()) ->visit($book->getUrl())
->dontSeeInElement('.page-list', 'New Page') ->dontSeeInElement('.book-contents', 'New Page')
->visit($chapter->getUrl()) ->visit($chapter->getUrl())
->dontSeeInElement('.page-list', 'New Page'); ->dontSeeInElement('.book-contents', 'New Page');
} }
} }

View File

@ -62,7 +62,7 @@ class HomepageTest extends TestCase
$this->asEditor(); $this->asEditor();
$homeVisit = $this->get('/'); $homeVisit = $this->get('/');
$homeVisit->assertSee('Books'); $homeVisit->assertSee('Books');
$homeVisit->assertSee('book-grid-item grid-card'); $homeVisit->assertSee('grid-card');
$homeVisit->assertSee('grid-card-content'); $homeVisit->assertSee('grid-card-content');
$homeVisit->assertSee('grid-card-footer'); $homeVisit->assertSee('grid-card-footer');
$homeVisit->assertSee('featured-image-container'); $homeVisit->assertSee('featured-image-container');

View File

@ -131,12 +131,12 @@ class RestrictionsTest extends BrowserKitTest
$bookUrl = $book->getUrl(); $bookUrl = $book->getUrl();
$this->actingAs($this->viewer) $this->actingAs($this->viewer)
->visit($bookUrl) ->visit($bookUrl)
->dontSeeInElement('.action-buttons', 'New Page') ->dontSeeInElement('.actions', 'New Page')
->dontSeeInElement('.action-buttons', 'New Chapter'); ->dontSeeInElement('.actions', 'New Chapter');
$this->actingAs($this->user) $this->actingAs($this->user)
->visit($bookUrl) ->visit($bookUrl)
->seeInElement('.action-buttons', 'New Page') ->seeInElement('.actions', 'New Page')
->seeInElement('.action-buttons', 'New Chapter'); ->seeInElement('.actions', 'New Chapter');
$this->setEntityRestrictions($book, ['view', 'delete', 'update']); $this->setEntityRestrictions($book, ['view', 'delete', 'update']);
@ -144,8 +144,8 @@ class RestrictionsTest extends BrowserKitTest
->see('You do not have permission')->seePageIs('/'); ->see('You do not have permission')->seePageIs('/');
$this->forceVisit($bookUrl . '/create-page') $this->forceVisit($bookUrl . '/create-page')
->see('You do not have permission')->seePageIs('/'); ->see('You do not have permission')->seePageIs('/');
$this->visit($bookUrl)->dontSeeInElement('.action-buttons', 'New Page') $this->visit($bookUrl)->dontSeeInElement('.actions', 'New Page')
->dontSeeInElement('.action-buttons', 'New Chapter'); ->dontSeeInElement('.actions', 'New Chapter');
$this->setEntityRestrictions($book, ['view', 'create']); $this->setEntityRestrictions($book, ['view', 'create']);
@ -159,8 +159,8 @@ class RestrictionsTest extends BrowserKitTest
->type('test content', 'html') ->type('test content', 'html')
->press('Save Page') ->press('Save Page')
->seePageIs($bookUrl . '/page/test-page'); ->seePageIs($bookUrl . '/page/test-page');
$this->visit($bookUrl)->seeInElement('.action-buttons', 'New Page') $this->visit($bookUrl)->seeInElement('.actions', 'New Page')
->seeInElement('.action-buttons', 'New Chapter'); ->seeInElement('.actions', 'New Chapter');
} }
public function test_book_update_restriction() public function test_book_update_restriction()
@ -255,13 +255,13 @@ class RestrictionsTest extends BrowserKitTest
$chapterUrl = $chapter->getUrl(); $chapterUrl = $chapter->getUrl();
$this->actingAs($this->user) $this->actingAs($this->user)
->visit($chapterUrl) ->visit($chapterUrl)
->seeInElement('.action-buttons', 'New Page'); ->seeInElement('.actions', 'New Page');
$this->setEntityRestrictions($chapter, ['view', 'delete', 'update']); $this->setEntityRestrictions($chapter, ['view', 'delete', 'update']);
$this->forceVisit($chapterUrl . '/create-page') $this->forceVisit($chapterUrl . '/create-page')
->see('You do not have permission')->seePageIs('/'); ->see('You do not have permission')->seePageIs('/');
$this->visit($chapterUrl)->dontSeeInElement('.action-buttons', 'New Page'); $this->visit($chapterUrl)->dontSeeInElement('.actions', 'New Page');
$this->setEntityRestrictions($chapter, ['view', 'create']); $this->setEntityRestrictions($chapter, ['view', 'create']);
@ -272,7 +272,7 @@ class RestrictionsTest extends BrowserKitTest
->press('Save Page') ->press('Save Page')
->seePageIs($chapter->book->getUrl() . '/page/test-page'); ->seePageIs($chapter->book->getUrl() . '/page/test-page');
$this->visit($chapterUrl)->seeInElement('.action-buttons', 'New Page'); $this->visit($chapterUrl)->seeInElement('.actions', 'New Page');
} }
public function test_chapter_update_restriction() public function test_chapter_update_restriction()
@ -535,8 +535,8 @@ class RestrictionsTest extends BrowserKitTest
$bookUrl = $book->getUrl(); $bookUrl = $book->getUrl();
$this->actingAs($this->viewer) $this->actingAs($this->viewer)
->visit($bookUrl) ->visit($bookUrl)
->dontSeeInElement('.action-buttons', 'New Page') ->dontSeeInElement('.actions', 'New Page')
->dontSeeInElement('.action-buttons', 'New Chapter'); ->dontSeeInElement('.actions', 'New Chapter');
$this->setEntityRestrictions($book, ['view', 'delete', 'update']); $this->setEntityRestrictions($book, ['view', 'delete', 'update']);
@ -544,8 +544,8 @@ class RestrictionsTest extends BrowserKitTest
->see('You do not have permission')->seePageIs('/'); ->see('You do not have permission')->seePageIs('/');
$this->forceVisit($bookUrl . '/create-page') $this->forceVisit($bookUrl . '/create-page')
->see('You do not have permission')->seePageIs('/'); ->see('You do not have permission')->seePageIs('/');
$this->visit($bookUrl)->dontSeeInElement('.action-buttons', 'New Page') $this->visit($bookUrl)->dontSeeInElement('.actions', 'New Page')
->dontSeeInElement('.action-buttons', 'New Chapter'); ->dontSeeInElement('.actions', 'New Chapter');
$this->setEntityRestrictions($book, ['view', 'create']); $this->setEntityRestrictions($book, ['view', 'create']);
@ -559,8 +559,8 @@ class RestrictionsTest extends BrowserKitTest
->type('test content', 'html') ->type('test content', 'html')
->press('Save Page') ->press('Save Page')
->seePageIs($bookUrl . '/page/test-page'); ->seePageIs($bookUrl . '/page/test-page');
$this->visit($bookUrl)->seeInElement('.action-buttons', 'New Page') $this->visit($bookUrl)->seeInElement('.actions', 'New Page')
->seeInElement('.action-buttons', 'New Chapter'); ->seeInElement('.actions', 'New Chapter');
} }
public function test_book_update_restriction_override() public function test_book_update_restriction_override()
@ -645,11 +645,9 @@ class RestrictionsTest extends BrowserKitTest
{ {
$firstBook = Book::first(); $firstBook = Book::first();
$secondBook = Book::find(2); $secondBook = Book::find(2);
$thirdBook = Book::find(3);
$this->setEntityRestrictions($firstBook, ['view', 'update']); $this->setEntityRestrictions($firstBook, ['view', 'update']);
$this->setEntityRestrictions($secondBook, ['view']); $this->setEntityRestrictions($secondBook, ['view']);
$this->setEntityRestrictions($thirdBook, ['view', 'update']);
// Test sort page visibility // Test sort page visibility
$this->actingAs($this->user)->visit($secondBook->getUrl() . '/sort') $this->actingAs($this->user)->visit($secondBook->getUrl() . '/sort')
@ -657,9 +655,7 @@ class RestrictionsTest extends BrowserKitTest
->seePageIs('/'); ->seePageIs('/');
// Check sort page on first book // Check sort page on first book
$this->actingAs($this->user)->visit($firstBook->getUrl() . '/sort') $this->actingAs($this->user)->visit($firstBook->getUrl() . '/sort');
->see($thirdBook->name)
->dontSee($secondBook->name);
} }
public function test_book_sort_permission() { public function test_book_sort_permission() {

View File

@ -632,8 +632,8 @@ class RolesTest extends BrowserKitTest
{ {
$user = \BookStack\Auth\User::first(); $user = \BookStack\Auth\User::first();
$this->asAdmin()->visit('/settings/users/' . $user->id) $this->asAdmin()->visit('/settings/users/' . $user->id)
->seeElement('#roles-admin') ->seeElement('[name="roles[admin]"]')
->seeElement('#roles-public'); ->seeElement('[name="roles[public]"]');
} }
public function test_public_role_visible_in_role_listing() public function test_public_role_visible_in_role_listing()

View File

@ -59,9 +59,9 @@ class UserProfileTest extends BrowserKitTest
\Activity::add($entities['page'], 'page_create', $entities['book']->id); \Activity::add($entities['page'], 'page_create', $entities['book']->id);
$this->asAdmin()->visit('/user/' . $newUser->id) $this->asAdmin()->visit('/user/' . $newUser->id)
->seeInElement('#recent-activity', 'updated book') ->seeInElement('#recent-user-activity', 'updated book')
->seeInElement('#recent-activity', 'created page') ->seeInElement('#recent-user-activity', 'created page')
->seeInElement('#recent-activity', $entities['page']->name); ->seeInElement('#recent-user-activity', $entities['page']->name);
} }
public function test_clicking_user_name_in_activity_leads_to_profile_page() public function test_clicking_user_name_in_activity_leads_to_profile_page()
@ -103,7 +103,7 @@ class UserProfileTest extends BrowserKitTest
$this->actingAs($editor) $this->actingAs($editor)
->visit('/books') ->visit('/books')
->pageNotHasElement('.featured-image-container') ->pageNotHasElement('.featured-image-container')
->pageHasElement('.content .entity-list-item'); ->pageHasElement('.content-wrap .entity-list-item');
} }
public function test_books_view_is_grid() public function test_books_view_is_grid()