1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-10-30 07:32:39 +01:00

Organised test files & added page update draft tests

Also cleaned styling for new autosave ui parts.
Closes #36.
This commit is contained in:
Dan Brown 2016-03-12 16:31:02 +00:00
parent 30214fde74
commit bf7852ce85
8 changed files with 69 additions and 7 deletions

0
public/uploads/.gitignore vendored Normal file → Executable file
View File

View File

@ -161,7 +161,7 @@ form.search-box {
} }
} }
.faded > span.faded-text { .faded span.faded-text {
display: inline-block; display: inline-block;
padding: $-s; padding: $-s;
opacity: 0.5; opacity: 0.5;
@ -189,6 +189,9 @@ form.search-box {
padding-left: 0; padding-left: 0;
} }
} }
&.text-center {
text-align: center;
}
} }
.setting-nav { .setting-nav {

View File

@ -14,14 +14,11 @@
</div> </div>
</div> </div>
<div class="col-sm-4 faded text-center"> <div class="col-sm-4 faded text-center">
<div class="action-buttons text-center" ng-cloak> <span class="faded-text" ng-bind="draftText"></span>
<span class="faded-text" ng-bind="draftText"></span>
<button type="button" ng-if="isDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button>
</div>
</div> </div>
<div class="col-sm-4 faded"> <div class="col-sm-4 faded">
<div class="action-buttons"> <div class="action-buttons" ng-cloak>
<button type="button" ng-if="isDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button>
<button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button>
</div> </div>
</div> </div>

View File

@ -0,0 +1,62 @@
<?php
class PageUpdateDraftTest extends TestCase
{
protected $page;
protected $pageRepo;
public function setUp()
{
parent::setUp();
$this->page = \BookStack\Page::first();
$this->pageRepo = app('\BookStack\Repos\PageRepo');
}
public function test_draft_content_shows_if_available()
{
$addedContent = '<p>test message content</p>';
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->dontSeeInField('html', $addedContent);
$newContent = $this->page->html . $addedContent;
$this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]);
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->seeInField('html', $newContent);
}
public function test_draft_not_visible_by_others()
{
$addedContent = '<p>test message content</p>';
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->dontSeeInField('html', $addedContent);
$newContent = $this->page->html . $addedContent;
$newUser = $this->getNewUser();
$this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]);
$this->actingAs($newUser)->visit($this->page->getUrl() . '/edit')
->dontSeeInField('html', $newContent);
}
public function test_alert_message_shows_if_editing_draft()
{
$this->asAdmin();
$this->pageRepo->saveUpdateDraft($this->page, ['html' => 'test content']);
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->see('You are currently editing a draft');
}
public function test_alert_message_shows_if_someone_else_editing()
{
$addedContent = '<p>test message content</p>';
$this->asAdmin()->visit($this->page->getUrl() . '/edit')
->dontSeeInField('html', $addedContent);
$newContent = $this->page->html . $addedContent;
$newUser = $this->getNewUser();
$this->pageRepo->saveUpdateDraft($this->page, ['html' => $newContent]);
$this->actingAs($newUser)->visit($this->page->getUrl() . '/edit')
->see('Admin has started editing this page');
}
}