3 class SortTest extends TestCase
7 public function setUp()
10 $this->book = \BookStack\Book::first();
13 public function test_drafts_do_not_show_up()
16 $entityRepo = app('\BookStack\Repos\EntityRepo');
17 $draft = $entityRepo->getDraftPage($this->book);
19 $this->visit($this->book->getUrl())
21 ->visit($this->book->getUrl() . '/sort')
22 ->dontSee($draft->name);
25 public function test_page_move()
27 $page = \BookStack\Page::first();
28 $currentBook = $page->book;
29 $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
30 $this->asAdmin()->visit($page->getUrl() . '/move')
32 ->type('book:' . $newBook->id, 'entity_selection')->press('Move Page');
34 $page = \BookStack\Page::find($page->id);
35 $this->seePageIs($page->getUrl());
36 $this->assertTrue($page->book->id == $newBook->id, 'Page book is now the new book');
38 $this->visit($newBook->getUrl())
39 ->seeInNthElement('.activity-list-item', 0, 'moved page')
40 ->seeInNthElement('.activity-list-item', 0, $page->name);
43 public function test_chapter_move()
45 $chapter = \BookStack\Chapter::first();
46 $currentBook = $chapter->book;
47 $pageToCheck = $chapter->pages->first();
48 $newBook = \BookStack\Book::where('id', '!=', $currentBook->id)->first();
50 $this->asAdmin()->visit($chapter->getUrl() . '/move')
52 ->type('book:' . $newBook->id, 'entity_selection')->press('Move Chapter');
54 $chapter = \BookStack\Chapter::find($chapter->id);
55 $this->seePageIs($chapter->getUrl());
56 $this->assertTrue($chapter->book->id === $newBook->id, 'Chapter Book is now the new book');
58 $this->visit($newBook->getUrl())
59 ->seeInNthElement('.activity-list-item', 0, 'moved chapter')
60 ->seeInNthElement('.activity-list-item', 0, $chapter->name);
62 $pageToCheck = \BookStack\Page::find($pageToCheck->id);
63 $this->assertTrue($pageToCheck->book_id === $newBook->id, 'Chapter child page\'s book id has changed to the new book');
64 $this->visit($pageToCheck->getUrl())
65 ->see($newBook->name);