|
2 | 2 |
|
3 | 3 | namespace Tests\View; |
4 | 4 |
|
| 5 | +use BookStack\Activity\Models\Favourite; |
5 | 6 | use Tests\TestCase; |
6 | 7 |
|
7 | 8 | class LayoutEditTest extends TestCase |
8 | 9 | { |
| 10 | + public function test_route_access_limited_to_logged_in_users() |
| 11 | + { |
| 12 | + $this->setSettings(['app-public' => 'true']); |
| 13 | + |
| 14 | + $this->get('/layouts/books-show')->assertRedirect('/'); |
| 15 | + $this->put('/layouts/books-show')->assertRedirect('/'); |
| 16 | + $this->put('/layouts/books-show/reset')->assertRedirect('/'); |
| 17 | + } |
| 18 | + |
9 | 19 | public function test_view() |
10 | 20 | { |
11 | 21 | $resp = $this->asEditor()->get('/layouts/books-index'); |
@@ -111,6 +121,45 @@ public function test_update() |
111 | 121 | ], $storedData); |
112 | 122 | } |
113 | 123 |
|
| 124 | + public function test_layout_changes_take_effect() |
| 125 | + { |
| 126 | + $editor = $this->users->editor(); |
| 127 | + $this->actingAs($editor); |
| 128 | + $page = $this->entities->page(); |
| 129 | + $page->favourites()->save((new Favourite())->forceFill(['user_id' => $editor->id])); |
| 130 | + $this->get($page->getUrl()); |
| 131 | + |
| 132 | + $html = $this->withHtml($this->get('/')); |
| 133 | + |
| 134 | + $html->assertElementExists('.grid.third > div:nth-child(1) h3:contains("My Recently Viewed")'); |
| 135 | + $html->assertElementExists('.grid.third > div:nth-child(2) h3:contains("My Most Viewed Favourites")'); |
| 136 | + $html->assertElementExists('.grid.third > div:nth-child(2) h3:contains("Recently Updated Pages")'); |
| 137 | + $html->assertElementExists('.grid.third > div:nth-child(3) h3:contains("Recent Activity")'); |
| 138 | + |
| 139 | + $layout = [ |
| 140 | + 'left' => [ |
| 141 | + 'builtin_home-top-favourites', |
| 142 | + ], |
| 143 | + 'center' => [ |
| 144 | + 'builtin_home-recent-activity', |
| 145 | + ], |
| 146 | + 'right' => [ |
| 147 | + 'builtin_home-recently-viewed-or-recent-books', |
| 148 | + ], |
| 149 | + 'unused' => [ |
| 150 | + 'builtin_home-recently-updated-pages', |
| 151 | + ], |
| 152 | + ]; |
| 153 | + |
| 154 | + $this->put('/layouts/home-default', ['layout' => json_encode($layout)])->assertRedirect('/layouts/home-default'); |
| 155 | + $html = $this->withHtml($this->get('/')); |
| 156 | + |
| 157 | + $html->assertElementExists('.grid.third > div:nth-child(3) h3:contains("My Recently Viewed")'); |
| 158 | + $html->assertElementExists('.grid.third > div:nth-child(1) h3:contains("My Most Viewed Favourites")'); |
| 159 | + $html->assertElementNotExists('h3:contains("Recently Updated Pages")'); |
| 160 | + $html->assertElementExists('.grid.third > div:nth-child(2) h3:contains("Recent Activity")'); |
| 161 | + } |
| 162 | + |
114 | 163 | public function test_reset() |
115 | 164 | { |
116 | 165 | $this->asEditor(); |
|
0 commit comments