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

Create tests for OrganizationDashboard.tsx #1577

Closed

Conversation

Sauradip07
Copy link
Contributor

Create tests for src/screens/OrganizationDashboard/OrganizationDashboard.tsx

Issue Number:

Fixes #1132

Did you add tests for your changes?
Yes

Snapshots/Videos:

Screenshot from 2024-02-06 15-20-51

Screenshot from 2024-02-06 15-21-11

Summary

Lines 86-94 & Lines 239-241 weren't covered by the tests It seems that Upcoming Events are mainly not covered
which introduce in Last PR of this File

Other information

I try to cover the entire useEffect hook
for Line 86 to 94

  // UseEffect to update upcomingEvents array
  useEffect(() => {
    if (eventData && eventData?.eventsByOrganizationConnection.length > 0) {
      const tempUpcomingEvents: InterfaceQueryOrganizationEventListItem[] = [];
      eventData?.eventsByOrganizationConnection.map((event: any) => {
        const startDate = new Date(event.startDate);
        const now = new Date();
        if (startDate > now) {
          tempUpcomingEvents.push(event);
        }
      });
      setUpcomingEvents(tempUpcomingEvents);
    }
  }, [eventData?.eventsByOrganizationConnection]);

The 239 to 241 is already Covered but not showed in Codecov
Have you read the contributing guide?

Yes

Please feel free to reach out if there are any modifications or any changes need to be made.

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

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
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

codecov bot commented Feb 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.65%. Comparing base (6c44d96) to head (50362ef).
Report is 27 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1577   +/-   ##
========================================
  Coverage    96.65%   96.65%           
========================================
  Files          136      136           
  Lines         3587     3587           
  Branches      1101     1101           
========================================
  Hits          3467     3467           
  Misses         114      114           
  Partials         6        6           

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

@Sauradip07
Copy link
Contributor Author

Sauradip07 commented Feb 11, 2024

@palisadoes Please Check I create a Fresh PR for #1549
Again Sorry For the inconvenience

@noman2002
Copy link
Member

@Sauradip07 Why the coverage has not increased?

@Sauradip07
Copy link
Contributor Author

@noman2002
The Test is Wait for useEffect: wait() is called to ensure any useEffect hooks inside the Organization Dashboard component have executed and also the test checks whether certain elements (Upcoming Eventsand Latest Posts) are rendered, indicating that the state has been updated properly.
Overall, this test suite checks for the OrganizationDashboard component, including state updates, logic execution.It ensures that the component behaves correctly under different conditions and renders the expected content.

I don't know why the coverage has not increased.
I google it but not found any relevent Informatation about it if Possible please suggest what's i need to do.

@rishav-jha-mech
Copy link
Contributor

@Sauradip07 have you tried using jest preview and checked the code coverage from the html file that gets updated everytime you make a change to your tests ?

@Sauradip07
Copy link
Contributor Author

@rishav-jha-mech
Yes, I used jest preview and checked the code coverage from the HTML file
I try to cover the entire useEffect hook and after all changes I don't know why this coverage has not increased
if you find any mistake in my code changes, please point it out, and I am continuously research on it why coverage is not increased.
If you have any suggestion, Please feel free to suggest.
Screenshot from 2024-02-13 18-53-59

@palisadoes
Copy link
Contributor

NOTE Read very carefully

  1. We just merged this PR which upgraded the prettier package.
    1. Upgraded prettier from 2.3.2 to 3.2.5 #1599
  2. It reformatted over 150 files.

This will put your PR at risk of extensive merge conflicts. Do the following IN THIS ORDER:

  1. upgrade your prettier in your local branch to the same version
  2. run prettier on your local branch
  3. update your local branch with the latest upstream

This will help to reduce the number of existing and future merge conflicts for your PR.

@rishav-jha-mech
Copy link
Contributor

@Sauradip07 for some reason, the code under the if condition is not getting executed, you need to check if the mocks are correct or not

Copy link

This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.

@github-actions github-actions bot added the no-pr-activity No pull request activity label Feb 29, 2024
@palisadoes
Copy link
Contributor

Closing due to inactivity

@palisadoes palisadoes closed this Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-pr-activity No pull request activity Ready 4 PR Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants