Organised test files & added page update draft tests
Also cleaned styling for new autosave ui parts. Closes #36.
Showing
8 changed files
with
69 additions
and
7 deletions
public/uploads/.gitignore
100644 → 100755
File mode changed
| ... | @@ -161,7 +161,7 @@ form.search-box { | ... | @@ -161,7 +161,7 @@ form.search-box { |
| 161 | } | 161 | } |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | -.faded > span.faded-text { | 164 | +.faded span.faded-text { |
| 165 | display: inline-block; | 165 | display: inline-block; |
| 166 | padding: $-s; | 166 | padding: $-s; |
| 167 | opacity: 0.5; | 167 | opacity: 0.5; |
| ... | @@ -189,6 +189,9 @@ form.search-box { | ... | @@ -189,6 +189,9 @@ form.search-box { |
| 189 | padding-left: 0; | 189 | padding-left: 0; |
| 190 | } | 190 | } |
| 191 | } | 191 | } |
| 192 | + &.text-center { | ||
| 193 | + text-align: center; | ||
| 194 | + } | ||
| 192 | } | 195 | } |
| 193 | 196 | ||
| 194 | .setting-nav { | 197 | .setting-nav { | ... | ... |
| ... | @@ -14,14 +14,11 @@ | ... | @@ -14,14 +14,11 @@ |
| 14 | </div> | 14 | </div> |
| 15 | </div> | 15 | </div> |
| 16 | <div class="col-sm-4 faded text-center"> | 16 | <div class="col-sm-4 faded text-center"> |
| 17 | - <div class="action-buttons text-center" ng-cloak> | 17 | + <span class="faded-text" ng-bind="draftText"></span> |
| 18 | - <span class="faded-text" ng-bind="draftText"></span> | ||
| 19 | - <button type="button" ng-if="isDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> | ||
| 20 | - </div> | ||
| 21 | </div> | 18 | </div> |
| 22 | <div class="col-sm-4 faded"> | 19 | <div class="col-sm-4 faded"> |
| 23 | - <div class="action-buttons"> | 20 | + <div class="action-buttons" ng-cloak> |
| 24 | - | 21 | + <button type="button" ng-if="isDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> |
| 25 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> | 22 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> |
| 26 | </div> | 23 | </div> |
| 27 | </div> | 24 | </div> | ... | ... |
tests/Entity/PageUpdateDraftTest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +class PageUpdateDraftTest extends TestCase | ||
| 5 | +{ | ||
| 6 | + protected $page; | ||
| 7 | + protected $pageRepo; | ||
| 8 | + | ||
| 9 | + public function setUp() | ||
| 10 | + { | ||
| 11 | + parent::setUp(); | ||
| 12 | + $this->page = \BookStack\Page::first(); | ||
| 13 | + $this->pageRepo = app('\BookStack\Repos\PageRepo'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + public function test_draft_content_shows_if_available() | ||
| 17 | + { | ||
| 18 | + $addedContent = '<p>test message content</p>'; | ||
| 19 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 20 | + ->dontSeeInField('html', $addedContent); | ||
| 21 | + | ||
| 22 | + $newContent = $this->page->html . $addedContent; | ||
| 23 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 24 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 25 | + ->seeInField('html', $newContent); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public function test_draft_not_visible_by_others() | ||
| 29 | + { | ||
| 30 | + $addedContent = '<p>test message content</p>'; | ||
| 31 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 32 | + ->dontSeeInField('html', $addedContent); | ||
| 33 | + | ||
| 34 | + $newContent = $this->page->html . $addedContent; | ||
| 35 | + $newUser = $this->getNewUser(); | ||
| 36 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 37 | + $this->actingAs($newUser)->visit($this->page->getUrl() . '/edit') | ||
| 38 | + ->dontSeeInField('html', $newContent); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public function test_alert_message_shows_if_editing_draft() | ||
| 42 | + { | ||
| 43 | + $this->asAdmin(); | ||
| 44 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => 'test content']); | ||
| 45 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 46 | + ->see('You are currently editing a draft'); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public function test_alert_message_shows_if_someone_else_editing() | ||
| 50 | + { | ||
| 51 | + $addedContent = '<p>test message content</p>'; | ||
| 52 | + $this->asAdmin()->visit($this->page->getUrl() . '/edit') | ||
| 53 | + ->dontSeeInField('html', $addedContent); | ||
| 54 | + | ||
| 55 | + $newContent = $this->page->html . $addedContent; | ||
| 56 | + $newUser = $this->getNewUser(); | ||
| 57 | + $this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]); | ||
| 58 | + $this->actingAs($newUser)->visit($this->page->getUrl() . '/edit') | ||
| 59 | + ->see('Admin has started editing this page'); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | +} |
-
Please register or sign in to post a comment