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(login): warn when re-running cy.login with same uid but different role #267

Open
itsravenous opened this issue Jan 5, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@itsravenous
Copy link

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"

@prescottprue prescottprue added the enhancement New feature or request label Jan 6, 2021
@prescottprue 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
@darrelfrancis
Copy link
Contributor

I am not sure this is a priority for you @prescottprue

I quite often log in again without logging out. I wouldn't do extensive work in response to one person spending 5 minutes to track down a bug! 8-)

@Aliwahid17
Copy link

Aliwahid17 commented Nov 15, 2022

cy.login() is not working

Error

defaultApp.auth is not a function

`
48 | function getAuth(tenantId) {

49 | const auth = defaultApp.auth() ;
| ^
50 | if (tenantId) {
51 | auth.tenantId = tenantId;
52 | }

`

@prescottprue
Copy link
Owner

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants