You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
This is really down to laziness/absent-mindedness, but I had a series of tests that each visited the same page but logged in with a different custom claim (to assert the presence of various UI elements which show or not depending on the user's role).
I was confused as to why I was seeing these assertions failing, when while testing manually the app's behaviour was correct.
The problem was that I'd forgotten to add an afterEach with cy.logout(), and because I was using the same uid in each cy.login call, the role didn't change between the tests (presumably no re-login took place at all).
If I hadn't had coffee this morning then I might have spent longer than I did (maybe five minutes) figuring out what was going on.
Describe the solution you'd like
A warning along the lines of "cy.login() called with the same uid as the currently logged-in user. This will have no effect, even if different custom claims have been passed. Call cy.logout() first, or use a different uid"
The text was updated successfully, but these errors were encountered:
prescottprue
changed the title
Warn when re-running cy.login with same uid but different role
feat(login): warn when re-running cy.login with same uid but different role
May 2, 2021
@Aliwahid17 It appears that you are having a different problem - could you open a new issue with repro steps?
@itsravenous thanks for the detailed explanation including that you just barley caught it - this type of information is super helpful. As @darrelfrancis called out it is a super common use case to call cy.login again with the same UID intentionally - this was so common in fact that there is currently a cy.log that calls out login of already logged in user which you should be seeing. Can you confirm you are seeing it? Maybe updating that messaging a bit could help?
At the very least we might want to call this out more clearly in the docs. The callout of cy.logout is good, but it also feels like a suggestion of testing different custom claims with different UIDs may help - what are your thoughts?
Is your feature request related to a problem? Please describe.
This is really down to laziness/absent-mindedness, but I had a series of tests that each visited the same page but logged in with a different custom claim (to assert the presence of various UI elements which show or not depending on the user's role).
I was confused as to why I was seeing these assertions failing, when while testing manually the app's behaviour was correct.
The problem was that I'd forgotten to add an
afterEach
withcy.logout()
, and because I was using the sameuid
in eachcy.login
call, the role didn't change between the tests (presumably no re-login took place at all).If I hadn't had coffee this morning then I might have spent longer than I did (maybe five minutes) figuring out what was going on.
Describe the solution you'd like
A warning along the lines of "cy.login() called with the same uid as the currently logged-in user. This will have no effect, even if different custom claims have been passed. Call cy.logout() first, or use a different uid"
The text was updated successfully, but these errors were encountered: