Skip to content

Conversation

@TavoNiievez
Copy link
Member

This function verifies that there is a flash message in the session. See docblock for full description.

@TavoNiievez TavoNiievez marked this pull request as ready for review November 19, 2020 17:46
@Naktibalda
Copy link
Member

Is this method really necessary?

Flash message should be rendered by the next page and it can be tested using see method, right?
There is no need to stop redirects too .

@TavoNiievez
Copy link
Member Author

TavoNiievez commented Nov 19, 2020

@Naktibalda , thanks for asking.
Please refer to this issue. Codeception/Codeception#5351
There are difficulties asserting flash messages in functional tests due to limitations of phpbrowser.

Although this method does not verify that the message is displayed on the screen as it would with see, it does verify that the algorithm flow and the symfony session/flashbag are working correctly and as expected.
I think that is what you would like to be able to verify in a functional/framework test.
While that the message is shown on the screen and with the expected selector is what should be verified in an acceptance/browser test.

@TavoNiievez
Copy link
Member Author

TavoNiievez commented Nov 19, 2020

Regarding the need to stop redirects... Yes, it is necessary.
Symfony flash bag works through stacks, which means that as soon as a message is accessed (in this case, rendered in a view) it is removed from the stack. So if you do a redirect the message will not exist in the flashbag at the time of asserting.

Finally, there are scenarios in which not all messages will be displayed in the browser at the same time. Some may depend on the actions of the user, and this is an easy way to assert that the expected messages were included successfully. Even if they are not being shown.

@Naktibalda
Copy link
Member

Naktibalda commented Nov 20, 2020

Codeception/Codeception#5351 requires further investigation, not workaround.

@TavoNiievez
Copy link
Member Author

TavoNiievez commented Nov 20, 2020

I agree.

Edit:: I'll close this for now, it needs more differentiation from the current $I->see() behavior. Technically they work differently, but in practice they behave similarly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants