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 elemental searchable fields #1209

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
19 changes: 19 additions & 0 deletions tests/Behat/Context/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\Queries\SQLInsert;
use SilverStripe\FrameworkTest\Elemental\Model\ElementalSearchableFieldsBlock;

/**
* Context used to create fixtures in the SilverStripe ORM.
Expand Down Expand Up @@ -44,6 +45,24 @@ public function theHasAContentElementWithContent($type, $pageTitle, $elementTitl
}
}

/**
* @Given /a "([^"]+)" "([^"]+)" with a "([^"]+)" element titled "([^"]+)"/
*
* e.g. Given a "page" "My page" with a "My\App\MyBlock" element titled "Some block"
*
* @param string $type - will be converted to a class name
* @param string $pageTitle
* @param string $elementClass
* @param string $elementTitle
*/
public function theDataObjectWithAnElement($type, $pageTitle, $elementClass, $elementTitle)
{
$elementalArea = $this->getElementalArea($type, $pageTitle);
$elementalArea->Elements()->add(
$this->getFixtureFactory()->createObject($elementClass, $elementTitle)
);
}

/**
* @Given /(?:the|a) "([^"]+)" "([^"]+)" (?:with|has) a broken element named "([^"]+)"/
*/
Expand Down
39 changes: 39 additions & 0 deletions tests/Behat/features/searchable-dropdown-fields.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@javascript
Feature: Searchable fields
As a CMS user
I want searchable dropdown fields to function when used in a content block
So that I can continue to update my content

Background:
Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class
And a "page" "Blocks Page" with a "SilverStripe\FrameworkTest\Elemental\Model\ElementalSearchableFieldsBlock" element titled "My block"
And a "SilverStripe\FrameworkTest\Model\Company" "test-1"
And a "SilverStripe\FrameworkTest\Model\Company" "test-2"
And a "SilverStripe\FrameworkTest\Model\Company" "test-3"
Given the "group" "EDITOR" has permissions "Access to 'Pages' section"
And I am logged in as a member of "EDITOR" group
And I go to "/admin/pages"
And I left click on "Blocks Page" in the tree
When I see a list of blocks
Then I should see "My block"
When I click on block 1

Scenario: I can use lazy-loaded searchable dropdown fields
When I click on the "#Form_ElementForm_1_PageElements_1_CompanyID .ss-searchable-dropdown-field__value-container" element
And I type "test-1" in the field
And I wait 2 seconds
And I press the "Enter" key globally
When I click on the "#Form_ElementForm_1_PageElements_1_Companys .ss-searchable-dropdown-field__value-container" element
And I type "test-2" in the field
And I wait 2 seconds
And I press the "Enter" key globally
And I type "test-3" in the field
And I wait 2 seconds
And I press the "Enter" key globally
When I press the "View actions" button
And I press the "Save" button
And I wait 1 second
Then I should see a "Saved 'My block' successfully" success toast
And I should see "test-1"
And I should see "test-2"
And I should see "test-3"
Loading