]> BookStack Code Mirror - bookstack/blob - tests/HomepageTest.php
Fixed German translations for notifications
[bookstack] / tests / HomepageTest.php
1 <?php namespace Tests;
2
3 class HomepageTest extends TestCase
4 {
5
6     public function test_default_homepage_visible()
7     {
8         $this->asEditor();
9         $homeVisit = $this->get('/');
10         $homeVisit->assertSee('My Recently Viewed');
11         $homeVisit->assertSee('Recently Updated Pages');
12         $homeVisit->assertSee('Recent Activity');
13     }
14
15     public function test_custom_homepage()
16     {
17         $this->asEditor();
18         $name = 'My custom homepage';
19         $content = 'This is the body content of my custom homepage.';
20         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
21         $this->setSettings(['app-homepage' => $customPage->id]);
22
23         $homeVisit = $this->get('/');
24         $homeVisit->assertSee($name);
25         $homeVisit->assertSee($content);
26         $homeVisit->assertSee('My Recently Viewed');
27         $homeVisit->assertSee('Recently Updated Pages');
28         $homeVisit->assertSee('Recent Activity');
29     }
30
31     public function test_delete_custom_homepage()
32     {
33         $this->asEditor();
34         $name = 'My custom homepage';
35         $content = 'This is the body content of my custom homepage.';
36         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
37         $this->setSettings(['app-homepage' => $customPage->id]);
38
39         $homeVisit = $this->get('/');
40         $homeVisit->assertSee($name);
41
42         $pageDeleteReq = $this->delete($customPage->getUrl());
43         $pageDeleteReq->assertStatus(302);
44         $pageDeleteReq->assertRedirect($customPage->getUrl());
45         $pageDeleteReq->assertSessionHas('error');
46         $pageDeleteReq->assertSessionMissing('success');
47
48         $homeVisit = $this->get('/');
49         $homeVisit->assertSee($name);
50         $homeVisit->assertStatus(200);
51     }
52
53     public function test_set_book_homepage()
54     {
55         $editor = $this->getEditor();
56         setting()->putUser($editor, 'books_view_type', 'grid');
57
58         $this->setSettings(['app-book-homepage' => true]);
59
60         $this->asEditor();
61         $homeVisit = $this->get('/');
62         $homeVisit->assertSee('Books');
63         $homeVisit->assertSee('book-grid-item grid-card');
64         $homeVisit->assertSee('grid-card-content');
65         $homeVisit->assertSee('grid-card-footer');
66         $homeVisit->assertSee('featured-image-container');
67
68         $this->setSettings(['app-book-homepage' => false]);
69         $this->test_default_homepage_visible();
70     }
71 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.