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

NEW LinkField Behat tests #201

Merged

Conversation

sabina-talipova
Copy link
Contributor

@sabina-talipova sabina-talipova commented Feb 5, 2024

Description

These changes add integration testing and test the operation of the linkfield as part of the SMS page and as part of the Elemental Block. The tests cover the following main aspects of the module's operation:

  • User can create link in LinkField / MultiLinkField
  • User can modify link in LinkField / MultiLinkField
  • User can see current versioned state of created links
  • User can reorder links
  • User can delete links

Parent issue

New issue

A problem was identified when using Mock classes that implement the TestOnly interface in Behat tests. Most likely, these classes are ignored when creating database tables, making it impossible to test complex relationships between classes.

Note

  • This PR was tested together with silverstripe / frameworktest and passed. See here

@sabina-talipova sabina-talipova force-pushed the pulls/4/linkfield-behat-tests branch 11 times, most recently from b24c9b7 to bb1c998 Compare February 7, 2024 23:42
@sabina-talipova sabina-talipova marked this pull request as ready for review February 7, 2024 23:52
@sabina-talipova
Copy link
Contributor Author

Failed tests require silverstripe/silverstripe-frameworktest#162

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

You've committed the two behat files with tabs instead of spaces. Please use 2 spaces per indent.

As per the frameworktest PR, copy in code form that PR as extensions and update this test to use those here

Comment on lines 100 to 108
# Test that user can reorder links

## These test steps give inconsistent results, not always passed
# And I drag the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element to the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-last" element
# And I wait for 5 seconds
# Then I press the "Publish" button
# Then I click on the ".element-editor__element" element
# And I should see "All about us" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-last" element
# And I should see "Phone" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Test that user can reorder links
## These test steps give inconsistent results, not always passed
# And I drag the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element to the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-last" element
# And I wait for 5 seconds
# Then I press the "Publish" button
# Then I click on the ".element-editor__element" element
# And I should see "All about us" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-last" element
# And I should see "Phone" in the "#Form_ElementForm_1_PageElements_1_ManyLinks_Holder .link-picker__link--is-first" element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

I want to add links to pages, files, external URLs, email addresses and phone numbers

Background:
Given I add an extension "SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension" to the "Page" class
Copy link
Member

Choose a reason for hiding this comment

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

Update this to the new namespace of the extension copied in from the frameworktest PR
Also add in the new ElementContent extension I've mentioned on the frameworktest PR

Do this for the other behat file as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

And I wait for 5 seconds
Then I should see "Link to external URL" in the ".modal-header" element
Then I fill in "Form_LinkForm_0_Title" with "External URL"
Then I fill in "Form_LinkForm_0_ExternalUrl" with "https://www.silverstripe.org"
Copy link
Member

Choose a reason for hiding this comment

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

Also add in a quick test here with an invalid URL to test that validation is working, then update it to a valid url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 33 to 34


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@sabina-talipova sabina-talipova force-pushed the pulls/4/linkfield-behat-tests branch 3 times, most recently from 3b358d5 to 294da79 Compare February 9, 2024 01:20
Then I should see "Page on this site" in the ".modal-header" element
And I wait for 2 seconds
And I press the "Create link" button
Then I should see "Page is required" in the ".modal-content" element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add test for validation

And I wait for 5 seconds
Then I should see "Link to external URL" in the ".modal-header" element
Then I fill in "Form_LinkForm_0_LinkText" with "External URL"
And I fill in "Form_LinkForm_0_ExternalUrl" with "w1234@$%"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add test for invalid URL

Scenario: I can create link blocks page
Given I press the "Add block" button
# There are few buttons on the page with 'Content' text
Then I click on the ".font-icon-block-content" element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to change this to class name since there are more than one "Content" button on the page


Background:
Given I add an extension "SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension" to the "Page" class
And I go to "/dev/build?flush"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should rebuild DB after new Extension was applied.

@sabina-talipova
Copy link
Contributor Author

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

You still need to update the behat files to use spaces instead of tabs

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Will merge once the corresponding frameworktest PR is merge

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

You'll need to add "silverstripe/frameworktest": "^1" to "require-dev" in composer.json

@sabina-talipova
Copy link
Contributor Author

Updated. Sorry, I removed and forgot to return back.

@emteknetnz emteknetnz merged commit f3de6ac into silverstripe:4 Feb 13, 2024
12 checks passed
@emteknetnz emteknetnz deleted the pulls/4/linkfield-behat-tests branch February 13, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants