Removed test web route, extracted text, added test

This commit is contained in:
Dan Brown 2022-07-17 10:18:24 +01:00
parent 8f90996cef
commit e6e6d25974
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
4 changed files with 18 additions and 9 deletions

View file

@ -24,6 +24,7 @@ return [
'meta_updated_name' => 'Updated :timeLength by :user',
'meta_owned_name' => 'Owned by :user',
'entity_select' => 'Entity Select',
'entity_select_lack_permission' => 'You don\'t have the required permissions to select this item',
'images' => 'Images',
'my_recent_drafts' => 'My Recent Drafts',
'my_recently_viewed' => 'My Recently Viewed',

View file

@ -4,7 +4,7 @@
@if($locked ?? false)
<div class="text-warn my-xxs bold">
@icon('lock')You don't have the required permissions to select this item.
@icon('lock'){{ trans('entities.entity_select_lack_permission') }}
</div>
@endif

View file

@ -38,13 +38,6 @@ use Illuminate\View\Middleware\ShareErrorsFromSession;
Route::get('/status', [StatusController::class, 'show']);
Route::get('/robots.txt', [HomeController::class, 'robots']);
Route::get('/test', function() {
$book = \BookStack\Entities\Models\Book::query()->where('slug', '=', 'k5TrhXxaNb')->firstOrFail();
$builder= app()->make(\BookStack\Auth\Permissions\JointPermissionBuilder::class);
$builder->rebuildForEntity($book);
return 'finished';
})->withoutMiddleware('web');
// Authenticated routes...
Route::middleware('auth')->group(function () {

View file

@ -214,7 +214,7 @@ class EntitySearchTest extends TestCase
$defaultListTest->assertDontSee($notVisitedPage->name);
}
public function test_ajax_entity_serach_shows_breadcrumbs()
public function test_ajax_entity_search_shows_breadcrumbs()
{
$chapter = Chapter::first();
$page = $chapter->pages->first();
@ -230,6 +230,21 @@ class EntitySearchTest extends TestCase
$chapterSearch->assertSee($chapter->book->getShortName(42));
}
public function test_ajax_entity_search_reflects_items_without_permission()
{
$page = Page::query()->first();
$baseSelector = 'a[data-entity-type="page"][data-entity-id="' . $page->id . '"]';
$searchUrl = "/ajax/search/entities?permission=update&term=" . urlencode($page->name);
$resp = $this->asEditor()->get($searchUrl);
$resp->assertElementContains($baseSelector, $page->name);
$resp->assertElementNotContains($baseSelector, "You don't have the required permissions to select this item");
$resp = $this->actingAs($this->getViewer())->get($searchUrl);
$resp->assertElementContains($baseSelector, $page->name);
$resp->assertElementContains($baseSelector, "You don't have the required permissions to select this item");
}
public function test_sibling_search_for_pages()
{
$chapter = Chapter::query()->with('pages')->first();