Skip to content
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

feat(j-s): send criminal records to public prosecutor static email #17406

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

thorhildurt
Copy link
Member

@thorhildurt thorhildurt commented Jan 3, 2025

What

  • Asana task
  • In this PR we add a new notification type when criminal records have been added when submitting a case to public prosecutor
    • We need to add new secret to aws parameter store for PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL in all env. Values are already set in 1Password but we need to share with devops for update.
  • Note: This is expected to be a temporary solution until we can integrate directly with the new criminal records system 👀

Why

  • So the criminal records public prosecutor secretary can process the submitted criminal records file.

Screenshots / Gifs

  • New email:
Screenshot 2025-01-03 at 11 55 25

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Added support for sending notifications about criminal record file uploads in the judicial system
    • Introduced a new email configuration for public prosecutor criminal records
  • Configuration

    • Added new secret for public prosecutor criminal records email across development, staging, and production environments
  • Notifications

    • Enhanced notification system to handle criminal record file upload notifications
    • Added new message templates for criminal record file upload emails

@thorhildurt thorhildurt requested review from a team as code owners January 3, 2025 16:31
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-7f8d5899-3b4c-4daa-bd7f-ae5f454184e6 > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning "@nx/eslint > @nx/js > [email protected]" has unmet peer dependency "@types/node@".
warning "@nx/next > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "styled-components > babel-plugin-styled-components > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
warning "@nx/react > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "@types/node@
".
warning " > [email protected]" has incorrect peer dependency "[email protected]".
warning "react-native > @react-native/[email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "react-native > @react-native/community-cli-plugin > @react-native/[email protected]" has unmet peer dependency "@babel/core@*".
warning "@vanilla-extract/next-plugin > @vanilla-extract/[email protected]" has unmet peer dependency "webpack@^4.30.0 || ^5.20.2".
warning " > [email protected]" has incorrect peer dependency "react@^16.13.1 || ^17".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.13.1 || ^17".
warning "next-auth > @next-auth/[email protected]" has unmet peer dependency "@prisma/client@^2.16.1".
warning "@nx/next > [email protected]" has unmet peer dependency "webpack@^5.1.0".

Walkthrough

This pull request introduces a new feature for handling notifications related to criminal record files in the judicial system backend. The changes involve adding a new secret for the public prosecutor's criminal records email, updating notification configurations, and implementing a new notification type for criminal record file uploads. The modifications span multiple files across infrastructure, backend services, and configuration, focusing on enhancing the email notification system for indictment cases.

Changes

File Path Change Summary
apps/judicial-system/backend/infra/judicial-system-backend.ts Added new secret PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL
apps/judicial-system/backend/src/app/messages/notifications.ts Added new notification entry for publicProsecutorCriminalRecords
apps/judicial-system/backend/src/app/modules/notification/notification.config.ts Added publicProsecutorCriminalRecordsEmail configuration parameter
libs/judicial-system/types/src/lib/notification.ts Added CRIMINAL_RECORD_FILES_UPLOADED to IndictmentCaseNotificationType enum
charts/*/values.*.yaml Added PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL secret across dev, staging, and prod environments

Sequence Diagram

sequenceDiagram
    participant Backend as Judicial System Backend
    participant NotificationService as Notification Dispatch Service
    participant EmailService as Email Service
    participant CriminalRecords as Public Prosecutor Criminal Records

    Backend->>NotificationService: Dispatch Indictment Notification
    NotificationService->>NotificationService: Check Case File Categories
    alt Criminal Record Files Uploaded
        NotificationService->>EmailService: Construct Criminal Record Files Notification
        EmailService->>CriminalRecords: Send Notification Email
    end
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • gudjong
  • unakb

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thorhildurt thorhildurt self-assigned this Jan 3, 2025
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: 0

🧹 Nitpick comments (8)
apps/judicial-system/backend/src/app/modules/notification/notification.config.ts (1)

21-24: Ensure default value for new configuration parameter is correct and documented.

Having the default value set to an empty string might lead to unintentional behavior if the environment variable is missing. Consider throwing an error if the environment variable is absent, or provide a descriptive default value in production-like environments. Also, document this new configuration requirement clearly so that maintainers know to set the relevant secret.

apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts (3)

14-17: Check for strong typing in the Then interface.

Your Then interface only captures result and error as broad types. If the DeliverResponse object can contain more specific fields or if the error can be typed (e.g., SomeErrorType), consider specifying them for improved clarity and type safety.


19-23: Clarify naming convention of "GivenWhenThen".

The custom testing pattern is understandable, but if it’s widely reused, consider a more descriptive or standard naming convention for easier readability and consistency across the codebase.


60-61: Address possible confusion from assignments in expression statements.

Static analysis tools warn about the use of assignments (then.result = result / then.error = error) within .then(...) and .catch(...) callbacks, as it can be less clear than returning or assigning within a clearer code block. Consider rewriting to maintain clarity.

-    .then((result) => (then.result = result))
-    .catch((error) => (then.error = error))
+    .then((result) => {
+      then.result = result
+    })
+    .catch((error) => {
+      then.error = error
+    })
🧰 Tools
🪛 Biome (1.9.4)

[error] 60-60: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 61-61: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/eventNotificationDispatch/eventNotificationDispatch.spec.ts (3)

5-5: Keep the import order consistent.

To improve readability and follow typical NestJS / TypeScript guidelines, consider grouping local imports separately from third-party ones, or follow your team’s established convention.


13-13: Document the structure of CaseFile usage.

The added CaseFile import indicates expanded logic around attachments or file categories. Provide a brief code comment or docstring explaining how CaseFileCategory.CRIMINAL_RECORD_UPDATE is used in this test scenario and potentially in production features.


65-70: Ensure scenario naming is descriptive.

Consider adding more descriptive scenario descriptions for each item in notificationScenarios so future maintainers can easily spot differences in test coverage when new events are introduced.

apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.service.ts (1)

165-165: Private vs. public method.

Retain consistency in method visibility. If this method is only called internally, maintaining a private or protected modifier is fine. If needed externally, consider making it public.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd1b223 and f49d783.

📒 Files selected for processing (15)
  • apps/judicial-system/backend/infra/judicial-system-backend.ts (1 hunks)
  • apps/judicial-system/backend/src/app/messages/notifications.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/notification.config.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/notificationDispatch.service.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.service.ts (3 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.strings.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/eventNotificationDispatch/eventNotificationDispatch.spec.ts (2 hunks)
  • apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts (1 hunks)
  • charts/judicial-system/values.dev.yaml (1 hunks)
  • charts/judicial-system/values.prod.yaml (1 hunks)
  • charts/judicial-system/values.staging.yaml (1 hunks)
  • charts/services/judicial-system-backend/values.dev.yaml (1 hunks)
  • charts/services/judicial-system-backend/values.prod.yaml (1 hunks)
  • charts/services/judicial-system-backend/values.staging.yaml (1 hunks)
  • libs/judicial-system/types/src/lib/notification.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
apps/judicial-system/backend/src/app/messages/notifications.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/infra/judicial-system-backend.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/notification.config.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.strings.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/notificationDispatch.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/judicial-system/types/src/lib/notification.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."
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/eventNotificationDispatch/eventNotificationDispatch.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (3)
apps/judicial-system/backend/src/app/modules/notification/notificationDispatch.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16452
File: apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts:1845-1854
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In the `sendCaseFilesUpdatedNotifications` method within `internalNotification.service.ts`, when the `user` is a defence user, it is intended to send notifications to the prosecutor.
libs/judicial-system/types/src/lib/notification.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16556
File: apps/judicial-system/backend/src/app/modules/notification/guards/rolesRules.ts:13-16
Timestamp: 2024-11-12T15:15:26.274Z
Learning: In the `CaseNotificationType` enum in `libs/judicial-system/types/src/lib/notification.ts`, `APPEAL_CASE_FILES_UPDATED` and `CASE_FILES_UPDATED` are distinct notification types that need to remain separate, as they serve different purposes in the notification system.
apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.service.ts (1)
Learnt from: gudjong
PR: island-is/island.is#16452
File: apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts:1845-1854
Timestamp: 2024-11-12T15:15:11.835Z
Learning: In the `sendCaseFilesUpdatedNotifications` method within `internalNotification.service.ts`, when the `user` is a defence user, it is intended to send notifications to the prosecutor.
🪛 Biome (1.9.4)
apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts

[error] 60-60: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 61-61: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (22)
apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.strings.ts (1)

19-33: Review subject and message for clarity and i18n consistency.

The strings for the criminalRecordFilesUploadedEmail are self-explanatory, but make sure the language is consistent with other notifications sent in this module. Consider verifying capitalization, special characters, and translations for non-Icelandic texts if applicable.

apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/indictmentCaseNotification/sendIndictmentCriminalRecordFilesUploadedNotification.spec.ts (2)

39-65: Consider verifying environment variables during tests.

While the test sets PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL explicitly, ensure that in a continuous integration environment, missing or invalid environment variables won’t break the test. Validate existence or correctness of required environment variables with a setup step or configuration check to avoid silent failures.

🧰 Tools
🪛 Biome (1.9.4)

[error] 60-60: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 61-61: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


67-92: Good comprehensive test coverage for criminal record files email dispatch.

The test ensures the correct parameters are passed to the email service and verifies a successful delivery response. This coverage is essential to prevent regressions for newly introduced flow. Great job!

apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/eventNotificationDispatch/eventNotificationDispatch.spec.ts (3)

17-24: Validate presence of other case file categories.

While CRIMINAL_RECORD_UPDATE is an important category, consider verifying other categories to ensure the test scenario is adequately covering or ignoring them as intended. This will prevent breakage if a future developer adds more file categories without adjusting this test.


45-60: Comprehensive approach to testing multiple messages.

Allowing multiple expected messages in a single scenario is a powerful approach, ensuring any newly introduced notifications are also captured. Continue this pattern to maintain robust coverage as more notifications are added.


78-80: Keep parallel structure when asserting calls.

Your expect(mockMessageService.sendMessagesToQueue).toHaveBeenCalledWith(...) is consistent. Maintain similar patterns across other tests for clarity, or use variables if the repeated code becomes substantial.

apps/judicial-system/backend/src/app/modules/notification/notificationDispatch.service.ts (2)

11-11: Imports look good.

You’ve correctly imported the CaseFileCategory enum, which is necessary for checking if any files fall into the CRIMINAL_RECORD_UPDATE category.


74-95: Good addition for handling multiple messages.

Using a dedicated array of messages before calling sendMessagesToQueue() makes the code more extensible. The check for CRIMINAL_RECORD_UPDATE files and then pushing the CRIMINAL_RECORD_FILES_UPLOADED notification is straightforward and clear.

apps/judicial-system/backend/infra/judicial-system-backend.ts (1)

77-78: Verify the usage of new secret.

The new secret PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL must be configured in all relevant environments (dev, staging, prod) to avoid runtime issues.

libs/judicial-system/types/src/lib/notification.ts (1)

27-27: New enum value addresses expanded use case.

Adding CRIMINAL_RECORD_FILES_UPLOADED to IndictmentCaseNotificationType is aligned with the need to detect criminal record file uploads. Update any relevant test coverage to ensure it’s handled properly throughout the system.

apps/judicial-system/backend/src/app/modules/notification/services/indictmentCaseNotification/indictmentCaseNotification.service.ts (5)

1-2: Check the benefit of using applyCase.

Ensure applyCase from beygla/strict is actually needed. If applyCase is unused or only partially used, consider removing it to avoid dead imports.


15-15: Route constant usage.

Using ROUTE_HANDLER_ROUTE centralizes routing logic and avoids hardcoding. Great approach for maintainability.


21-21: Notifications import is consistent.

Importing from a common messages or strings module fosters reusability. Keep references consistent for all notifications.


130-164: Well-structured email notification logic.

The dedicated sendCriminalRecordFilesUploadedNotification method clarifies the email’s subject, body, and recipients. The usage of formatMessage ensures translation readiness.


173-174: Proper routing of notification types.

The switch statement explicitly handles CRIMINAL_RECORD_FILES_UPLOADED, reinforcing clarity. Good usage of typed enums to avoid string-literal errors.

apps/judicial-system/backend/src/app/messages/notifications.ts (1)

784-788: New localized message looks consistent with existing patterns.
This addition aligns with the established structure for notification strings and follows best practices for localized messages.

charts/services/judicial-system-backend/values.dev.yaml (1)

145-145: Added secret appears correct and consistent.
The new secret aligns with existing naming conventions. Ensure that it is properly referenced by the application code and that access is controlled to avoid accidental leakage.

charts/services/judicial-system-backend/values.prod.yaml (1)

145-145: New secret addition matches environment-specific settings.
Make sure the secret is securely managed and kept in sync with the usage in the application’s production environment.

charts/services/judicial-system-backend/values.staging.yaml (1)

145-145: Secret key tracking is consistent across environments.
The new secret is set up uniformly, which helps maintain consistency across staging and other deployment tiers.

charts/judicial-system/values.dev.yaml (1)

232-232: LGTM! The secret configuration follows security best practices.

The addition of PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL as a Kubernetes secret:

  1. Follows the established pattern for email configurations
  2. Is consistently implemented across all environments (dev/staging/prod)
  3. Uses the secure /k8s/judicial-system/ path prefix
  4. Aligns with the PR objective of implementing criminal records notifications

Run the following script to verify the secret is properly configured in all environments:

✅ Verification successful

Secret configuration verified: Consistent implementation across all environments

The verification confirms that the PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL secret:

  • Uses identical path /k8s/judicial-system/PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL in all environments (dev/staging/prod)
  • Maintains consistent positioning in the configuration files
  • Follows the same pattern as other sensitive configurations (e.g., XROAD_CLIENT_CERT)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the secret configuration across environments
# Test: Check if the secret path exists in all environment files
# Expected: The secret should be present with identical paths

echo "Checking secret configuration consistency across environments..."
for env in dev staging prod; do
  rg -A 1 "PUBLIC_PROSECUTOR_CRIMINAL_RECORDS_EMAIL" "charts/judicial-system/values.${env}.yaml"
done

Length of output: 1025

charts/judicial-system/values.staging.yaml (1)

232-232: Duplicate configuration - LGTM!

This is identical to the configuration in values.dev.yaml.

charts/judicial-system/values.prod.yaml (1)

232-232: Duplicate configuration - LGTM!

This is identical to the configuration in values.dev.yaml.

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.69%. Comparing base (dd1b223) to head (f49d783).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17406   +/-   ##
=======================================
  Coverage   35.68%   35.69%           
=======================================
  Files        6931     6931           
  Lines      148792   148807   +15     
  Branches    42511    42515    +4     
=======================================
+ Hits        53098    53111   +13     
- Misses      95694    95696    +2     
Flag Coverage Δ
judicial-system-api 20.23% <100.00%> (+0.02%) ⬆️
judicial-system-backend 56.00% <100.00%> (+0.02%) ⬆️
judicial-system-formatters 78.52% <100.00%> (+0.02%) ⬆️
judicial-system-message 66.60% <ø> (ø)
judicial-system-message-handler 48.33% <ø> (ø)
judicial-system-scheduler 71.17% <100.00%> (+0.02%) ⬆️
judicial-system-types 41.54% <0.00%> (-0.07%) ⬇️
judicial-system-web 27.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...l-system/backend/src/app/messages/notifications.ts 100.00% <ø> (ø)
...dules/notification/notificationDispatch.service.ts 81.39% <100.00%> (+2.44%) ⬆️
...Notification/indictmentCaseNotification.service.ts 93.10% <100.00%> (+1.26%) ⬆️
...Notification/indictmentCaseNotification.strings.ts 100.00% <ø> (ø)
libs/judicial-system/types/src/lib/notification.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd1b223...f49d783. Read the comment docs.

@datadog-island-is
Copy link

Datadog Report

All test runs e396ff7 🔗

9 Total Test Services: 0 Failed, 9 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.07%), 5 increased, 6 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-api 0 0 0 61 0 5.33s 1 increased (+0.03%) Link
judicial-system-backend 0 0 0 21086 0 18m 25.27s 1 increased (+0.02%) Link
judicial-system-formatters 0 0 0 38 0 4.88s 1 increased (+0.01%) Link
judicial-system-message 0 0 0 40 0 9.49s 1 no change Link
judicial-system-message-handler 0 0 0 4 0 3.18s 1 no change Link
judicial-system-scheduler 0 0 0 4 0 3.85s 1 increased (+0.02%) Link
judicial-system-types 0 0 0 23 0 5.98s 1 decreased (-0.07%) Link
judicial-system-web 0 0 0 344 0 56.54s 1 no change Link
judicial-system-xrd-api 0 0 0 6 0 4.89s 1 increased (+0.01%) Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-types - jest 44.18% (-0.07%) - Details

@@ -1,3 +1,5 @@
import { applyCase } from 'beygla/strict'
Copy link
Member

Choose a reason for hiding this comment

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

Please remove unused import

Suggested change
import { applyCase } from 'beygla/strict'

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.

3 participants