Open
Conversation
…eeks. Add tests for existing period types
Member
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
xurxodev
requested changes
Mar 20, 2026
xurxodev
left a comment
There was a problem hiding this comment.
thanks @nshandra
This PR expands the supported DHIS2 dataset period types and adds a new TypeScript implementation of buildAllPossiblePeriods, along with Jest coverage for all newly added variants.
It's great.
I've found some issues to review.
1. Should fix
src/domain/entities/DataForm.tsdeclaresperiodType?: DataFormPeriod, butsrc/webapp/utils/periods.tscan throw for missing/unsupportedperiodType.
buildAllPossiblePeriodsshould not throw whenperiodTypeis missing; either acceptperiodType?: DataFormPeriodand return[], or add an early guard in the function.- Improve type safety/readability in
src/webapp/utils/periods.tsand push it towards a more functional/immutable style without introducing mutableletstate. It's safe this change because now we have unit test. Examples:- eliminate
let current;ingenerateSixMonthlyNovPeriodsby computingcurrentas aconstexpression (ternary) and, where feasible, useclone().add(...)to avoid mutating Moment instances; - type the accumulator/output arrays explicitly (e.g.
const dates: string[] = []) so the contract is clear at a glance; - make intermediate values explicit/typed in helpers (so the types of
start/end/currentand formatting pieces are obvious during review).
- eliminate
2. Recommendations non blocking
- Tests status:
src/test/utils/periods.spec.tscovers the newly added period variants and passes (yarn test --runInBand src/test/utils/periods.spec.ts). Consider adding a couple more edge cases (e.g.startDate > endDate) to validate robustness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 References
📝 Implementation
Added the following dataSet periods:
WeeklyWednesdayWeeklyThursdayWeeklySaturdayWeeklySundayBiWeeklyBiMonthlyQuarterlyNovSixMonthlySixMonthlyAprilSixMonthlyNovAdded tests for all periods.
🔥 Notes for the reviewer
📹 Screenshots/Screen capture
📑 Others
#869b9v6pp