Skip to content

[test]: unit tests for Statistics - #8643

Open
kwhuber wants to merge 1 commit into
mainfrom
issue-8582
Open

kwhuber wants to merge 1 commit into
mainfrom
issue-8582

Conversation

@kwhuber

@kwhuber kwhuber commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #8582

Summary by CodeRabbit

  • Tests
    • Added coverage for default statistics layouts, initial data selection, backend response handling, and refresh behavior.
    • Verified handling of empty responses, formatting, expanded items, and avoiding repeat requests.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ebbbdaaa-1265-4777-b801-ad8e34bda07d
📥 Commits

Reviewing files that changed from the base of the PR and between 3dc37c8 and c45cabc.

📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/Statistics/__tests__/initialLoad.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The change adds unit tests for statistics layout generation, initial loading, backend-response application, layout clearing, and refresh behavior.

Changes

Statistics test coverage

Layer / File(s) Summary
Default layout generation
specifyweb/frontend/js_src/lib/components/Statistics/__tests__/initialLoad.test.ts
Tests assert generated page and category ordering, default statistic contents, initial values and timestamps, and empty-spec behavior.
Initial loading and response application
specifyweb/frontend/js_src/lib/components/Statistics/__tests__/initialLoad.test.ts
Tests assert backend and dynamic-query selection, response application, phantom-item expansion, formatting, and repeat-request behavior.
Layout clearing and refresh
specifyweb/frontend/js_src/lib/components/Statistics/__tests__/initialLoad.test.ts
Tests assert that clearing resets timestamps and values while retaining definitions. Refresh tests check outcomes for missing, unparsable, recent, stale, and future timestamps.

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to c45ca

No actionable issue was established in this test change; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning [#8582] requires unit tests for the Statistics checklist. initialLoad.test.ts covers generated layouts, fetch selection, backend responses, clearing, and refresh logic. It does not test initial load… Add automated tests for the remaining #8582 checklist behaviors, including Statistics UI initial loading, page and statistic management, TSV export, preferences, and edit-permission controls and policies.
Testing Instructions ⚠️ Warning The PR description only says “Fixes #8582” and gives no testing instructions. The PR adds Statistics/__tests__/initialLoad.test.ts, which tests default-layout generation, initial backend and dynamic… Add a testing-instructions section to the PR description. For example: “From specifyweb/frontend/js_src, run npm run unitTests -- lib/components/Statistics/__tests__/initialLoad.test.ts. This suite covers default-layout generation, init…
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the pull request as adding unit tests for Statistics, which matches the changeset.
Out of Scope Changes check ✅ Passed The pull request adds tests in the Statistics test directory. The tests cover Statistics layout and initial-load behavior, which directly supports [#8582]. No unrelated changes appear in the whole-pul…
Automatic Tests ✅ Passed The PR adds initialLoad.test.ts with Jest describe and test cases for Statistics initial-load behavior. The Jest configuration matches **/__tests__/**/*.test.[jt]s?(x), so it includes this fil…
Full details: Linked Issues check

Explanation

[#8582] requires unit tests for the Statistics checklist. initialLoad.test.ts covers generated layouts, fetch selection, backend responses, clearing, and refresh logic. It does not test initial loading through the Statistics UI or the requested page, category, and statistic create/edit/delete flows; duplicate names; TSV export; button-color preferences; or edit permissions and role policies. These are concrete unmet coding and test requirements.

Full details: Testing Instructions

Explanation

The PR description only says “Fixes #8582” and gives no testing instructions. The PR adds Statistics/__tests__/initialLoad.test.ts, which tests default-layout generation, initial backend and dynamic-query selection, backend-response application, and refresh behavior. The repository PR template includes a “Testing instructions” section. The frontend package provides a Jest unitTests script, but the PR does not say how to run the new tests or what they cover.

Resolution

Add a testing-instructions section to the PR description. For example: “From specifyweb/frontend/js_src, run npm run unitTests -- lib/components/Statistics/__tests__/initialLoad.test.ts. This suite covers default-layout generation, initial backend and dynamic-query selection, backend-response application, layout clearing, and refresh behavior.”

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

[test]: unit tests for Statistics

1 participant