mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-29 23:22:34 +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:
parent
30214fde74
commit
bf7852ce85
0
public/uploads/.gitignore
vendored
Normal file → Executable file
0
public/uploads/.gitignore
vendored
Normal file → Executable file
@ -161,7 +161,7 @@ form.search-box {
|
||||
}
|
||||
}
|
||||
|
||||
.faded > span.faded-text {
|
||||
.faded span.faded-text {
|
||||
display: inline-block;
|
||||
padding: $-s;
|
||||
opacity: 0.5;
|
||||
@ -189,6 +189,9 @@ form.search-box {
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
&.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-nav {
|
||||
|
@ -14,14 +14,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4 faded text-center">
|
||||
<div class="action-buttons text-center" ng-cloak>
|
||||
<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>
|
||||
<span class="faded-text" ng-bind="draftText"></span>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
62
tests/Entity/PageUpdateDraftTest.php
Normal file
62
tests/Entity/PageUpdateDraftTest.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user