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

Replace all hard coded localhosts with env constant variables #1497

Conversation

NayOoLwin5
Copy link

@NayOoLwin5 NayOoLwin5 commented Jan 25, 2024

What kind of change does this PR introduce?

Replacement of all hard coded localhost urls in places with environment constant variables.

Issue Number:

Fixes #1244

Did you add tests for your changes?

Snapshots/Videos:
Screenshot 2024-01-25 at 20 23 40

If relevant, did you update the documentation?

Yes

Summary

  • With PR feat: Updated Talawa Admin to use custom port #1488 merged, I had to introduce new env variable REACT_ADMIN_FRONTEND_HOST for two test files to access host IP and port separately and wrote a prompt for it in setup
  • Leaving hard coded localhost in file /src/components/AddOn/support/services/Plugin.helper.ts as I was informed it is outdated and no longer used

Does this PR introduce a breaking change?

Other information

Have you read the contributing guide?

Yes

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congratulations on making your first PR! 🎊 If you haven't already, check out our Contributing Guidelines and PR Reporting Guidelines to ensure that you are following our guidelines for contributing and creating PR.

@Cioppolo14
Copy link

@NayOoLwin5 Please fix the test application failing tests.

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

  1. I don't see the need to create the REACT_ADMIN_FRONTEND_HOST variable when relative variables would seem to be equally suitable.
  2. Let us know why this is necessary
  3. The replacement of localhost with the BACKEND_URL is clearly necessary.

src/screens/LoginPage/LoginPage.test.tsx Show resolved Hide resolved
src/screens/UserPortal/Home/Home.test.tsx Outdated Show resolved Hide resolved
src/screens/EventDashboard/EventDashboard.test.tsx Outdated Show resolved Hide resolved
@NayOoLwin5
Copy link
Author

  • I checked and found out all test files have its mock responses against the localhost. Therefore, no need of dynamic env variables. Thanks for pointing them out.
  • However, running tests only with relative url resulting in failures. Thus, I kept them same as it was. Please review and let me know if anything more needed to be fixed.

@palisadoes

@palisadoes palisadoes self-requested a review January 26, 2024 21:11
@palisadoes
Copy link
Contributor

Please fix the failing tests

@NayOoLwin5
Copy link
Author

  • I cannot reproduce the test failures on my machine even though using node version 20.
  • However, I tested the login page manually by myself and the fetch checks are working as expected with my new changes.
  • No changes to the failed test files also as I changed back to previously existing code.

Please let me know how I can reproduce the failed tests. @palisadoes

@palisadoes
Copy link
Contributor

  1. Scroll down in the test box
  2. Click on this link
  3. It is explained there

image

@NayOoLwin5
Copy link
Author

Hi @palisadoes, the test should work fine now. The issue was removing dynamic env BACKEND_URL variable from the test files as the value in fetch expect the same as that is parsed in fetch in the components. Added it back and let us check the test again.

Copy link

codecov bot commented Jan 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c647157) 97.29% compared to head (e640521) 97.29%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1497   +/-   ##
========================================
  Coverage    97.29%   97.29%           
========================================
  Files          132      132           
  Lines         3395     3396    +1     
  Branches      1038     1038           
========================================
+ Hits          3303     3304    +1     
  Misses          87       87           
  Partials         5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@palisadoes palisadoes merged commit 35bc19f into PalisadoesFoundation:develop Jan 27, 2024
10 checks passed
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.

3 participants