-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add Behat tests #321
Add Behat tests #321
Conversation
45f684b
to
1069f17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I think the feature definition file could be split up into individual features like add block, edit block, delete block etc, but as you noted in your PR there's some refactoring to do once we work out how to do element fixtures properly.
I've left some other comments too
<Input type="select" className="no-change-track" onChange={this.handleTypeChange}> | ||
<Input | ||
type="select" | ||
id="elemental-editor_add-new-block-control_select-dropdown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that pages can have multiple elemental areas. While we haven't been strongly keeping this in mind while doing our development, this wouldn't work with two or more editors since IDs must be unique. Can you add classes instead please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to leave this for now, since this control will be relatively temporary
{ | ||
$block = $this->getSpecificBlock($position); | ||
$button = $block->findAll('css', 'Delete'); | ||
assertNotNull($button, 'Delete button not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could combine some logic in this step with iClickOnTheDeleteButtonForBlock
?
$element->write(); | ||
|
||
$page->ElementalArea()->write(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this since we aren't using it at the moment? Also the scaffoldDefaultFixtureFactory
method if it's not needed
# # See: Content element, bundled by default with elemental | ||
# And I should see text matching "HTML text block" | ||
# # Ensure BaseElement is ignored | ||
# And I should not see text matching "Base element class" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally committed this maybe?
And I wait until I see the ".element-editor__element" element | ||
Then I should see "My Sample Block" | ||
|
||
Scenario: I can see the icon, title, and summary of each element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're actually only checking for the title
|
||
Given I fill in "New Block Title" for "Title" | ||
And I fill in "<p>New sample content</p>" for the "HTML" HTML field | ||
And I click "Publish" in the "#Form_ItemEditForm_action_doPublish" element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I press the "Publish" button
if it works
And I wait 1 second | ||
And I fill in "Second Sample Block" for "Title" | ||
And I fill in "<p>Additional sample content</p>" for the "HTML" HTML field | ||
And I click "Create" in the "#Form_ItemEditForm_action_doSave" element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I press the "Create" button
And I should see block 1 | ||
And I should see the delete button for block 1 | ||
|
||
Then I click on the delete button for block 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
*
And I should see the delete button for block 1 | ||
|
||
Then 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I should see...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a predefined step I am utilising from the BasicContext.php
:
/**
* @Given /^I see the text "([^"]+)" in the alert$/
* @param string $expected
*/
public function iSeeTheDialogText($expected)
{
$text = $this->getExpectedAlert()->getText();
assertContains($expected, $text);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright - in lieu of "should" being part of that regex it's ok like it is
|
||
Then 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 | ||
And I confirm the dialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given
/When
1069f17
to
be3d953
Compare
Will need to be refactored once silverstripe/silverstripe-behat-extension#180
and #320 are resolved.
In particular, there is a lot of repetition in the background set up. At the moment we are not able to add elements via fixtures, so we are using the UI to do so. This makes the
I can add elements to the page
scenario somewhat obsolete, but it will be of relevance, once the tests work with a proper fixture set up.