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

feat: add commands to assert success messages, error messages and page titles #47

Merged
merged 3 commits into from
Mar 29, 2022

Conversation

kolaente
Copy link
Collaborator

@kolaente kolaente commented Mar 29, 2022

This PR adds a few short helper functions:

  • shouldHavePageTitle
  • shouldHaveSuccessMessage
  • shouldHaveErrorMessage

All of them pretty much do what their title says.

Example usage for checking if a success message is present:

import {shouldHaveSuccessMessage} from '../support/utils'

it('Can add a product to the cart from the product page', () => {
    cy.get(selectors.addToCartButton).click()
    shouldHaveSuccessMessage(`You added ${product.simpleProductName} to your shopping cart.`)
})

@@ -0,0 +1,5 @@
{
"successMessage": ".message-success.success",
"errorMessage": ".message-error",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure how much these selectors differ between hyvä and luma? I've used the commands in luma only so far, so I can't say a lot about hyvä.

@peterjaap
Copy link
Contributor

Could you move the global commands to helper functions? See the first bullet point under Contributing; https://github.com/elgentos/magento2-cypress-testing-suite#contributing

Global commands are bad mmkay.

@kolaente
Copy link
Collaborator Author

Should I remove the login command as well while I'm at it? Looks like it's not used anywhere.

@peterjaap
Copy link
Contributor

Yes please!

@kolaente
Copy link
Collaborator Author

Done!

@peterjaap
Copy link
Contributor

Awesome, thanks!

@peterjaap peterjaap merged commit dc5ebde into elgentos:main Mar 29, 2022
@kolaente kolaente deleted the feature/message branch March 29, 2022 08:26
@kolaente kolaente mentioned this pull request Mar 29, 2022
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