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

test: logged in user gets redirected to Home with username on main Navigation bar #288

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

rkraeher
Copy link

@rkraeher rkraeher commented Feb 27, 2022

Description

  • Fixes Test: Write test successful login user gets redirected to Homepage with username on main navbar #33

  • Adds a test to check that the Login component will redirect to Home after a successful login (or when directly accessing the /login route).

  • The issue also requires a test to check that the logged in user's username is displayed on the Navigation bar after being redirected to Home. As this is really checking Navigation component functionality, not Login, I have added a separate test file for Navigation

  • The Login test requires an import of the history dependency

Type of Change:

  • Quality Assurance

How Has This Been Tested?

  • npm run test

Checklist:

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged

Code/Quality Assurance Only

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been published in downstream modules

@welcome
Copy link

welcome bot commented Feb 27, 2022

Hello there!👋 Welcome to the project!💖

Thank you and congrats🎉 for opening your first pull request.✨ AnitaB.org is an inclusive community, committed to creating a safe and positive environment.🌸Please adhere to our Code of Conduct and Contribution Guidelines.🙌.We will get back to you as soon as we can.😄

Feel free to join us on AnitaB.org Open Source Zulip Community.💖 We have different streams for each active repository for discussions.✨ Hope you have a great time there!😄

@rkraeher rkraeher marked this pull request as draft February 27, 2022 19:08
@rkraeher rkraeher changed the title test: WIP test for redirect after successful login test: for logged in user gets redirected to Home with username on main Navigation bar Mar 4, 2022
@rkraeher rkraeher changed the title test: for logged in user gets redirected to Home with username on main Navigation bar test: logged in user gets redirected to Home with username on main Navigation bar Mar 4, 2022
@rkraeher
Copy link
Author

rkraeher commented Mar 4, 2022

Merge Conflict

Currently there is a merge conflict between this PR branch and development. The merge stems from two conflicting uses of Router from 'react-router-dom'.

Description

development uses an import alias for BrowserRouter. Right now I have simply added an alias for the Router object (calling it Redirect), as my test is the only one that needs it. BrowserRouter object will not work for the new test from this PR because the test mocks history.replace function that is used by the real Redirect component in the implementation of Login. But BrowserRouter does not accept the history prop, so I must use Router, not BrowserRouter for the redirect test. See docs

Possible Solution

This seems like a confusing and misleading alias usage, since in the test we use aliases, but both of those aliases are overriding the default export names of different package objects. I think a better solution would be to remove the BrowserRouter as Router alias and just import both BrowserRouter and Router from the package with their default export names.

@rkraeher rkraeher marked this pull request as ready for review March 4, 2022 22:29
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.

Test: Write test successful login user gets redirected to Homepage with username on main navbar
1 participant