Skip to content

test: add tests for js/widgets/statistics.js#5222

Open
Om-A-osc wants to merge 3 commits intosugarlabs:masterfrom
Om-A-osc:test/statistics-jest
Open

test: add tests for js/widgets/statistics.js#5222
Om-A-osc wants to merge 3 commits intosugarlabs:masterfrom
Om-A-osc:test/statistics-jest

Conversation

@Om-A-osc
Copy link
Contributor

Resolves #5221

Add Jest tests for statistics.js widget

This PR adds unit tests for the StatsWindow widget (js/widgets/statistics.js).

Highlights:

  • Improves test coverage for statistics.js from 0% to 100%
  • Adds Jest tests covering constructor initialization, widget lifecycle callbacks (onclose, onmaximize)
  • Verifies doAnalytics() behavior, including analytics execution, chart creation, and DOM updates
  • Tests displayInfo() to ensure statistics are rendered correctly
  • Uses mocks for DOM APIs, Chart.js, and global helpers to keep tests deterministic and fast

This is a test-only change and does not modify runtime behavior.
teststatistics

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Om-A-osc
Copy link
Contributor Author

@omsuneri @walterbender Could you please have a look when convenient?

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Om-A-osc
Copy link
Contributor Author

@walterbender Whenever you have time, I’d appreciate any feedback on this PR.

@walterbender
Copy link
Member

Sorry about being slow to review this.

I think it looks good over all. I do think that since there is another PR, #4972, which covers some of the same ground, it would make sense for you to build upon that initial effort.

@vanshika2720
Copy link
Contributor

@Om-A-osc resolve merge conflicts.

@Om-A-osc Om-A-osc force-pushed the test/statistics-jest branch from 6488c50 to e8a9e7e Compare February 16, 2026 17:34
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Om-A-osc
Copy link
Contributor Author

Screenshot from 2026-02-16 23-05-55

@walterbender @vanshika2720 Done!

@walterbender
Copy link
Member

I think you need to do a rebase before applying your changes. Lots of things are unintentionally removed here.

@Om-A-osc Om-A-osc force-pushed the test/statistics-jest branch from e8a9e7e to 3cfa87d Compare February 22, 2026 06:28
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Om-A-osc
Copy link
Contributor Author

@walterbender I guess it should be ready to merge now. I have rebased and added hardening tests on top of existing code.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Om-A-osc
Copy link
Contributor Author

@walterbender @omsuneri Please have a look guys.

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]: Add missing tests for js/widgets/statistics.js

3 participants