mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-07 23:03:00 +03:00
@@ -18,21 +18,21 @@ class BookShelfTest extends TestCase
|
||||
{
|
||||
$viewer = $this->getViewer();
|
||||
$resp = $this->actingAs($viewer)->get('/');
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementContains('header', 'Shelves');
|
||||
|
||||
$viewer->roles()->delete();
|
||||
$this->giveUserPermissions($viewer);
|
||||
$resp = $this->actingAs($viewer)->get('/');
|
||||
$resp->assertElementNotContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementNotContains('header', 'Shelves');
|
||||
|
||||
$this->giveUserPermissions($viewer, ['bookshelf-view-all']);
|
||||
$resp = $this->actingAs($viewer)->get('/');
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementContains('header', 'Shelves');
|
||||
|
||||
$viewer->roles()->delete();
|
||||
$this->giveUserPermissions($viewer, ['bookshelf-view-own']);
|
||||
$resp = $this->actingAs($viewer)->get('/');
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementContains('header', 'Shelves');
|
||||
}
|
||||
|
||||
public function test_shelves_shows_in_header_if_have_any_shelve_view_permission()
|
||||
@@ -43,18 +43,18 @@ class BookShelfTest extends TestCase
|
||||
$userRole = $user->roles()->first();
|
||||
|
||||
$resp = $this->actingAs($user)->get('/');
|
||||
$resp->assertElementNotContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementNotContains('header', 'Shelves');
|
||||
|
||||
$this->setEntityRestrictions($shelf, ['view'], [$userRole]);
|
||||
|
||||
$resp = $this->get('/');
|
||||
$resp->assertElementContains('header', 'Shelves');
|
||||
$this->withHtml($resp)->assertElementContains('header', 'Shelves');
|
||||
}
|
||||
|
||||
public function test_shelves_page_contains_create_link()
|
||||
{
|
||||
$resp = $this->asEditor()->get('/shelves');
|
||||
$resp->assertElementContains('a', 'New Shelf');
|
||||
$this->withHtml($resp)->assertElementContains('a', 'New Shelf');
|
||||
}
|
||||
|
||||
public function test_book_not_visible_in_shelf_list_view_if_user_cant_view_shelf()
|
||||
@@ -100,8 +100,8 @@ class BookShelfTest extends TestCase
|
||||
$shelfPage = $this->get($shelf->getUrl());
|
||||
$shelfPage->assertSee($shelfInfo['name']);
|
||||
$shelfPage->assertSee($shelfInfo['description']);
|
||||
$shelfPage->assertElementContains('.tag-item', 'Test Category');
|
||||
$shelfPage->assertElementContains('.tag-item', 'Test Tag Value');
|
||||
$this->withHtml($shelfPage)->assertElementContains('.tag-item', 'Test Category');
|
||||
$this->withHtml($shelfPage)->assertElementContains('.tag-item', 'Test Tag Value');
|
||||
|
||||
$this->assertDatabaseHas('bookshelves_books', ['bookshelf_id' => $shelf->id, 'book_id' => $booksToInclude[0]->id]);
|
||||
$this->assertDatabaseHas('bookshelves_books', ['bookshelf_id' => $shelf->id, 'book_id' => $booksToInclude[1]->id]);
|
||||
@@ -148,10 +148,10 @@ class BookShelfTest extends TestCase
|
||||
$resp->assertSee($shelf->getUrl('/edit'));
|
||||
$resp->assertSee($shelf->getUrl('/permissions'));
|
||||
$resp->assertSee($shelf->getUrl('/delete'));
|
||||
$resp->assertElementContains('a', 'New Book');
|
||||
$resp->assertElementContains('a', 'Edit');
|
||||
$resp->assertElementContains('a', 'Permissions');
|
||||
$resp->assertElementContains('a', 'Delete');
|
||||
$this->withHtml($resp)->assertElementContains('a', 'New Book');
|
||||
$this->withHtml($resp)->assertElementContains('a', 'Edit');
|
||||
$this->withHtml($resp)->assertElementContains('a', 'Permissions');
|
||||
$this->withHtml($resp)->assertElementContains('a', 'Delete');
|
||||
|
||||
$resp = $this->asEditor()->get($shelf->getUrl());
|
||||
$resp->assertDontSee($shelf->getUrl('/permissions'));
|
||||
@@ -161,8 +161,8 @@ class BookShelfTest extends TestCase
|
||||
{
|
||||
$shelf = Bookshelf::query()->first();
|
||||
$resp = $this->asAdmin()->get($shelf->getUrl());
|
||||
$resp->assertElementExists('form[action$="change-sort/shelf_books"]');
|
||||
$resp->assertElementContains('form[action$="change-sort/shelf_books"] [aria-haspopup="true"]', 'Default');
|
||||
$this->withHtml($resp)->assertElementExists('form[action$="change-sort/shelf_books"]');
|
||||
$this->withHtml($resp)->assertElementContains('form[action$="change-sort/shelf_books"] [aria-haspopup="true"]', 'Default');
|
||||
}
|
||||
|
||||
public function test_shelf_view_sort_takes_action()
|
||||
@@ -182,20 +182,20 @@ class BookShelfTest extends TestCase
|
||||
$shelf->refresh();
|
||||
|
||||
$resp = $this->asEditor()->get($shelf->getUrl());
|
||||
$resp->assertElementContains('.book-content a.grid-card', $books[0]->name, 1);
|
||||
$resp->assertElementNotContains('.book-content a.grid-card', $books[0]->name, 3);
|
||||
$this->withHtml($resp)->assertElementContains('.book-content a.grid-card:nth-child(1)', $books[0]->name);
|
||||
$this->withHtml($resp)->assertElementNotContains('.book-content a.grid-card:nth-child(3)', $books[0]->name);
|
||||
|
||||
setting()->putUser($this->getEditor(), 'shelf_books_sort_order', 'desc');
|
||||
$resp = $this->asEditor()->get($shelf->getUrl());
|
||||
$resp->assertElementNotContains('.book-content a.grid-card', $books[0]->name, 1);
|
||||
$resp->assertElementContains('.book-content a.grid-card', $books[0]->name, 3);
|
||||
$this->withHtml($resp)->assertElementNotContains('.book-content a.grid-card:nth-child(1)', $books[0]->name);
|
||||
$this->withHtml($resp)->assertElementContains('.book-content a.grid-card:nth-child(3)', $books[0]->name);
|
||||
|
||||
setting()->putUser($this->getEditor(), 'shelf_books_sort_order', 'desc');
|
||||
setting()->putUser($this->getEditor(), 'shelf_books_sort', 'name');
|
||||
$resp = $this->asEditor()->get($shelf->getUrl());
|
||||
$resp->assertElementContains('.book-content a.grid-card', 'hdgfgdfg', 1);
|
||||
$resp->assertElementContains('.book-content a.grid-card', 'bsfsdfsdfsd', 2);
|
||||
$resp->assertElementContains('.book-content a.grid-card', 'adsfsdfsdfsd', 3);
|
||||
$this->withHtml($resp)->assertElementContains('.book-content a.grid-card:nth-child(1)', 'hdgfgdfg');
|
||||
$this->withHtml($resp)->assertElementContains('.book-content a.grid-card:nth-child(2)', 'bsfsdfsdfsd');
|
||||
$this->withHtml($resp)->assertElementContains('.book-content a.grid-card:nth-child(3)', 'adsfsdfsdfsd');
|
||||
}
|
||||
|
||||
public function test_shelf_edit()
|
||||
@@ -229,8 +229,8 @@ class BookShelfTest extends TestCase
|
||||
$shelfPage = $this->get($shelf->getUrl());
|
||||
$shelfPage->assertSee($shelfInfo['name']);
|
||||
$shelfPage->assertSee($shelfInfo['description']);
|
||||
$shelfPage->assertElementContains('.tag-item', 'Test Category');
|
||||
$shelfPage->assertElementContains('.tag-item', 'Test Tag Value');
|
||||
$this->withHtml($shelfPage)->assertElementContains('.tag-item', 'Test Category');
|
||||
$this->withHtml($shelfPage)->assertElementContains('.tag-item', 'Test Tag Value');
|
||||
|
||||
$this->assertDatabaseHas('bookshelves_books', ['bookshelf_id' => $shelf->id, 'book_id' => $booksToInclude[0]->id]);
|
||||
$this->assertDatabaseHas('bookshelves_books', ['bookshelf_id' => $shelf->id, 'book_id' => $booksToInclude[1]->id]);
|
||||
@@ -282,7 +282,7 @@ class BookShelfTest extends TestCase
|
||||
$this->assertTrue($shelf->deletions()->count() === 1);
|
||||
|
||||
$redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
|
||||
$redirectReq->assertNotificationContains('Bookshelf Successfully Deleted');
|
||||
$this->assertNotificationContains($redirectReq, 'Bookshelf Successfully Deleted');
|
||||
}
|
||||
|
||||
public function test_shelf_copy_permissions()
|
||||
@@ -323,22 +323,22 @@ class BookShelfTest extends TestCase
|
||||
$this->asAdmin();
|
||||
|
||||
$bookVisit = $this->get($shelfBook->getUrl());
|
||||
$bookVisit->assertElementNotContains('.breadcrumbs', 'Shelves');
|
||||
$bookVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
||||
$this->withHtml($bookVisit)->assertElementNotContains('.breadcrumbs', 'Shelves');
|
||||
$this->withHtml($bookVisit)->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
||||
|
||||
$this->get($shelf->getUrl());
|
||||
$bookVisit = $this->get($shelfBook->getUrl());
|
||||
$bookVisit->assertElementContains('.breadcrumbs', 'Shelves');
|
||||
$bookVisit->assertElementContains('.breadcrumbs', $shelf->getShortName());
|
||||
$this->withHtml($bookVisit)->assertElementContains('.breadcrumbs', 'Shelves');
|
||||
$this->withHtml($bookVisit)->assertElementContains('.breadcrumbs', $shelf->getShortName());
|
||||
|
||||
$pageVisit = $this->get($shelfPage->getUrl());
|
||||
$pageVisit->assertElementContains('.breadcrumbs', 'Shelves');
|
||||
$pageVisit->assertElementContains('.breadcrumbs', $shelf->getShortName());
|
||||
$this->withHtml($pageVisit)->assertElementContains('.breadcrumbs', 'Shelves');
|
||||
$this->withHtml($pageVisit)->assertElementContains('.breadcrumbs', $shelf->getShortName());
|
||||
|
||||
$this->get('/books');
|
||||
$pageVisit = $this->get($shelfPage->getUrl());
|
||||
$pageVisit->assertElementNotContains('.breadcrumbs', 'Shelves');
|
||||
$pageVisit->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
||||
$this->withHtml($pageVisit)->assertElementNotContains('.breadcrumbs', 'Shelves');
|
||||
$this->withHtml($pageVisit)->assertElementNotContains('.breadcrumbs', $shelf->getShortName());
|
||||
}
|
||||
|
||||
public function test_bookshelves_show_on_book()
|
||||
@@ -361,7 +361,7 @@ class BookShelfTest extends TestCase
|
||||
$newBook = Book::query()->orderBy('id', 'desc')->first();
|
||||
|
||||
$resp = $this->asEditor()->get($newBook->getUrl());
|
||||
$resp->assertElementContains('.tri-layout-left-contents', $shelfInfo['name']);
|
||||
$this->withHtml($resp)->assertElementContains('.tri-layout-left-contents', $shelfInfo['name']);
|
||||
|
||||
// Remove shelf
|
||||
$this->delete($shelf->getUrl());
|
||||
@@ -375,6 +375,6 @@ class BookShelfTest extends TestCase
|
||||
/** @var Bookshelf $shelf */
|
||||
$shelf = Bookshelf::query()->first();
|
||||
$resp = $this->asEditor()->get($shelf->getUrl('/create-book'));
|
||||
$resp->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel');
|
||||
$this->withHtml($resp)->assertElementContains('form a[href="' . $shelf->getUrl() . '"]', 'Cancel');
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,10 @@ class BookTest extends TestCase
|
||||
]);
|
||||
|
||||
$resp = $this->asEditor()->get('/books');
|
||||
$resp->assertElementContains('a[href="' . url('/create-book') . '"]', 'Create New Book');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . url('/create-book') . '"]', 'Create New Book');
|
||||
|
||||
$resp = $this->get('/create-book');
|
||||
$resp->assertElementContains('form[action="' . url('/books') . '"][method="POST"]', 'Save Book');
|
||||
$this->withHtml($resp)->assertElementContains('form[action="' . url('/books') . '"][method="POST"]', 'Save Book');
|
||||
|
||||
$resp = $this->post('/books', $book->only('name', 'description'));
|
||||
$resp->assertRedirect('/books/my-first-book');
|
||||
@@ -91,7 +91,7 @@ class BookTest extends TestCase
|
||||
$resp = $this->get($book->getUrl('/edit'));
|
||||
$resp->assertSee($book->name);
|
||||
$resp->assertSee($book->description);
|
||||
$resp->assertElementContains('form[action="' . $book->getUrl() . '"]', 'Save Book');
|
||||
$this->withHtml($resp)->assertElementContains('form[action="' . $book->getUrl() . '"]', 'Save Book');
|
||||
|
||||
$resp = $this->put($book->getUrl(), ['name' => $newName, 'description' => $newDesc]);
|
||||
$resp->assertRedirect($book->getUrl() . '-updated');
|
||||
@@ -155,13 +155,13 @@ class BookTest extends TestCase
|
||||
$this->assertTrue($book->deletions()->count() === 1);
|
||||
|
||||
$redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
|
||||
$redirectReq->assertNotificationContains('Book Successfully Deleted');
|
||||
$this->assertNotificationContains($redirectReq, 'Book Successfully Deleted');
|
||||
}
|
||||
|
||||
public function test_cancel_on_create_page_leads_back_to_books_listing()
|
||||
{
|
||||
$resp = $this->asEditor()->get('/create-book');
|
||||
$resp->assertElementContains('form a[href="' . url('/books') . '"]', 'Cancel');
|
||||
$this->withHtml($resp)->assertElementContains('form a[href="' . url('/books') . '"]', 'Cancel');
|
||||
}
|
||||
|
||||
public function test_cancel_on_edit_book_page_leads_back_to_book()
|
||||
@@ -169,7 +169,7 @@ class BookTest extends TestCase
|
||||
/** @var Book $book */
|
||||
$book = Book::query()->first();
|
||||
$resp = $this->asEditor()->get($book->getUrl('/edit'));
|
||||
$resp->assertElementContains('form a[href="' . $book->getUrl() . '"]', 'Cancel');
|
||||
$this->withHtml($resp)->assertElementContains('form a[href="' . $book->getUrl() . '"]', 'Cancel');
|
||||
}
|
||||
|
||||
public function test_next_previous_navigation_controls_show_within_book_content()
|
||||
@@ -178,28 +178,28 @@ class BookTest extends TestCase
|
||||
$chapter = $book->chapters->first();
|
||||
|
||||
$resp = $this->asEditor()->get($chapter->getUrl());
|
||||
$resp->assertElementContains('#sibling-navigation', 'Next');
|
||||
$resp->assertElementContains('#sibling-navigation', substr($chapter->pages[0]->name, 0, 20));
|
||||
$this->withHtml($resp)->assertElementContains('#sibling-navigation', 'Next');
|
||||
$this->withHtml($resp)->assertElementContains('#sibling-navigation', substr($chapter->pages[0]->name, 0, 20));
|
||||
|
||||
$resp = $this->get($chapter->pages[0]->getUrl());
|
||||
$resp->assertElementContains('#sibling-navigation', substr($chapter->pages[1]->name, 0, 20));
|
||||
$resp->assertElementContains('#sibling-navigation', 'Previous');
|
||||
$resp->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
|
||||
$this->withHtml($resp)->assertElementContains('#sibling-navigation', substr($chapter->pages[1]->name, 0, 20));
|
||||
$this->withHtml($resp)->assertElementContains('#sibling-navigation', 'Previous');
|
||||
$this->withHtml($resp)->assertElementContains('#sibling-navigation', substr($chapter->name, 0, 20));
|
||||
}
|
||||
|
||||
public function test_recently_viewed_books_updates_as_expected()
|
||||
{
|
||||
$books = Book::all()->take(2);
|
||||
|
||||
$this->asAdmin()->get('/books')
|
||||
->assertElementNotContains('#recents', $books[0]->name)
|
||||
$resp = $this->asAdmin()->get('/books');
|
||||
$this->withHtml($resp)->assertElementNotContains('#recents', $books[0]->name)
|
||||
->assertElementNotContains('#recents', $books[1]->name);
|
||||
|
||||
$this->get($books[0]->getUrl());
|
||||
$this->get($books[1]->getUrl());
|
||||
|
||||
$this->get('/books')
|
||||
->assertElementContains('#recents', $books[0]->name)
|
||||
$resp = $this->get('/books');
|
||||
$this->withHtml($resp)->assertElementContains('#recents', $books[0]->name)
|
||||
->assertElementContains('#recents', $books[1]->name);
|
||||
}
|
||||
|
||||
@@ -207,16 +207,16 @@ class BookTest extends TestCase
|
||||
{
|
||||
$books = Book::all()->take(2);
|
||||
|
||||
$this->asAdmin()->get('/books')
|
||||
->assertElementNotContains('#popular', $books[0]->name)
|
||||
$resp = $this->asAdmin()->get('/books');
|
||||
$this->withHtml($resp)->assertElementNotContains('#popular', $books[0]->name)
|
||||
->assertElementNotContains('#popular', $books[1]->name);
|
||||
|
||||
$this->get($books[0]->getUrl());
|
||||
$this->get($books[1]->getUrl());
|
||||
$this->get($books[0]->getUrl());
|
||||
|
||||
$this->get('/books')
|
||||
->assertElementContains('#popular .book:nth-child(1)', $books[0]->name)
|
||||
$resp = $this->get('/books');
|
||||
$this->withHtml($resp)->assertElementContains('#popular .book:nth-child(1)', $books[0]->name)
|
||||
->assertElementContains('#popular .book:nth-child(2)', $books[1]->name);
|
||||
}
|
||||
|
||||
@@ -227,16 +227,16 @@ class BookTest extends TestCase
|
||||
setting()->putUser($editor, 'books_view_type', 'list');
|
||||
|
||||
$resp = $this->actingAs($editor)->get('/books');
|
||||
$resp->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'Grid View');
|
||||
$resp->assertElementExists('input[name="view_type"][value="grid"]');
|
||||
$this->withHtml($resp)->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'Grid View');
|
||||
$this->withHtml($resp)->assertElementExists('input[name="view_type"][value="grid"]');
|
||||
|
||||
$resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'grid']);
|
||||
$resp->assertRedirect();
|
||||
$this->assertEquals('grid', setting()->getUser($editor, 'books_view_type'));
|
||||
|
||||
$resp = $this->actingAs($editor)->get('/books');
|
||||
$resp->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'List View');
|
||||
$resp->assertElementExists('input[name="view_type"][value="list"]');
|
||||
$this->withHtml($resp)->assertElementContains('form[action$="/settings/users/' . $editor->id . '/switch-books-view"]', 'List View');
|
||||
$this->withHtml($resp)->assertElementExists('input[name="view_type"][value="list"]');
|
||||
|
||||
$resp = $this->patch("/settings/users/{$editor->id}/switch-books-view", ['view_type' => 'list']);
|
||||
$resp->assertRedirect();
|
||||
@@ -273,7 +273,7 @@ class BookTest extends TestCase
|
||||
$book = Book::query()->first();
|
||||
$resp = $this->asEditor()->get($book->getUrl());
|
||||
|
||||
$resp->assertElementContains("a[href=\"{$book->getUrl('/copy')}\"]", 'Copy');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"{$book->getUrl('/copy')}\"]", 'Copy');
|
||||
}
|
||||
|
||||
public function test_copy_view()
|
||||
@@ -284,7 +284,7 @@ class BookTest extends TestCase
|
||||
|
||||
$resp->assertOk();
|
||||
$resp->assertSee('Copy Book');
|
||||
$resp->assertElementExists("input[name=\"name\"][value=\"{$book->name}\"]");
|
||||
$this->withHtml($resp)->assertElementExists("input[name=\"name\"][value=\"{$book->name}\"]");
|
||||
}
|
||||
|
||||
public function test_copy()
|
||||
|
@@ -19,10 +19,10 @@ class ChapterTest extends TestCase
|
||||
]);
|
||||
|
||||
$resp = $this->asEditor()->get($book->getUrl());
|
||||
$resp->assertElementContains('a[href="' . $book->getUrl('/create-chapter') . '"]', 'New Chapter');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $book->getUrl('/create-chapter') . '"]', 'New Chapter');
|
||||
|
||||
$resp = $this->get($book->getUrl('/create-chapter'));
|
||||
$resp->assertElementContains('form[action="' . $book->getUrl('/create-chapter') . '"][method="POST"]', 'Save Chapter');
|
||||
$this->withHtml($resp)->assertElementContains('form[action="' . $book->getUrl('/create-chapter') . '"][method="POST"]', 'Save Chapter');
|
||||
|
||||
$resp = $this->post($book->getUrl('/create-chapter'), $chapter->only('name', 'description'));
|
||||
$resp->assertRedirect($book->getUrl('/chapter/my-first-chapter'));
|
||||
@@ -53,7 +53,7 @@ class ChapterTest extends TestCase
|
||||
$this->assertTrue($chapter->deletions()->count() === 1);
|
||||
|
||||
$redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
|
||||
$redirectReq->assertNotificationContains('Chapter Successfully Deleted');
|
||||
$this->assertNotificationContains($redirectReq, 'Chapter Successfully Deleted');
|
||||
}
|
||||
|
||||
public function test_show_view_has_copy_button()
|
||||
@@ -62,7 +62,7 @@ class ChapterTest extends TestCase
|
||||
$chapter = Chapter::query()->first();
|
||||
|
||||
$resp = $this->asEditor()->get($chapter->getUrl());
|
||||
$resp->assertElementContains("a[href$=\"{$chapter->getUrl('/copy')}\"]", 'Copy');
|
||||
$this->withHtml($resp)->assertElementContains("a[href$=\"{$chapter->getUrl('/copy')}\"]", 'Copy');
|
||||
}
|
||||
|
||||
public function test_copy_view()
|
||||
@@ -73,8 +73,8 @@ class ChapterTest extends TestCase
|
||||
$resp = $this->asEditor()->get($chapter->getUrl('/copy'));
|
||||
$resp->assertOk();
|
||||
$resp->assertSee('Copy Chapter');
|
||||
$resp->assertElementExists("input[name=\"name\"][value=\"{$chapter->name}\"]");
|
||||
$resp->assertElementExists('input[name="entity_selection"]');
|
||||
$this->withHtml($resp)->assertElementExists("input[name=\"name\"][value=\"{$chapter->name}\"]");
|
||||
$this->withHtml($resp)->assertElementExists('input[name="entity_selection"]');
|
||||
}
|
||||
|
||||
public function test_copy()
|
||||
|
@@ -20,8 +20,8 @@ class CommentSettingTest extends TestCase
|
||||
$this->setSettings(['app-disable-comments' => 'true']);
|
||||
$this->asAdmin();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl())
|
||||
->assertElementNotExists('.comments-list');
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl());
|
||||
$this->withHtml($resp)->assertElementNotExists('.comments-list');
|
||||
}
|
||||
|
||||
public function test_comment_enable()
|
||||
@@ -29,7 +29,7 @@ class CommentSettingTest extends TestCase
|
||||
$this->setSettings(['app-disable-comments' => 'false']);
|
||||
$this->asAdmin();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl())
|
||||
->assertElementExists('.comments-list');
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl());
|
||||
$this->withHtml($resp)->assertElementExists('.comments-list');
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ class ConvertTest extends TestCase
|
||||
$resp = $this->asEditor()->get($chapter->getUrl('/edit'));
|
||||
$resp->assertSee('Convert to Book');
|
||||
$resp->assertSee('Convert Chapter');
|
||||
$resp->assertElementExists('form[action$="/convert-to-book"] button');
|
||||
$this->withHtml($resp)->assertElementExists('form[action$="/convert-to-book"] button');
|
||||
}
|
||||
|
||||
public function test_convert_chapter_to_book()
|
||||
@@ -77,7 +77,7 @@ class ConvertTest extends TestCase
|
||||
$resp->assertSee('Convert to Shelf');
|
||||
$resp->assertSee('Convert Book');
|
||||
$resp->assertSee('Note that permissions on shelves do not auto-cascade to content');
|
||||
$resp->assertElementExists('form[action$="/convert-to-shelf"] button');
|
||||
$this->withHtml($resp)->assertElementExists('form[action$="/convert-to-shelf"] button');
|
||||
}
|
||||
|
||||
public function test_book_convert_to_shelf()
|
||||
|
@@ -237,12 +237,12 @@ class EntitySearchTest extends TestCase
|
||||
$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");
|
||||
$this->withHtml($resp)->assertElementContains($baseSelector, $page->name);
|
||||
$this->withHtml($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");
|
||||
$this->withHtml($resp)->assertElementContains($baseSelector, $page->name);
|
||||
$this->withHtml($resp)->assertElementContains($baseSelector, "You don't have the required permissions to select this item");
|
||||
}
|
||||
|
||||
public function test_sibling_search_for_pages()
|
||||
@@ -338,16 +338,16 @@ class EntitySearchTest extends TestCase
|
||||
$this->newPage(['name' => 'Test page B', 'html' => '<p>cat biscuit</p>']);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=cat+dog+biscuit');
|
||||
$search->assertElementContains('.entity-list > .page', 'Test page A', 1);
|
||||
$search->assertElementContains('.entity-list > .page', 'Test page B', 2);
|
||||
$this->withHtml($search)->assertElementContains('.entity-list > .page:nth-child(1)', 'Test page A');
|
||||
$this->withHtml($search)->assertElementContains('.entity-list > .page:nth-child(2)', 'Test page B');
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$this->newPage(['name' => 'Test page ' . $i, 'html' => '<p>dog</p>']);
|
||||
}
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=cat+dog+biscuit');
|
||||
$search->assertElementContains('.entity-list > .page', 'Test page B', 1);
|
||||
$search->assertElementContains('.entity-list > .page', 'Test page A', 2);
|
||||
$this->withHtml($search)->assertElementContains('.entity-list > .page:nth-child(1)', 'Test page B');
|
||||
$this->withHtml($search)->assertElementContains('.entity-list > .page:nth-child(2)', 'Test page A');
|
||||
}
|
||||
|
||||
public function test_terms_in_headers_have_an_adjusted_index_score()
|
||||
@@ -413,9 +413,9 @@ class EntitySearchTest extends TestCase
|
||||
// Content
|
||||
$search->assertSee('A <strong>superimportant</strong> page about <strong>meowie</strong>able animals', false);
|
||||
// Tag name
|
||||
$search->assertElementContains('.tag-name.highlight', 'SuperImportant');
|
||||
$this->withHtml($search)->assertElementContains('.tag-name.highlight', 'SuperImportant');
|
||||
// Tag value
|
||||
$search->assertElementContains('.tag-value.highlight', 'MeowieCat');
|
||||
$this->withHtml($search)->assertElementContains('.tag-value.highlight', 'MeowieCat');
|
||||
}
|
||||
|
||||
public function test_match_highlighting_works_with_multibyte_content()
|
||||
@@ -452,7 +452,7 @@ class EntitySearchTest extends TestCase
|
||||
public function test_searches_with_user_filters_adds_them_into_advanced_search_form()
|
||||
{
|
||||
$resp = $this->asEditor()->get('/search?term=' . urlencode('test {updated_by:me} {created_by:dan}'));
|
||||
$resp->assertElementExists('form input[type="hidden"][name="filters[updated_by]"][value="me"]');
|
||||
$resp->assertElementExists('form input[type="hidden"][name="filters[created_by]"][value="dan"]');
|
||||
$this->withHtml($resp)->assertElementExists('form input[type="hidden"][name="filters[updated_by]"][value="me"]');
|
||||
$this->withHtml($resp)->assertElementExists('form input[type="hidden"][name="filters[created_by]"][value="dan"]');
|
||||
}
|
||||
}
|
||||
|
@@ -454,7 +454,7 @@ class ExportTest extends TestCase
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$resp = $this->asEditor()->get($entity->getUrl('/export/html'));
|
||||
$resp->assertElementExists('head meta[http-equiv="Content-Security-Policy"][content*="script-src "]');
|
||||
$this->withHtml($resp)->assertElementExists('head meta[http-equiv="Content-Security-Policy"][content*="script-src "]');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,6 +463,6 @@ class ExportTest extends TestCase
|
||||
$page = Page::query()->first();
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertElementExists('body.export.export-format-html.export-engine-none');
|
||||
$this->withHtml($resp)->assertElementExists('body.export.export-format-html.export-engine-none');
|
||||
}
|
||||
}
|
||||
|
@@ -149,8 +149,8 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<script>');
|
||||
$pageView->assertElementNotContains('.page-content', '</script>');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<script>');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '</script>');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,13 +185,14 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<iframe>');
|
||||
$pageView->assertElementNotContains('.page-content', '<img');
|
||||
$pageView->assertElementNotContains('.page-content', '</iframe>');
|
||||
$pageView->assertElementNotContains('.page-content', 'src=');
|
||||
$pageView->assertElementNotContains('.page-content', 'javascript:');
|
||||
$pageView->assertElementNotContains('.page-content', 'data:');
|
||||
$pageView->assertElementNotContains('.page-content', 'base64');
|
||||
$html = $this->withHtml($pageView);
|
||||
$html->assertElementNotContains('.page-content', '<iframe>');
|
||||
$html->assertElementNotContains('.page-content', '<img');
|
||||
$html->assertElementNotContains('.page-content', '</iframe>');
|
||||
$html->assertElementNotContains('.page-content', 'src=');
|
||||
$html->assertElementNotContains('.page-content', 'javascript:');
|
||||
$html->assertElementNotContains('.page-content', 'data:');
|
||||
$html->assertElementNotContains('.page-content', 'base64');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,8 +214,8 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<a id="xss"');
|
||||
$pageView->assertElementNotContains('.page-content', 'href=javascript:');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<a id="xss"');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'href=javascript:');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,11 +238,11 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<button id="xss"');
|
||||
$pageView->assertElementNotContains('.page-content', '<input id="xss"');
|
||||
$pageView->assertElementNotContains('.page-content', '<form id="xss"');
|
||||
$pageView->assertElementNotContains('.page-content', 'action=javascript:');
|
||||
$pageView->assertElementNotContains('.page-content', 'formaction=javascript:');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<button id="xss"');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<input id="xss"');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<form id="xss"');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'action=javascript:');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'formaction=javascript:');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +263,10 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', '<meta>');
|
||||
$pageView->assertElementNotContains('.page-content', '</meta>');
|
||||
$pageView->assertElementNotContains('.page-content', 'content=');
|
||||
$pageView->assertElementNotContains('.page-content', 'external_url');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '<meta>');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', '</meta>');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'content=');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'external_url');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', 'onclick');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'onclick');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,9 +341,9 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertElementNotContains('.page-content', 'alert');
|
||||
$pageView->assertElementNotContains('.page-content', 'xlink:href');
|
||||
$pageView->assertElementNotContains('.page-content', 'application/xml');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'alert');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'xlink:href');
|
||||
$this->withHtml($pageView)->assertElementNotContains('.page-content', 'application/xml');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +507,7 @@ class PageContentTest extends TestCase
|
||||
$this->assertStringContainsString('</tbody>', $page->html);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertElementExists('.page-content table tbody td');
|
||||
$this->withHtml($pageView)->assertElementExists('.page-content table tbody td');
|
||||
}
|
||||
|
||||
public function test_page_markdown_task_list_rendering()
|
||||
@@ -526,8 +527,8 @@ class PageContentTest extends TestCase
|
||||
$this->assertStringContainsString('type="checkbox"', $page->html);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertElementExists('.page-content li.task-list-item input[type=checkbox]');
|
||||
$pageView->assertElementExists('.page-content li.task-list-item input[type=checkbox][checked]');
|
||||
$this->withHtml($pageView)->assertElementExists('.page-content li.task-list-item input[type=checkbox]');
|
||||
$this->withHtml($pageView)->assertElementExists('.page-content li.task-list-item input[type=checkbox][checked]');
|
||||
}
|
||||
|
||||
public function test_page_markdown_strikethrough_rendering()
|
||||
@@ -545,7 +546,7 @@ class PageContentTest extends TestCase
|
||||
$this->assertStringMatchesFormat('%A<s%A>some crossed out text</s>%A', $page->html);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertElementExists('.page-content p > s');
|
||||
$this->withHtml($pageView)->assertElementExists('.page-content p > s');
|
||||
}
|
||||
|
||||
public function test_page_markdown_single_html_comment_saving()
|
||||
|
@@ -31,27 +31,27 @@ class PageDraftTest extends TestCase
|
||||
{
|
||||
$addedContent = '<p>test message content</p>';
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementNotContains('[name="html"]', $addedContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementNotContains('[name="html"]', $addedContent);
|
||||
|
||||
$newContent = $this->page->html . $addedContent;
|
||||
$this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementContains('[name="html"]', $newContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementContains('[name="html"]', $newContent);
|
||||
}
|
||||
|
||||
public function test_draft_not_visible_by_others()
|
||||
{
|
||||
$addedContent = '<p>test message content</p>';
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementNotContains('[name="html"]', $addedContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementNotContains('[name="html"]', $addedContent);
|
||||
|
||||
$newContent = $this->page->html . $addedContent;
|
||||
$newUser = $this->getEditor();
|
||||
$this->pageRepo->updatePageDraft($this->page, ['html' => $newContent]);
|
||||
|
||||
$this->actingAs($newUser)->get($this->page->getUrl('/edit'))
|
||||
->assertElementNotContains('[name="html"]', $newContent);
|
||||
$resp = $this->actingAs($newUser)->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementNotContains('[name="html"]', $newContent);
|
||||
}
|
||||
|
||||
public function test_alert_message_shows_if_editing_draft()
|
||||
@@ -66,8 +66,8 @@ class PageDraftTest extends TestCase
|
||||
{
|
||||
$nonEditedPage = Page::query()->take(10)->get()->last();
|
||||
$addedContent = '<p>test message content</p>';
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementNotContains('[name="html"]', $addedContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementNotContains('[name="html"]', $addedContent);
|
||||
|
||||
$newContent = $this->page->html . $addedContent;
|
||||
$newUser = $this->getEditor();
|
||||
@@ -77,8 +77,8 @@ class PageDraftTest extends TestCase
|
||||
->get($this->page->getUrl('/edit'))
|
||||
->assertSee('Admin has started editing this page');
|
||||
$this->flushSession();
|
||||
$this->get($nonEditedPage->getUrl() . '/edit')
|
||||
->assertElementNotContains('.notification', 'Admin has started editing this page');
|
||||
$resp = $this->get($nonEditedPage->getUrl() . '/edit');
|
||||
$this->withHtml($resp)->assertElementNotContains('.notification', 'Admin has started editing this page');
|
||||
}
|
||||
|
||||
public function test_draft_save_shows_alert_if_draft_older_than_last_page_update()
|
||||
@@ -142,12 +142,12 @@ class PageDraftTest extends TestCase
|
||||
{
|
||||
/** @var Book $book */
|
||||
$book = Book::query()->first();
|
||||
$this->asAdmin()->get('/')
|
||||
->assertElementNotContains('#recent-drafts', 'New Page');
|
||||
$resp = $this->asAdmin()->get('/');
|
||||
$this->withHtml($resp)->assertElementNotContains('#recent-drafts', 'New Page');
|
||||
|
||||
$this->get($book->getUrl() . '/create-page');
|
||||
|
||||
$this->get('/')->assertElementContains('#recent-drafts', 'New Page');
|
||||
$this->withHtml($this->get('/'))->assertElementContains('#recent-drafts', 'New Page');
|
||||
}
|
||||
|
||||
public function test_draft_pages_not_visible_by_others()
|
||||
@@ -159,13 +159,13 @@ class PageDraftTest extends TestCase
|
||||
|
||||
$this->actingAs($newUser)->get($book->getUrl('/create-page'));
|
||||
$this->get($chapter->getUrl('/create-page'));
|
||||
$this->get($book->getUrl())
|
||||
->assertElementContains('.book-contents', 'New Page');
|
||||
$resp = $this->get($book->getUrl());
|
||||
$this->withHtml($resp)->assertElementContains('.book-contents', 'New Page');
|
||||
|
||||
$this->asAdmin()->get($book->getUrl())
|
||||
->assertElementNotContains('.book-contents', 'New Page');
|
||||
$this->get($chapter->getUrl())
|
||||
->assertElementNotContains('.book-contents', 'New Page');
|
||||
$resp = $this->asAdmin()->get($book->getUrl());
|
||||
$this->withHtml($resp)->assertElementNotContains('.book-contents', 'New Page');
|
||||
$resp = $this->get($chapter->getUrl());
|
||||
$this->withHtml($resp)->assertElementNotContains('.book-contents', 'New Page');
|
||||
}
|
||||
|
||||
public function test_page_html_in_ajax_fetch_response()
|
||||
|
@@ -22,7 +22,7 @@ class PageEditorTest extends TestCase
|
||||
{
|
||||
$this->assertEquals('wysiwyg', setting('app-editor'));
|
||||
$resp = $this->asAdmin()->get($this->page->book->getUrl('/create-page'));
|
||||
$this->followRedirects($resp)->assertElementExists('#html-editor');
|
||||
$this->withHtml($this->followRedirects($resp))->assertElementExists('#html-editor');
|
||||
}
|
||||
|
||||
public function test_markdown_setting_shows_markdown_editor_for_new_pages()
|
||||
@@ -30,7 +30,7 @@ class PageEditorTest extends TestCase
|
||||
$this->setSettings(['app-editor' => 'markdown']);
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->book->getUrl('/create-page'));
|
||||
$this->followRedirects($resp)
|
||||
$this->withHtml($this->followRedirects($resp))
|
||||
->assertElementNotExists('#html-editor')
|
||||
->assertElementExists('#markdown-editor');
|
||||
}
|
||||
@@ -42,8 +42,8 @@ class PageEditorTest extends TestCase
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl('/edit'))
|
||||
->assertElementContains('[name="markdown"]', $mdContent);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$this->withHtml($resp)->assertElementContains('[name="markdown"]', $mdContent);
|
||||
}
|
||||
|
||||
public function test_html_content_given_to_editor_if_no_markdown()
|
||||
@@ -51,8 +51,8 @@ class PageEditorTest extends TestCase
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$this->asAdmin()->get($this->page->getUrl() . '/edit')
|
||||
->assertElementContains('[name="markdown"]', $this->page->html);
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl() . '/edit');
|
||||
$this->withHtml($resp)->assertElementContains('[name="markdown"]', $this->page->html);
|
||||
}
|
||||
|
||||
public function test_empty_markdown_still_saves_without_error()
|
||||
@@ -91,19 +91,19 @@ class PageEditorTest extends TestCase
|
||||
|
||||
// Book draft goes back to book
|
||||
$resp = $this->get($book->getUrl("/draft/{$draft->id}"));
|
||||
$resp->assertElementContains('a[href="' . $book->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $book->getUrl() . '"]', 'Back');
|
||||
|
||||
// Chapter draft goes back to chapter
|
||||
$draft->chapter_id = $chapter->id;
|
||||
$draft->save();
|
||||
$resp = $this->get($book->getUrl("/draft/{$draft->id}"));
|
||||
$resp->assertElementContains('a[href="' . $chapter->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $chapter->getUrl() . '"]', 'Back');
|
||||
|
||||
// Saved page goes back to page
|
||||
$this->post($book->getUrl("/draft/{$draft->id}"), ['name' => 'Updated', 'html' => 'Updated']);
|
||||
$draft->refresh();
|
||||
$resp = $this->get($draft->getUrl('/edit'));
|
||||
$resp->assertElementContains('a[href="' . $draft->getUrl() . '"]', 'Back');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $draft->getUrl() . '"]', 'Back');
|
||||
}
|
||||
|
||||
public function test_switching_from_html_to_clean_markdown_works()
|
||||
@@ -116,7 +116,7 @@ class PageEditorTest extends TestCase
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=markdown-clean'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee("## A Header\n\nSome **bold** content.");
|
||||
$resp->assertElementExists('#markdown-editor');
|
||||
$this->withHtml($resp)->assertElementExists('#markdown-editor');
|
||||
}
|
||||
|
||||
public function test_switching_from_html_to_stable_markdown_works()
|
||||
@@ -129,7 +129,7 @@ class PageEditorTest extends TestCase
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=markdown-stable'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee('<h2>A Header</h2><p>Some <strong>bold</strong> content.</p>', true);
|
||||
$resp->assertElementExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_switching_from_markdown_to_wysiwyg_works()
|
||||
@@ -142,40 +142,40 @@ class PageEditorTest extends TestCase
|
||||
|
||||
$resp = $this->asAdmin()->get($page->getUrl('/edit?editor=wysiwyg'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$resp->assertSee("<h2>A Header</h2>\n<p>Some content with <strong>bold</strong> text!</p>", true);
|
||||
}
|
||||
|
||||
public function test_page_editor_changes_with_editor_property()
|
||||
{
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
|
||||
$this->page->markdown = "## A Header\n\nSome content with **bold** text!";
|
||||
$this->page->editor = 'markdown';
|
||||
$this->page->save();
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$resp->assertElementExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_editor_type_switch_options_show()
|
||||
{
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
|
||||
$resp->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-clean\"]", '(Clean Content)');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}markdown-stable\"]", '(Stable Content)');
|
||||
|
||||
$resp = $this->asAdmin()->get($this->page->getUrl('/edit?editor=markdown-stable'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
||||
$this->withHtml($resp)->assertElementContains("a[href=\"${editLink}wysiwyg\"]", 'Switch to WYSIWYG Editor');
|
||||
}
|
||||
|
||||
public function test_editor_type_switch_options_dont_show_if_without_change_editor_permissions()
|
||||
{
|
||||
$resp = $this->asEditor()->get($this->page->getUrl('/edit'));
|
||||
$editLink = $this->page->getUrl('/edit') . '?editor=';
|
||||
$resp->assertElementNotExists("a[href*=\"${editLink}\"]");
|
||||
$this->withHtml($resp)->assertElementNotExists("a[href*=\"${editLink}\"]");
|
||||
}
|
||||
|
||||
public function test_page_editor_type_switch_does_not_work_without_change_editor_permissions()
|
||||
@@ -187,8 +187,8 @@ class PageEditorTest extends TestCase
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/edit?editor=markdown-stable'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$resp->assertElementNotExists('[component="markdown-editor"]');
|
||||
$this->withHtml($resp)->assertElementExists('[component="wysiwyg-editor"]');
|
||||
$this->withHtml($resp)->assertElementNotExists('[component="markdown-editor"]');
|
||||
}
|
||||
|
||||
public function test_page_save_does_not_change_active_editor_without_change_editor_permissions()
|
||||
|
@@ -211,11 +211,11 @@ class PageRevisionTest extends TestCase
|
||||
$this->asAdmin()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html']);
|
||||
|
||||
$resp = $this->get($page->refresh()->getUrl('/revisions'));
|
||||
$resp->assertElementContains('td', '(WYSIWYG)');
|
||||
$resp->assertElementNotContains('td', '(Markdown)');
|
||||
$this->withHtml($resp)->assertElementContains('td', '(WYSIWYG)');
|
||||
$this->withHtml($resp)->assertElementNotContains('td', '(Markdown)');
|
||||
|
||||
$this->asAdmin()->put($page->getUrl(), ['name' => 'Updated page', 'markdown' => '# Some markdown content']);
|
||||
$resp = $this->get($page->refresh()->getUrl('/revisions'));
|
||||
$resp->assertElementContains('td', '(Markdown)');
|
||||
$this->withHtml($resp)->assertElementContains('td', '(Markdown)');
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ class PageTest extends TestCase
|
||||
]);
|
||||
|
||||
$resp = $this->asEditor()->get($chapter->getUrl());
|
||||
$resp->assertElementContains('a[href="' . $chapter->getUrl('/create-page') . '"]', 'New Page');
|
||||
$this->withHtml($resp)->assertElementContains('a[href="' . $chapter->getUrl('/create-page') . '"]', 'New Page');
|
||||
|
||||
$resp = $this->get($chapter->getUrl('/create-page'));
|
||||
/** @var Page $draftPage */
|
||||
@@ -30,7 +30,7 @@ class PageTest extends TestCase
|
||||
$resp->assertRedirect($draftPage->getUrl());
|
||||
|
||||
$resp = $this->get($draftPage->getUrl());
|
||||
$resp->assertElementContains('form[action="' . $draftPage->getUrl() . '"][method="POST"]', 'Save Page');
|
||||
$this->withHtml($resp)->assertElementContains('form[action="' . $draftPage->getUrl() . '"][method="POST"]', 'Save Page');
|
||||
|
||||
$resp = $this->post($draftPage->getUrl(), $draftPage->only('name', 'html'));
|
||||
$draftPage->refresh();
|
||||
@@ -98,7 +98,7 @@ class PageTest extends TestCase
|
||||
$this->assertTrue($page->deletions()->count() === 1);
|
||||
|
||||
$redirectReq = $this->get($deleteReq->baseResponse->headers->get('location'));
|
||||
$redirectReq->assertNotificationContains('Page Successfully Deleted');
|
||||
$this->assertNotificationContains($redirectReq, 'Page Successfully Deleted');
|
||||
}
|
||||
|
||||
public function test_page_full_delete_removes_all_revisions()
|
||||
@@ -257,8 +257,8 @@ class PageTest extends TestCase
|
||||
$user = $this->getEditor();
|
||||
$content = $this->createEntityChainBelongingToUser($user);
|
||||
|
||||
$this->asAdmin()->get('/pages/recently-updated')
|
||||
->assertElementContains('.entity-list .page:nth-child(1)', $content['page']->name);
|
||||
$resp = $this->asAdmin()->get('/pages/recently-updated');
|
||||
$this->withHtml($resp)->assertElementContains('.entity-list .page:nth-child(1)', $content['page']->name);
|
||||
}
|
||||
|
||||
public function test_recently_updated_pages_view_shows_updated_by_details()
|
||||
@@ -273,7 +273,7 @@ class PageTest extends TestCase
|
||||
]);
|
||||
|
||||
$resp = $this->asAdmin()->get('/pages/recently-updated');
|
||||
$resp->assertElementContains('.entity-list .page:nth-child(1)', 'Updated 1 second ago by ' . $user->name);
|
||||
$this->withHtml($resp)->assertElementContains('.entity-list .page:nth-child(1)', 'Updated 1 second ago by ' . $user->name);
|
||||
}
|
||||
|
||||
public function test_recently_updated_pages_view_shows_parent_chain()
|
||||
@@ -288,8 +288,8 @@ class PageTest extends TestCase
|
||||
]);
|
||||
|
||||
$resp = $this->asAdmin()->get('/pages/recently-updated');
|
||||
$resp->assertElementContains('.entity-list .page:nth-child(1)', $page->chapter->getShortName(42));
|
||||
$resp->assertElementContains('.entity-list .page:nth-child(1)', $page->book->getShortName(42));
|
||||
$this->withHtml($resp)->assertElementContains('.entity-list .page:nth-child(1)', $page->chapter->getShortName(42));
|
||||
$this->withHtml($resp)->assertElementContains('.entity-list .page:nth-child(1)', $page->book->getShortName(42));
|
||||
}
|
||||
|
||||
public function test_recently_updated_pages_view_does_not_show_parent_if_not_visible()
|
||||
@@ -309,7 +309,7 @@ class PageTest extends TestCase
|
||||
$resp = $this->get('/pages/recently-updated');
|
||||
$resp->assertDontSee($page->book->getShortName(42));
|
||||
$resp->assertDontSee($page->chapter->getShortName(42));
|
||||
$resp->assertElementContains('.entity-list .page:nth-child(1)', 'Updated title');
|
||||
$this->withHtml($resp)->assertElementContains('.entity-list .page:nth-child(1)', 'Updated title');
|
||||
}
|
||||
|
||||
public function test_recently_updated_pages_on_home()
|
||||
@@ -320,15 +320,15 @@ class PageTest extends TestCase
|
||||
'updated_at' => Carbon::now()->subSecond(1),
|
||||
]);
|
||||
|
||||
$this->asAdmin()->get('/')
|
||||
->assertElementNotContains('#recently-updated-pages', $page->name);
|
||||
$resp = $this->asAdmin()->get('/');
|
||||
$this->withHtml($resp)->assertElementNotContains('#recently-updated-pages', $page->name);
|
||||
|
||||
$this->put($page->getUrl(), [
|
||||
'name' => $page->name,
|
||||
'html' => $page->html,
|
||||
]);
|
||||
|
||||
$this->get('/')
|
||||
->assertElementContains('#recently-updated-pages', $page->name);
|
||||
$resp = $this->get('/');
|
||||
$this->withHtml($resp)->assertElementContains('#recently-updated-pages', $page->name);
|
||||
}
|
||||
}
|
||||
|
@@ -247,7 +247,7 @@ class SortTest extends TestCase
|
||||
$bookToSort = Book::query()->first();
|
||||
|
||||
$resp = $this->asAdmin()->get($bookToSort->getUrl());
|
||||
$resp->assertElementExists('a[href="' . $bookToSort->getUrl('/sort') . '"]');
|
||||
$this->withHtml($resp)->assertElementExists('a[href="' . $bookToSort->getUrl('/sort') . '"]');
|
||||
|
||||
$resp = $this->get($bookToSort->getUrl('/sort'));
|
||||
$resp->assertStatus(200);
|
||||
@@ -456,14 +456,14 @@ class SortTest extends TestCase
|
||||
$book->pages()->whereNotIn('id', $pages->pluck('id'))->delete();
|
||||
|
||||
$resp = $this->asEditor()->get($book->getUrl());
|
||||
$resp->assertElementContains('.content-wrap a.page:nth-child(1)', $pages[0]->name);
|
||||
$resp->assertElementContains('.content-wrap a.page:nth-child(2)', $pages[1]->name);
|
||||
$this->withHtml($resp)->assertElementContains('.content-wrap a.page:nth-child(1)', $pages[0]->name);
|
||||
$this->withHtml($resp)->assertElementContains('.content-wrap a.page:nth-child(2)', $pages[1]->name);
|
||||
|
||||
$pages[0]->forceFill(['priority' => 10])->save();
|
||||
$pages[1]->forceFill(['priority' => 5])->save();
|
||||
|
||||
$resp = $this->asEditor()->get($book->getUrl());
|
||||
$resp->assertElementContains('.content-wrap a.page:nth-child(1)', $pages[1]->name);
|
||||
$resp->assertElementContains('.content-wrap a.page:nth-child(2)', $pages[0]->name);
|
||||
$this->withHtml($resp)->assertElementContains('.content-wrap a.page:nth-child(1)', $pages[1]->name);
|
||||
$this->withHtml($resp)->assertElementContains('.content-wrap a.page:nth-child(2)', $pages[0]->name);
|
||||
}
|
||||
}
|
||||
|
@@ -94,10 +94,10 @@ class TagTest extends TestCase
|
||||
$page = $this->getEntityWithTags(Page::class, $tags);
|
||||
$resp = $this->asEditor()->get('/search?term=[category]');
|
||||
$resp->assertSee($page->name);
|
||||
$resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'category');
|
||||
$resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'buckets');
|
||||
$resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'color');
|
||||
$resp->assertElementContains('[href="' . $page->getUrl() . '"]', 'red');
|
||||
$this->withHtml($resp)->assertElementContains('[href="' . $page->getUrl() . '"]', 'category');
|
||||
$this->withHtml($resp)->assertElementContains('[href="' . $page->getUrl() . '"]', 'buckets');
|
||||
$this->withHtml($resp)->assertElementContains('[href="' . $page->getUrl() . '"]', 'color');
|
||||
$this->withHtml($resp)->assertElementContains('[href="' . $page->getUrl() . '"]', 'red');
|
||||
}
|
||||
|
||||
public function test_tags_index_shows_tag_name_as_expected_with_right_counts()
|
||||
@@ -109,23 +109,24 @@ class TagTest extends TestCase
|
||||
|
||||
$resp = $this->asEditor()->get('/tags');
|
||||
$resp->assertSee('Category');
|
||||
$resp->assertElementCount('.tag-item', 1);
|
||||
$html = $this->withHtml($resp);
|
||||
$html->assertElementCount('.tag-item', 1);
|
||||
$resp->assertDontSee('GreatTestContent');
|
||||
$resp->assertDontSee('OtherTestContent');
|
||||
$resp->assertElementContains('a[title="Total tag usages"]', '2');
|
||||
$resp->assertElementContains('a[title="Assigned to Pages"]', '2');
|
||||
$resp->assertElementContains('a[title="Assigned to Books"]', '0');
|
||||
$resp->assertElementContains('a[title="Assigned to Chapters"]', '0');
|
||||
$resp->assertElementContains('a[title="Assigned to Shelves"]', '0');
|
||||
$resp->assertElementContains('a[href$="/tags?name=Category"]', '2 unique values');
|
||||
$html->assertElementContains('a[title="Total tag usages"]', '2');
|
||||
$html->assertElementContains('a[title="Assigned to Pages"]', '2');
|
||||
$html->assertElementContains('a[title="Assigned to Books"]', '0');
|
||||
$html->assertElementContains('a[title="Assigned to Chapters"]', '0');
|
||||
$html->assertElementContains('a[title="Assigned to Shelves"]', '0');
|
||||
$html->assertElementContains('a[href$="/tags?name=Category"]', '2 unique values');
|
||||
|
||||
/** @var Book $book */
|
||||
$book = Book::query()->first();
|
||||
$book->tags()->create(['name' => 'Category', 'value' => 'GreatTestContent']);
|
||||
$resp = $this->asEditor()->get('/tags');
|
||||
$resp->assertElementContains('a[title="Total tag usages"]', '3');
|
||||
$resp->assertElementContains('a[title="Assigned to Books"]', '1');
|
||||
$resp->assertElementContains('a[href$="/tags?name=Category"]', '2 unique values');
|
||||
$this->withHtml($resp)->assertElementContains('a[title="Total tag usages"]', '3');
|
||||
$this->withHtml($resp)->assertElementContains('a[title="Assigned to Books"]', '1');
|
||||
$this->withHtml($resp)->assertElementContains('a[href$="/tags?name=Category"]', '2 unique values');
|
||||
}
|
||||
|
||||
public function test_tag_index_can_be_searched()
|
||||
@@ -135,14 +136,14 @@ class TagTest extends TestCase
|
||||
$page->tags()->create(['name' => 'Category', 'value' => 'GreatTestContent']);
|
||||
|
||||
$resp = $this->asEditor()->get('/tags?search=cat');
|
||||
$resp->assertElementContains('.tag-item .tag-name', 'Category');
|
||||
$this->withHtml($resp)->assertElementContains('.tag-item .tag-name', 'Category');
|
||||
|
||||
$resp = $this->asEditor()->get('/tags?search=content');
|
||||
$resp->assertElementContains('.tag-item .tag-name', 'Category');
|
||||
$resp->assertElementContains('.tag-item .tag-value', 'GreatTestContent');
|
||||
$this->withHtml($resp)->assertElementContains('.tag-item .tag-name', 'Category');
|
||||
$this->withHtml($resp)->assertElementContains('.tag-item .tag-value', 'GreatTestContent');
|
||||
|
||||
$resp = $this->asEditor()->get('/tags?search=other');
|
||||
$resp->assertElementNotExists('.tag-item .tag-name');
|
||||
$this->withHtml($resp)->assertElementNotExists('.tag-item .tag-name');
|
||||
}
|
||||
|
||||
public function test_tag_index_search_will_show_mulitple_values_of_a_single_tag_name()
|
||||
@@ -153,8 +154,8 @@ class TagTest extends TestCase
|
||||
$page->tags()->create(['name' => 'Animal', 'value' => 'Catdog']);
|
||||
|
||||
$resp = $this->asEditor()->get('/tags?search=cat');
|
||||
$resp->assertElementContains('.tag-item .tag-value', 'Catfish');
|
||||
$resp->assertElementContains('.tag-item .tag-value', 'Catdog');
|
||||
$this->withHtml($resp)->assertElementContains('.tag-item .tag-value', 'Catfish');
|
||||
$this->withHtml($resp)->assertElementContains('.tag-item .tag-value', 'Catdog');
|
||||
}
|
||||
|
||||
public function test_tag_index_can_be_scoped_to_specific_tag_name()
|
||||
@@ -170,9 +171,9 @@ class TagTest extends TestCase
|
||||
$resp->assertSee('GreatTestContent');
|
||||
$resp->assertSee('OtherTestContent');
|
||||
$resp->assertDontSee('OtherTagName');
|
||||
$resp->assertElementCount('table .tag-item', 2);
|
||||
$resp->assertSee('Active Filter:');
|
||||
$resp->assertElementContains('form[action$="/tags"]', 'Clear Filter');
|
||||
$this->withHtml($resp)->assertElementCount('table .tag-item', 2);
|
||||
$this->withHtml($resp)->assertElementContains('form[action$="/tags"]', 'Clear Filter');
|
||||
}
|
||||
|
||||
public function test_tags_index_adheres_to_page_permissions()
|
||||
|
Reference in New Issue
Block a user