3 class HomepageTest extends TestCase
6 public function test_default_homepage_visible()
9 $homeVisit = $this->get('/');
10 $homeVisit->assertSee('My Recently Viewed');
11 $homeVisit->assertSee('Recently Updated Pages');
12 $homeVisit->assertSee('Recent Activity');
13 $homeVisit->assertSee('home-default');
16 public function test_custom_homepage()
19 $name = 'My custom homepage';
20 $content = str_repeat('This is the body content of my custom homepage.', 20);
21 $customPage = $this->newPage(['name' => $name, 'html' => $content]);
22 $this->setSettings(['app-homepage' => $customPage->id]);
23 $this->setSettings(['app-homepage-type' => 'page']);
25 $homeVisit = $this->get('/');
26 $homeVisit->assertSee($name);
27 $homeVisit->assertSee($content);
28 $homeVisit->assertSee('My Recently Viewed');
29 $homeVisit->assertSee('Recently Updated Pages');
30 $homeVisit->assertSee('Recent Activity');
33 public function test_delete_custom_homepage()
36 $name = 'My custom homepage';
37 $content = str_repeat('This is the body content of my custom homepage.', 20);
38 $customPage = $this->newPage(['name' => $name, 'html' => $content]);
39 $this->setSettings(['app-homepage' => $customPage->id]);
41 $homeVisit = $this->get('/');
42 $homeVisit->assertSee($name);
44 $pageDeleteReq = $this->delete($customPage->getUrl());
45 $pageDeleteReq->assertStatus(302);
46 $pageDeleteReq->assertRedirect($customPage->getUrl());
47 $pageDeleteReq->assertSessionHas('error');
48 $pageDeleteReq->assertSessionMissing('success');
50 $homeVisit = $this->get('/');
51 $homeVisit->assertSee($name);
52 $homeVisit->assertStatus(200);
55 public function test_set_book_homepage()
57 $editor = $this->getEditor();
58 setting()->putUser($editor, 'books_view_type', 'grid');
60 $this->setSettings(['app-homepage-type' => 'books']);
63 $homeVisit = $this->get('/');
64 $homeVisit->assertSee('Books');
65 $homeVisit->assertSee('grid-card');
66 $homeVisit->assertSee('grid-card-content');
67 $homeVisit->assertSee('grid-card-footer');
68 $homeVisit->assertSee('featured-image-container');
70 $this->setSettings(['app-homepage-type' => false]);
71 $this->test_default_homepage_visible();
74 public function test_set_bookshelves_homepage()
76 $editor = $this->getEditor();
77 setting()->putUser($editor, 'bookshelves_view_type', 'grid');
79 $this->setSettings(['app-homepage-type' => 'bookshelves']);
82 $homeVisit = $this->get('/');
83 $homeVisit->assertSee('Shelves');
84 $homeVisit->assertSee('bookshelf-grid-item grid-card');
85 $homeVisit->assertSee('grid-card-content');
86 $homeVisit->assertSee('grid-card-footer');
87 $homeVisit->assertSee('featured-image-container');
89 $this->setSettings(['app-homepage-type' => false]);
90 $this->test_default_homepage_visible();