Skip to content

Commit

Permalink
Fixing up tests with latest updates from behat-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ authored and raissanorth committed Aug 30, 2018
1 parent d167d2f commit 2b07d52
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 35 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ before_script:
# Install composer dependencies
- composer validate
- composer require silverstripe/recipe-cms:"$RECIPE_VERSION" silverstripe/recipe-testing:^1 --no-update
- if [[ $BEHAT_TEST ]]; then composer require --no-update silverstripe/behat-extension:4.x-dev; fi;
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.1.x-dev --no-update; fi
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"silverstripe/vendor-plugin": "^1"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"squizlabs/php_codesniffer": "^3.0"
"silverstripe/recipe-testing": "1.x-dev"
},
"suggest": {
"silverstripe/elemental-blocks": "Adds a set of common SilverStripe content block types",
Expand Down
40 changes: 29 additions & 11 deletions tests/Behat/Context/FixtureContext.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<?php
namespace DNADesign\Elemental\Tests\Behat\Context;

use DNADesign\Elemental\Extensions\ElementalAreasExtension;
use DNADesign\Elemental\Extensions\ElementalPageExtension;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementContent;
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;
use SilverStripe\BehatExtension\Utility\StepHelper;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\FixtureBlueprint;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\HasManyList;

if (!class_exists(BaseFixtureContext::class)) {
return;
Expand Down Expand Up @@ -50,8 +40,36 @@ public function theHasAContentElementWithContent($type, $pageTitle, $elementTitl
$element->HTML = $elementContent;
$element->write();
} else {
$element = $this->getFixtureFactory()->createObject(ElementContent::class, $elementTitle, $fields);
$element = $this->getFixtureFactory()->createObject(ElementContent::class, $elementTitle, [
'Title' => $elementTitle,
'HTML' => $elementContent
]);
$element->write();
}
}

/**
* @Given content blocks are not in-line editable
*
* @param $elementTitle
*/
public function contentBlocksAreNotInLineEditable()
{
$contentBlockClass = ElementContent::class;
$config = <<<YAML
---
Name: testonly-content-blocks-not-inline-editable
---
$contentBlockClass:
inline_editable: false
YAML;

$file = 'content-blocks-not-inline-editable.yml';
$path = $this->getDestinationConfigFolder($file);
file_put_contents($path, $config);

$this->activatedConfigFiles[] = $path;

$this->getMainContext()->visit('/?flush');
}
}
4 changes: 2 additions & 2 deletions tests/Behat/features/add-block-element.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Feature: Add elements in the CMS
So that I can use multiple elements on a page

Background:
Given I am logged in with "ADMIN" permissions
And I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "Alice's Block" content element with "Some content" content
And the "page" "Blocks Page" has a "Bob's Block" content element with "Some content II" content

Given I am logged in with "ADMIN" permissions
# Remove with 'And I click "Blocks Page" in the ".breadcrumbs-wrapper" element' once the ElementalArea refreshes,
# See https://github.com/dnadesign/silverstripe-elemental/issues/320
And I go to "/admin/pages/edit/show/6"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@javascript
Feature: Delete elements in the CMS
Feature: Archive elements in the CMS
As a CMS user
I want to delete elements in the CMS
I want to archive elements in the CMS
So that I can remove elements I have used on a page


Background:
Given I am logged in with "ADMIN" permissions
And I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "Alice's Block" content element with "Some content" content
And the "page" "Blocks Page" has a "Bob's Block" content element with "Some content II" content

Given I am logged in with "ADMIN" permissions
# Remove with 'And I click "Blocks Page" in the ".breadcrumbs-wrapper" element' once the ElementalArea refreshes,
# See https://github.com/dnadesign/silverstripe-elemental/issues/320
And I go to "/admin/pages/edit/show/6"
Expand All @@ -19,13 +19,15 @@ Feature: Delete elements in the CMS
And I should see "Bob's Block"

@modal
Scenario: I can delete a block
Scenario: I can archive a block
Given I wait until I see the ".element-editor__element" element
When I should see the delete button for block 1
And I click on the delete button for block 1
And I see the text "Are you sure you want to delete this block?" in the alert
When I press the "View actions" button
Then I should see the archive button for block 1
When I press the "Archive" button
And I see the text "Are you sure you want to send this block to the archive?" in the alert
And I confirm the dialog
And I wait for 2 seconds
# Sometimes behat can be quicker than the time it takes the JS to remove the row...
And I wait 1 second
And I wait until I see the ".element-editor__element" element
Then I should see "Bob's Block"
But I should not see "Alice's Block"
13 changes: 8 additions & 5 deletions tests/Behat/features/edit-block-element.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ Feature: Edit elements in the CMS
So that I can modify elements I have used on a page

Background:
Given I am logged in with "ADMIN" permissions
And I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "Alice's Block" content element with "Some content" content
And the "page" "Blocks Page" has a "Bob's Block" content element with "Some content II" content

Given I am logged in with "ADMIN" permissions
# Remove with 'And I click "Blocks Page" in the ".breadcrumbs-wrapper" element' once the ElementalArea refreshes,
# See https://github.com/dnadesign/silverstripe-elemental/issues/320
And I go to "/admin/pages/edit/show/6"
And I wait until I see the ".element-editor__element" element
Then I should see "Alice's Block"
And I should see "Bob's Block"

Scenario: I can edit a block
Given I wait until I see the ".element-editor__element" element
Scenario: I can edit a non in-line editable block
Given content blocks are not in-line editable
And I go to "/admin/pages/edit/show/6"
And I wait until I see the ".element-editor__element" element
Then I should see block 1

Given I click on block 1
Expand All @@ -29,5 +32,5 @@ Feature: Edit elements in the CMS
And I press the "Publish" button
Then I should see a "Published content block" message
When I go to "/admin/pages/edit/show/6"
Then I should see "Eve's Block"
Then I should see "Eve's Block"
But I should not see "Alice's Block"
25 changes: 19 additions & 6 deletions tests/Behat/features/element-editor.feature
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
@javascript
Feature: View types of elements in the elemental editor
Feature: View types of elements in an area on a page
As a CMS user
I want to view a list of elements in the CMS
So that I can see which elements I have used on a page
I want to view a list of elements that I have on a page
So that I can manage these elements individually

Background:
Given I am logged in with "ADMIN" permissions
And I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "Alice's Block" content element with "Some content" content
And the "page" "Blocks Page" has a "Bob's Block" content element with "Some content II" content

Given I am logged in with "ADMIN" permissions
And I go to "/admin/pages/edit/show/6"
And I wait until I see the ".element-editor__element" element
And I wait until I see the ".elemental-editor__list" element
Then I should see "Alice's Block"
And I should see "Bob's Block"

Expand All @@ -22,6 +23,18 @@ Feature: View types of elements in the elemental editor
And I should see "Bob's Block" as the title for block 2
And I should see "Some content II" as the summary for block 2

Scenario: I can preview a block
Given I wait until I see the ".element-editor__element" element
Then I should see block 1
Given I click on block 1
# Needs rewrite once the FormBuilder component is fully functional.
# Test checks only if placeholder text is rendered.
Then I should see "Imagine some fancy form builder here!"

Scenario: Opening the "more actions" menu will not expand a block
When I press the "View actions" button
Then I should not see "Imagine some fancy form builder here!"

Scenario: I can see the block type when I hover over an element's icon
Given I wait until I see the ".element-editor__element" element
When I hover over the icon of block 1
Expand Down

0 comments on commit 2b07d52

Please sign in to comment.