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()
{
return view('partials/custom-head-content');
return view('partials.custom-head-content');
}
/**
@ -138,7 +138,7 @@ class HomeController extends Controller
$allowRobots = $sitePublic;
}
return response()
->view('common/robots', ['allowRobots' => $allowRobots])
->view('common.robots', ['allowRobots' => $allowRobots])
->header('Content-Type', 'text/plain');
}
@ -147,6 +147,6 @@ class HomeController extends Controller
*/
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 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="text-center">

View File

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

View File

@ -6,7 +6,7 @@
<div class="card">
<h3 class="text-muted">{{ trans('errors.error_occurred') }}</h3>
<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>
</div>
</div>

View File

@ -17,7 +17,7 @@
</div>
@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>
<div class="padded files">

View File

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

View File

@ -197,11 +197,11 @@ class EntitySearchTest extends TestCase
$pageSearch = $this->get('/ajax/search/entities?term=' . urlencode($page->name));
$pageSearch->assertSee($page->name);
$pageSearch->assertSee($chapter->getShortName());
$pageSearch->assertSee($page->book->getShortName());
$pageSearch->assertSee($chapter->getShortName(42));
$pageSearch->assertSee($page->book->getShortName(42));
$chapterSearch = $this->get('/ajax/search/entities?term=' . urlencode($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')
->seePageIs($bookToSort->getUrl() . '/sort')
->seeStatusCode(200)
->see($bookToSort->name)
// Ensure page shows other books
->see($books[1]->name);
->see($bookToSort->name);
}
public function test_book_sort_item_returns_book_content()
@ -224,15 +222,6 @@ class EntityTest extends BrowserKitTest
->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()
{
$user = $this->getEditor();

View File

@ -87,13 +87,13 @@ class PageDraftTest extends BrowserKitTest
->visit($book->getUrl() . '/create-page')
->visit($chapter->getUrl() . '/create-page')
->visit($book->getUrl())
->seeInElement('.page-list', 'New Page');
->seeInElement('.book-contents', 'New Page');
$this->asAdmin()
->visit($book->getUrl())
->dontSeeInElement('.page-list', 'New Page')
->dontSeeInElement('.book-contents', 'New Page')
->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();
$homeVisit = $this->get('/');
$homeVisit->assertSee('Books');
$homeVisit->assertSee('book-grid-item grid-card');
$homeVisit->assertSee('grid-card');
$homeVisit->assertSee('grid-card-content');
$homeVisit->assertSee('grid-card-footer');
$homeVisit->assertSee('featured-image-container');

View File

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

View File

@ -632,8 +632,8 @@ class RolesTest extends BrowserKitTest
{
$user = \BookStack\Auth\User::first();
$this->asAdmin()->visit('/settings/users/' . $user->id)
->seeElement('#roles-admin')
->seeElement('#roles-public');
->seeElement('[name="roles[admin]"]')
->seeElement('[name="roles[public]"]');
}
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);
$this->asAdmin()->visit('/user/' . $newUser->id)
->seeInElement('#recent-activity', 'updated book')
->seeInElement('#recent-activity', 'created page')
->seeInElement('#recent-activity', $entities['page']->name);
->seeInElement('#recent-user-activity', 'updated book')
->seeInElement('#recent-user-activity', 'created page')
->seeInElement('#recent-user-activity', $entities['page']->name);
}
public function test_clicking_user_name_in_activity_leads_to_profile_page()
@ -103,7 +103,7 @@ class UserProfileTest extends BrowserKitTest
$this->actingAs($editor)
->visit('/books')
->pageNotHasElement('.featured-image-container')
->pageHasElement('.content .entity-list-item');
->pageHasElement('.content-wrap .entity-list-item');
}
public function test_books_view_is_grid()