Skip to content

removed animated counter#2915

Merged
arkid15r merged 5 commits intoOWASP:mainfrom
anirudhprmar:fix/remove-animated-counter
Dec 16, 2025
Merged

removed animated counter#2915
arkid15r merged 5 commits intoOWASP:mainfrom
anirudhprmar:fix/remove-animated-counter

Conversation

@anirudhprmar
Copy link
Contributor

Proposed change

Resolves #2868

I've removed the usage of animated counter and kept statistics display as text.
While removing the usage of AnimatedCounter.tsx component, I had to update a couple of tests of home page and about page.

Checklist

  • I read and followed the contributing guidelines
  • I ran make check-test locally and all tests passed
  • I used AI for code, documentation, or tests in this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Summary by CodeRabbit

  • Tests

    • Removed AnimatedCounter component test suite
    • Updated project statistics test references
  • Refactor

    • Removed animated counter display; project statistics now show static numbers instead of animating

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR removes the AnimatedCounter component entirely and replaces all its usages with static millified numeric values. Associated test files are removed or updated to reflect the transition from animated counters to static project statistics display.

Changes

Cohort / File(s) Summary
Component Removal
frontend/src/components/AnimatedCounter.tsx
Deleted the AnimatedCounter component that managed animation state via requestAnimationFrame and rendered millified counter values. Also removes its exported interface AnimatedCounterProps.
Page Component Updates
frontend/src/app/page.tsx, frontend/src/app/about/page.tsx
Replaced AnimatedCounter component usage with static millified numeric values. Removed AnimatedCounter imports and added millify imports. Statistics now render as formatted strings (e.g., "1M+") instead of animated transitions.
Test Updates
frontend/__tests__/e2e/pages/About.spec.ts
Renamed test case from "displays animated counters with correct values" to "displays project statistics with correct values" while maintaining existing assertions.
Test File Removals
frontend/__tests__/unit/components/AnimatedCounter.test.tsx
Deleted comprehensive unit test suite covering AnimatedCounter rendering, animation lifecycle, edge cases, accessibility, and performance.
Test Coverage Adjustments
frontend/__tests__/unit/pages/Home.test.tsx
Removed AnimatedCounter test block. Updated stats rendering test to assert static millified values with "+" suffix instead of iterating over animated counter values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify all AnimatedCounter references throughout the codebase have been removed or replaced
  • Confirm this change aligns with the linked issue (which described a bug in animation, not a decision to remove animation)
  • Validate that test coverage adequately reflects the new static rendering behavior
  • Review whether removal of animation functionality is intentional or if the component should be retained and fixed instead

Possibly related PRs

Suggested reviewers

  • kasya

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses issue #2868 by removing the non-functional AnimatedCounter; however, the issue requested fixing the animation, not removing it entirely. The issue #2868 requested fixing the AnimatedCounter animation to work correctly when scrolling. This PR removes the feature instead of fixing it, which does not resolve the stated objective.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'removed animated counter' accurately and concisely describes the main objective of the changeset: removing the AnimatedCounter component and its usage.
Description check ✅ Passed The description is related to the changeset, clearly stating the removal of AnimatedCounter usage and updating related tests.
Out of Scope Changes check ✅ Passed All changes are in-scope: removing AnimatedCounter component usage from pages and updating corresponding test files to reflect the removal.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf95ed and d970660.

📒 Files selected for processing (1)
  • frontend/__tests__/unit/pages/Home.test.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/tests/unit/pages/Home.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Set release version
  • GitHub Check: Run frontend checks
  • GitHub Check: Run pre-commit checks
  • GitHub Check: CodeQL (python)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
frontend/src/app/page.tsx (1)

21-21: Static millified counters look fine, but confirm this is the desired resolution for #2868

Switching the bottom stats to {millify(stat.value)}+ is a straightforward replacement for the previous AnimatedCounter usage and should render readable values.

However, this fully removes the animation behavior rather than fixing it, which is a functional change relative to the original issue request (animate from 0 to target on scroll). Please confirm with maintainers that resolving #2868 by removing animation (instead of repairing it) is acceptable for UX/product goals.

If this is the intended long-term behavior, you may want to document the decision in the issue or PR description so future contributors don’t try to reintroduce animations based on the old requirement.

Also applies to: 376-380

frontend/src/app/about/page.tsx (1)

17-17: Clarify and simplify the millify rounding logic for project stats

Using millify(Math.floor(stat.value / 10 || 0) * 10) will floor to the nearest lower multiple of 10 before millifying, which seems intentional to avoid noisy small changes. The stat.value / 10 || 0 piece, however, is a bit opaque and relies on JS truthiness.

You could make this clearer and safer for nullish values by writing something like:

const roundedValue = Math.floor((stat.value ?? 0) / 10) * 10
const display = `${millify(roundedValue)}+`

and then rendering {display}. This preserves behavior but is easier to read and reason about.

Please also confirm that snapping to the nearest 10 is the intended UX (as opposed to showing the exact count via millify); if not, you can drop the divide/floor/multiply and just use millify(stat.value ?? 0) + '+'.

Also applies to: 292-303

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffb2c2 and f984ea8.

📒 Files selected for processing (6)
  • frontend/__tests__/e2e/pages/About.spec.ts (1 hunks)
  • frontend/__tests__/unit/components/AnimatedCounter.test.tsx (0 hunks)
  • frontend/__tests__/unit/pages/Home.test.tsx (1 hunks)
  • frontend/src/app/about/page.tsx (2 hunks)
  • frontend/src/app/page.tsx (2 hunks)
  • frontend/src/components/AnimatedCounter.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • frontend/tests/unit/components/AnimatedCounter.test.tsx
  • frontend/src/components/AnimatedCounter.tsx
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-11-17T17:30:42.139Z
Learnt from: anurag2787
Repo: OWASP/Nest PR: 2671
File: frontend/__tests__/unit/components/MultiSearch.test.tsx:169-171
Timestamp: 2025-11-17T17:30:42.139Z
Learning: In the OWASP/Nest frontend tests (PR #2671 context), wrapper functions like `expectChaptersCountEqualsThree` that simply call another helper with a fixed parameter (e.g., `expectChaptersCountEquals(3)`) are intentionally used to avoid arrow function callbacks in `waitFor` calls. This pattern prevents adding nesting depth that would trigger rule typescript:S2004. Example: `await waitFor(expectChaptersCountEqualsThree)` avoids the extra nesting from `await waitFor(() => expectChaptersCountEquals(3))`.

Applied to files:

  • frontend/__tests__/e2e/pages/About.spec.ts
  • frontend/__tests__/unit/pages/Home.test.tsx
📚 Learning: 2025-07-12T17:36:57.255Z
Learnt from: Rajgupta36
Repo: OWASP/Nest PR: 1717
File: frontend/__tests__/unit/pages/createProgram.test.tsx:70-86
Timestamp: 2025-07-12T17:36:57.255Z
Learning: When testing React page components that use mocked form components, validation logic should be tested at the form component level, not the page level. Page-level tests should focus on authentication, role checking, submission handling, and navigation logic.

Applied to files:

  • frontend/__tests__/unit/pages/Home.test.tsx
📚 Learning: 2025-11-17T16:47:05.578Z
Learnt from: anurag2787
Repo: OWASP/Nest PR: 2671
File: frontend/__tests__/unit/components/MultiSearch.test.tsx:427-427
Timestamp: 2025-11-17T16:47:05.578Z
Learning: In the frontend test files for the OWASP/Nest repository, `expect(true).toBe(true)` no-op assertions may be intentionally added as workarounds when ESLint rule jest/expect-expect doesn't detect expectations inside helper functions or waitFor callbacks. These can be resolved by configuring the ESLint rule's assertFunctionNames option to recognize custom assertion helpers instead of flagging them as redundant.

Applied to files:

  • frontend/__tests__/unit/pages/Home.test.tsx
🔇 Additional comments (1)
frontend/__tests__/e2e/pages/About.spec.ts (1)

80-85: Test name now correctly reflects non-animated stats

Renaming the test to "displays project statistics with correct values" matches the new static-display behavior without changing assertions. This keeps intent clear without affecting coverage.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 15, 2025
@sonarqubecloud
Copy link

@arkid15r arkid15r enabled auto-merge December 16, 2025 00:28
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

LGTM

@arkid15r arkid15r added this pull request to the merge queue Dec 16, 2025
Merged via the queue into OWASP:main with commit 4249303 Dec 16, 2025
26 checks passed
@anirudhprmar anirudhprmar deleted the fix/remove-animated-counter branch December 16, 2025 03:58
arkid15r added a commit to sameersharmadev/Nest that referenced this pull request Dec 17, 2025
* Refactored: removed animated counter

* updated code

* Update tests

---------

Co-authored-by: Arkadii Yakovets <arkadii.yakovets@owasp.org>
@coderabbitai coderabbitai bot mentioned this pull request Dec 17, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project statistics are not Animating the way they're supposed to animate on Home page

2 participants