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

[Outreachy Task Submission] Fix irregularities for e2e testing in Localhost vs Live deployment for login.cy.js #1003

Closed
wants to merge 2 commits into from

Conversation

Chiemezuo
Copy link
Contributor

@Chiemezuo Chiemezuo commented Apr 5, 2024

Introduction

This fixes #4914. E2E testing for the login.cy.js started performing as expected for me in both Localhost and Live deployments.

My approach

I tweaked the following things:

  • I added a delay between opening the site and clicking through the onboarding, because every now and then I would see problems with the onboarding-button-greeting not being found.
  • I commented out the change_language() method because the language selector doesn't always appear in Localhost.
  • I changed the minimum password length to 5 because of the default admin password. This is purely for testing purposes.
  • I changed the user details checker to only look for the presence of a profile avatar, because that exists for every logged in user, whereas with localhost, name and email don't always show by the left.
  • I added a failsafe email and password for users who might have forgotten to configure their env.json file, and also for the CI/CD checks to not fail due to an absence of environment variables.

How to test this PR

  1. In your cloned (and updated) codebase, navigate to the e2e-testing folder.
  2. In the cypress.env.json file, if not already so, change the baseURL to http://localhost:4200.
  3. With the other properties empty, run npm run start in your command line.
  4. Monitor for the feedback for 1-login. You will notice a failure response.
  5. Checkout to this branch.
  6. Repeat steps 2 and 3.
  7. This time around, the 1-login passes.

Video

Here's a video I did after making these changes:

e2e.login.edit.-.Made.with.Clipchamp.mp4

Copy link
Contributor

@AmTryingMyBest AmTryingMyBest left a comment

Choose a reason for hiding this comment

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

The irregularities noted cause issues when running the tests locally. However the tests as set up run correctly(on the CI - which is where we need them to run correctly). Suggested changes in this PR will therefore not be approved for merging.
An update to the documentation will however be made to guide running the tests locally with minimal fuss.
Thanks.

}

click_login_button() {
cy.get(LoginLocators.loginButton).click();
cy.wait(5000);
Copy link
Contributor

Choose a reason for hiding this comment

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

An explicit 5 second wait is way too long. Explicit waits (even as short as 1second) are generally bad practice and should be avoided always unless totally unavoidable.
Also this is unnecessary at this point. There have been no issues at this step running this locally. I will ask you remove this wait.

this.click_through_onboarding();
this.change_laguage();
// this.change_laguage();
Copy link
Contributor

Choose a reason for hiding this comment

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

In the CI environment, the platform will always launch in non-english language. Why this happens, is unknown. That's why we have this step in the login process.
What to do, is disable this step to change the language when running the tests locally. :)

@@ -60,8 +59,8 @@ class LoginFunctions {
}

verify_login() {
cy.get(LoginLocators.loginButton).should('not.exist');
cy.get(LoginLocators.accountBtn).should('exist');
cy.get(LoginLocators.loginButton).should('exist');
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes don't look right.
On logging in, the loginButton should not exist, and the accountButton should exist.
Maybe we may need to change from existing to visibility instead i.e change should('not.exist') to should('be.visible') instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I thought that on verification of logging in, it should be the other way around.
Also, I did this because when I was running it on my local machine, there were inconsistencies when I ran it several different times.

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.

[Outreachy Task Submission] Irregularities in e2e testing via Localhost vs Live deployment for login.cy.js
2 participants