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

Add Behat tests #321

Merged

Conversation

raissanorth
Copy link
Contributor

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.

@raissanorth raissanorth force-pushed the pulls/master/behat-tests branch from 45f684b to 1069f17 Compare August 15, 2018 02:39
Copy link
Contributor

@robbieaverill robbieaverill left a 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"
Copy link
Contributor

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?

Copy link
Contributor

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');
Copy link
Contributor

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();
}
Copy link
Contributor

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"
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I should see...

Copy link
Contributor Author

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);
    }

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given/When

@raissanorth raissanorth force-pushed the pulls/master/behat-tests branch from 1069f17 to be3d953 Compare August 15, 2018 05:02
@robbieaverill robbieaverill merged commit e5ee2ca into silverstripe:master Aug 15, 2018
@robbieaverill robbieaverill deleted the pulls/master/behat-tests branch August 15, 2018 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants