-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(new-primary-school): mock users dev #17258
Conversation
WalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant Service as NewPrimarySchoolService
participant Environment as EnvironmentChecker
participant DataFilter as ChildDataFilter
Service->>Environment: Check if running in dev environment
alt Dev Environment
Service->>DataFilter: Apply child filtering
DataFilter-->>Service: Return filtered children
else Non-Dev Environment
Service->>Service: Fetch actual children data
end
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts (1)
Line range hint
115-142
: Refactor filtering logic for better maintainabilityThe filtering logic combines multiple concerns and could be split into smaller, more focused functions.
+ const VALID_TEST_CHILDREN = [ + '1111111119', + '2222222229', + '5555555559', + '6666666669', + ] as const; + + const isValidTestChild = (nationalId: string) => + isRunningOnEnvironment('local') && VALID_TEST_CHILDREN.includes(nationalId); + + const isChildOfSchoolAge = (nationalId: string) => { + const yearOfBirth = kennitala.info(nationalId).birthday.getFullYear(); + return yearOfBirth >= minYear && yearOfBirth <= maxYear; + }; + const filteredChildren = children.filter((child) => { - const validChildren = [ - '1111111119', - '2222222229', - '5555555559', - '6666666669', - ] - if ( - isRunningOnEnvironment('local') && - validChildren.includes(child.nationalId) - ) { + if (isValidTestChild(child.nationalId)) { return true; } if (!child.nationalId) { return false; } - const yearOfBirth = kennitala - .info(child.nationalId) - .birthday.getFullYear() - - return ( - child.livesWithApplicant && - yearOfBirth >= minYear && - yearOfBirth <= maxYear - ) + return child.livesWithApplicant && isChildOfSchoolAge(child.nationalId); })
🧹 Nitpick comments (3)
libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts (3)
Line range hint
13-14
: Remove unused import and consider environment constantThe
isRunningInProduction
import is no longer used after switching toisRunningOnEnvironment('dev')
. While the environment check change is an improvement in precision, consider creating a constant for the environment name to avoid magic strings.-import { isRunningInProduction } from '../parental-leave/constants' +const DEV_ENVIRONMENT = 'dev' as const; - if (isRunningOnEnvironment('dev')) { + if (isRunningOnEnvironment(DEV_ENVIRONMENT)) {Also applies to: 42-42
Line range hint
43-93
: Document mock data test scenariosThe mock data provides good coverage of different scenarios, but it would be helpful to document what each national ID represents in terms of test cases.
+ // Test scenarios: + // 0101303019 - Single child case + // 0101302989 - Multiple children with different gender codes + // 0101304929 - Single child with specific age case if (auth.nationalId === '0101303019') {
Line range hint
1-153
: Implementation follows coding guidelines and best practicesThe service implementation adheres to the coding guidelines for libs:
- Properly modular and reusable across NextJS apps
- Strong TypeScript typing throughout
- Follows dependency injection patterns
Consider adding integration tests to verify the environment-specific behavior, especially around the mock data scenarios.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (1)
libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts (1)
Line range hint 144-153
: LGTM! Error handling is well implemented
The error handling uses proper error types, externalized messages, and appropriate HTTP status codes.
Datadog ReportAll test runs ✅ 3 Total Test Services: 0 Failed, 3 Passed Test Services
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17258 +/- ##
=======================================
Coverage 35.73% 35.74%
=======================================
Files 6941 6940 -1
Lines 148396 148389 -7
Branches 42331 42341 +10
=======================================
- Hits 53036 53035 -1
+ Misses 95360 95354 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
51170d1
to
8fead2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
...
Attach a link to issue if relevant
What
Specify what you're trying to achieve
Why
Specify why you need to achieve this
Screenshots / Gifs
Attach Screenshots / Gifs to help reviewers understand the scope of the pull request
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes