Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Add behat test for previewing elemental blocks #980

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions tests/Behat/features/preview-a-block.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Feature: Preview a non-inline-editable block
As an author
I want to preview the parent page of the non-inline-editable block I'm editing in the CMS
So that I can see how it would look like to my visitors

Background:
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And I add an extension "DNADesign\Elemental\Tests\Src\TestReplacePageContentExtension" to the "Page" class
And content blocks are not in-line editable
And a "page" "Preview Blocks Page" with a "Alice's Block" content element with "Alice's content" content

Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages"
And I left click on "Preview Blocks Page" in the tree
And I set the CMS mode to "Edit mode"
And I press the "Publish" button
And I click on block 1

@javascript
Scenario: I can show a preview of the current block's page from the pages section
When I set the CMS mode to "Preview mode"
Then I can see the preview panel
And the preview contains "Alice's content"
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

Given I set the CMS mode to "Edit mode"

@javascript
Scenario: I can see an updated preview when editing inline-editable blocks
When I fill in "<p>New published content</p>" for the "Content" HTML field
And I press the "Publish" button
And I fill in "<p>New preview content</p>" for the "Content" HTML field
And I press the "Save" button
And I set the CMS mode to "Preview mode"

When I switch the preview to "Published"
Then the preview does not contain "New preview content"
And the preview contains "New published content"

When I switch the preview to "Draft"
Then the preview does not contain "New published content"
And the preview contains "New preview content"

Given I set the CMS mode to "Edit mode"
14 changes: 14 additions & 0 deletions tests/Src/TestReplacePageContentExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace DNADesign\Elemental\Tests\Src;

use SilverStripe\Core\Extension;
use SilverStripe\Dev\TestOnly;

class TestReplacePageContentExtension extends Extension implements TestOnly
{
public function getContent()
{
return $this->owner->ElementalArea;
}
}