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(user-notification): Add getNotificationStatus endpoint #17187

Closed
wants to merge 3 commits into from

Conversation

rafnarnason
Copy link
Member

@rafnarnason rafnarnason commented Dec 10, 2024

Adds a new endpoint to fetch notification status with dummy data

...

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:

  • 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

    • Introduced a method to retrieve the status of a specific notification by its ID.
  • Chores

    • Temporarily excluded certain user notification services from deployment.

Adds a new endpoint to fetch notification status with dummy data
@rafnarnason rafnarnason requested review from a team as code owners December 10, 2024 10:26
@rafnarnason rafnarnason added the deploy-feature Deploys features to dev label Dec 10, 2024
@rafnarnason rafnarnason requested a review from a team as a code owner December 10, 2024 10:35
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 35.73%. Comparing base (fcadfe5) to head (5b5082f).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
.../modules/notifications/notifications.controller.ts 40.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17187   +/-   ##
=======================================
  Coverage   35.73%   35.73%           
=======================================
  Files        6928     6928           
  Lines      147824   147829    +5     
  Branches    42129    42130    +1     
=======================================
+ Hits        52818    52820    +2     
- Misses      95006    95009    +3     
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.76% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.81% <ø> (+0.02%) ⬆️
services-user-notification 46.59% <40.00%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
.../modules/notifications/notifications.controller.ts 90.90% <40.00%> (-6.53%) ⬇️

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 fcadfe5...5b5082f. Read the comment docs.

Copy link
Contributor

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 10, 2024

Datadog Report

All test runs 7e6adab 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 7 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.41s 1 no change Link
application-system-api 0 0 0 46 0 2m 22.32s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.69s 1 no change Link
services-user-notification 0 0 0 51 0 1m 24.09s 1 no change Link

Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

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.

error Received malformed response from registry for "@typescript-eslint%2feslint-plugin". The registry may be down.

Walkthrough

The changes involve the addition of a new method getNotificationStatus in the NotificationsController to retrieve the status of a specific notification by its ID. This method includes various decorators for access control and documentation. Additionally, three services have been commented out in the ExcludedFeatureDeploymentServices within the islandis.ts file, indicating their temporary exclusion from deployment.

Changes

File Path Change Summary
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts Added method getNotificationStatus to retrieve notification status by ID, including logging and decorators.
infra/src/uber-charts/islandis.ts Commented out services: userNotificationService, userNotificationWorkerService, and userNotificationCleanupWorkerService from ExcludedFeatureDeploymentServices.

Suggested labels

automerge, high priority

Suggested reviewers

  • baering
  • thordurhhh

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. (Experiment)
  • @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.

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: 3

🧹 Outside diff range and nitpick comments (1)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (1)

111-127: Enhance API documentation

The current documentation could be improved by adding more details about the response structure and possible error scenarios.

Update the @documentation decorator to include:

  1. Response schema with possible status values
  2. Error responses (404 for not found, 403 for unauthorized)
  3. Example response in the documentation
@Documentation({
  summary: 'Get status information for a specific notification',
  response: {
    status: HttpStatus.OK,
    schema: {
      type: NotificationStatus,
      example: {
        id: 'notif-123-456',
        status: 'DELIVERED',
        createdAt: '2023-12-10T10:00:00Z',
        lastUpdated: '2023-12-10T10:15:00Z'
      }
    }
  },
  responses: [
    { status: 404, description: 'Notification not found' },
    { status: 403, description: 'Unauthorized access' }
  ]
})
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fcadfe5 and 5b5082f.

📒 Files selected for processing (2)
  • apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (1 hunks)
  • infra/src/uber-charts/islandis.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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."

Comment on lines +130 to +135
): Promise<{
id: string
status: string
createdAt: string
lastUpdated: string
}> {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Define an interface for the notification status response

The return type should be defined as an interface with proper types for each field.

Add this interface definition:

export interface NotificationStatus {
  id: string;
  status: NotificationStatusEnum; // Define enum with possible values
  createdAt: string;
  lastUpdated: string;
}

Comment on lines +138 to +143
return {
id: notificationId,
status: 'DELIVERED',
createdAt: '2024-12-10T10:00:00Z',
lastUpdated: '2024-12-10T10:15:00Z',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace hardcoded response with actual implementation

The current implementation returns hardcoded dummy data. This needs to be replaced with actual notification status retrieval logic.

Consider implementing the following:

  1. Add a method in NotificationsService to fetch notification status
  2. Handle cases where notification doesn't exist
  3. Use proper status enum/type instead of hardcoded string
-    return {
-      id: notificationId,
-      status: 'DELIVERED',
-      createdAt: '2024-12-10T10:00:00Z',
-      lastUpdated: '2024-12-10T10:15:00Z',
-    }
+    const notification = await this.notificationsService.getNotificationStatus(notificationId);
+    if (!notification) {
+      throw new NotFoundException(`Notification with id ${notificationId} not found`);
+    }
+    return notification;

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +272 to +275
// FIXME BEFORE APPROVEING THIS PR !!!!!!!!!!!!!!!! MERGE AND DIE
//userNotificationService,
//userNotificationWorkerService,
//userNotificationCleanupWorkerService,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Remove warning comment and uncomment notification services

The notification services are actively used in multiple parts of the system (api and application-system-api) and should not be excluded from feature deployments. The warning comment suggests these changes were temporary and not meant for production.

  • apps/api/infra/api.ts depends on userNotificationService for HTTP endpoints
  • apps/application-system/api/infra/application-system-api.ts has multiple dependencies on these services
  • These services are part of the core functionality and should be available in feature deployments
export const ExcludedFeatureDeploymentServices: ServiceBuilder<any>[] = [
-  // FIXME BEFORE APPROVEING THIS PR !!!!!!!!!!!!!!!! MERGE AND DIE
-  //userNotificationService,
-  //userNotificationWorkerService,
-  //userNotificationCleanupWorkerService,
  contentfulEntryTagger,
  searchIndexer,
  contentfulApps,
  githubActionsCache,
]
🔗 Analysis chain

Remove warning comment and properly document service exclusions

The current changes include a concerning warning comment and commented-out services without proper explanation.

  1. Remove the warning comment
  2. Either remove the services from the exclusion list or document why they should be excluded
  3. Verify the impact on feature deployments
export const ExcludedFeatureDeploymentServices: ServiceBuilder<any>[] = [
-  // FIXME BEFORE APPROVEING THIS PR !!!!!!!!!!!!!!!! MERGE AND DIE
-  //userNotificationService,
-  //userNotificationWorkerService,
-  //userNotificationCleanupWorkerService,
  contentfulEntryTagger,
  searchIndexer,
  contentfulApps,
  githubActionsCache,
]

Let's verify the dependencies of these services:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for dependencies on notification services
rg -l "userNotification(Service|Worker|CleanupWorker)" apps/

Length of output: 203


Script:

#!/bin/bash
# Check the actual usage of notification services in the dependent files
rg "userNotification(Service|Worker|CleanupWorker)" apps/services/user-notification/infra/user-notification.ts apps/application-system/api/infra/application-system-api.ts apps/api/infra/api.ts -A 3

# Check if these services are used in feature deployments configuration
rg "feature.*deployment" -A 5 -B 5

Length of output: 14815

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: 3

🧹 Outside diff range and nitpick comments (2)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (2)

115-127: Enhance API documentation for better developer experience

The current documentation could be improved by adding:

  • Possible response status codes (e.g., 404 for not found)
  • Example response with possible status values
  • Error response schema

Update the Documentation decorator to include:

@Documentation({
  summary: 'Get status information for a specific notification',
  response: {
    status: HttpStatus.OK,
    schema: {
      example: {
        id: 'notif-123-456',
        status: 'DELIVERED', // One of: PENDING, DELIVERED, FAILED
        createdAt: '2024-12-10T10:00:00.000Z',
        lastUpdated: '2024-12-10T10:15:00.000Z'
      }
    }
  },
  responses: [
    {
      status: HttpStatus.NOT_FOUND,
      description: 'Notification not found'
    }
  ],
  // ... rest of the existing config
})

128-144: Add proper error handling following NestJS patterns

The endpoint should handle cases where the notification ID is invalid or not found, following NestJS exception patterns.

Consider adding:

import { NotFoundException } from '@nestjs/common';

async getNotificationStatus(
  @Param('notificationId') notificationId: string,
): Promise<NotificationStatusResponse> {
  this.logger.info(`Fetching status for notification: ${notificationId}`);
  
  const status = await this.notificationsService.getNotificationStatus(notificationId);
  if (!status) {
    throw new NotFoundException(`Notification with ID ${notificationId} not found`);
  }
  
  return status;
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fcadfe5 and 5b5082f.

📒 Files selected for processing (2)
  • apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (1 hunks)
  • infra/src/uber-charts/islandis.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • infra/src/uber-charts/islandis.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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."

Comment on lines +130 to +135
): Promise<{
id: string
status: string
createdAt: string
lastUpdated: string
}> {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add type safety for notification status

The return type should use an enum for the status field to ensure type safety and documentation.

Consider adding:

export enum NotificationStatus {
  PENDING = 'PENDING',
  DELIVERED = 'DELIVERED',
  FAILED = 'FAILED'
}

// Update the return type
interface NotificationStatusResponse {
  id: string;
  status: NotificationStatus;
  createdAt: string;
  lastUpdated: string;
}

Comment on lines +138 to +143
return {
id: notificationId,
status: 'DELIVERED',
createdAt: '2024-12-10T10:00:00Z',
lastUpdated: '2024-12-10T10:15:00Z',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement proper service layer integration instead of hardcoded response

The current implementation returns hardcoded data which is not suitable for production use. This should be integrated with the NotificationsService.

Consider implementing like this:

-    return {
-      id: notificationId,
-      status: 'DELIVERED',
-      createdAt: '2024-12-10T10:00:00Z',
-      lastUpdated: '2024-12-10T10:15:00Z',
-    }
+    return this.notificationsService.getNotificationStatus(notificationId);

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +111 to +144
@UseGuards(IdsUserGuard, ScopesGuard)
@Scopes(AdminPortalScope.serviceDesk)
@Get('/status/:notificationId')
@Version('1')
@Documentation({
summary: 'Get status information for a specific notification',
response: { status: HttpStatus.OK },
request: {
params: {
notificationId: {
type: 'string',
description: 'ID of the notification',
example: 'notif-123-456',
},
},
},
})
async getNotificationStatus(
@Param('notificationId') notificationId: string,
): Promise<{
id: string
status: string
createdAt: string
lastUpdated: string
}> {
this.logger.info(`Fetching status for notification: ${notificationId}`)

return {
id: notificationId,
status: 'DELIVERED',
createdAt: '2024-12-10T10:00:00Z',
lastUpdated: '2024-12-10T10:15:00Z',
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Hardcoded status value needs to be aligned with the notification model

The current implementation returns a hardcoded status 'DELIVERED' which doesn't align with the existing notification system. The codebase shows that notifications are tracked using boolean flags 'read' and 'seen' in the NotificationsService and Notification model, rather than a delivery status.

  • The status endpoint should be modified to use the actual notification model's properties (read/seen) instead of a hardcoded delivery status
  • Consider using the NotificationsService to fetch the actual notification record and its status
  • Align the response type with existing DTOs like RenderedNotificationDto which already includes read/seen status
🔗 Analysis chain

Verify consistency with other notification endpoints

Let's ensure the implementation is consistent with other notification-related endpoints in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar notification status implementations
echo "Searching for notification status patterns..."
ast-grep --pattern 'status: string' apps/services/user-notification/

# Search for notification-related controllers
echo "Searching for other notification controllers..."
rg -l "NotificationsController" apps/services/

# Search for notification status enums
echo "Searching for existing notification status enums..."
rg -l "enum.*Status" apps/services/user-notification/

Length of output: 1198


Script:

#!/bin/bash
# Let's check the content of me-notifications.controller.ts for similar endpoints
echo "Checking me-notifications.controller.ts..."
cat apps/services/user-notification/src/app/modules/notifications/me-notifications.controller.ts

# Let's also check if there are any notification status types or constants
echo "Searching for notification status types..."
rg -A 5 "type.*Status|enum.*Status|const.*Status" apps/services/user-notification/

# Let's check the service implementation for status handling
echo "Checking notification service implementation..."
cat apps/services/user-notification/src/app/modules/notifications/notifications.service.ts

Length of output: 16354

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: 2

🧹 Outside diff range and nitpick comments (2)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (2)

111-114: Consider using a more RESTful endpoint path

The security setup with IdsUserGuard and AdminPortalScope is appropriate. However, consider making the endpoint more RESTful by moving it to:
GET /:notificationId/status instead of GET /status/:notificationId


115-127: Enhance API documentation for better clarity

While the basic documentation is in place, consider adding:

  1. Possible error responses (e.g., 404 for not found)
  2. Description of response fields (status, createdAt, lastUpdated)
  3. Enumeration of possible status values

Example enhancement:

@Documentation({
  summary: 'Get status information for a specific notification',
  response: { 
    status: HttpStatus.OK,
    description: 'Returns the current status and timestamps of the notification',
  },
  responses: [
    { status: 404, description: 'Notification not found' },
    { status: 403, description: 'Insufficient permissions' }
  ],
  schema: {
    properties: {
      status: {
        enum: ['PENDING', 'DELIVERED', 'FAILED'],
        description: 'Current status of the notification'
      }
    }
  }
})
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fcadfe5 and 5b5082f.

📒 Files selected for processing (2)
  • apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (1 hunks)
  • infra/src/uber-charts/islandis.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • infra/src/uber-charts/islandis.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/services/user-notification/src/app/modules/notifications/notifications.controller.ts (2)

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

  • NestJS architecture, including modules, services, and controllers.
  • Dependency injection patterns and service encapsulation.
  • Integration and unit testing coverage and practices."

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."

Comment on lines +128 to +144
async getNotificationStatus(
@Param('notificationId') notificationId: string,
): Promise<{
id: string
status: string
createdAt: string
lastUpdated: string
}> {
this.logger.info(`Fetching status for notification: ${notificationId}`)

return {
id: notificationId,
status: 'DELIVERED',
createdAt: '2024-12-10T10:00:00Z',
lastUpdated: '2024-12-10T10:15:00Z',
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implementation needs significant improvements

The current implementation has several critical issues:

  1. Returns hardcoded values instead of actual notification status
  2. Missing error handling for non-existent notifications
  3. Response type should be moved to a DTO class

Suggested improvements:

// Create new file: notification-status.dto.ts
export class NotificationStatusDto {
  @ApiProperty()
  id: string;

  @ApiProperty({
    enum: ['PENDING', 'DELIVERED', 'FAILED'],
    description: 'Current status of the notification'
  })
  status: string;

  @ApiProperty()
  createdAt: string;

  @ApiProperty()
  lastUpdated: string;
}

// In controller:
async getNotificationStatus(
  @Param('notificationId') notificationId: string,
): Promise<NotificationStatusDto> {
  try {
    return await this.notificationsService.getStatus(notificationId);
  } catch (error) {
    if (error instanceof NotFoundException) {
      throw new NotFoundException(`Notification ${notificationId} not found`);
    }
    throw error;
  }
}

Comment on lines +111 to +144
@UseGuards(IdsUserGuard, ScopesGuard)
@Scopes(AdminPortalScope.serviceDesk)
@Get('/status/:notificationId')
@Version('1')
@Documentation({
summary: 'Get status information for a specific notification',
response: { status: HttpStatus.OK },
request: {
params: {
notificationId: {
type: 'string',
description: 'ID of the notification',
example: 'notif-123-456',
},
},
},
})
async getNotificationStatus(
@Param('notificationId') notificationId: string,
): Promise<{
id: string
status: string
createdAt: string
lastUpdated: string
}> {
this.logger.info(`Fetching status for notification: ${notificationId}`)

return {
id: notificationId,
status: 'DELIVERED',
createdAt: '2024-12-10T10:00:00Z',
lastUpdated: '2024-12-10T10:15:00Z',
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add test coverage for the new endpoint

According to the coding guidelines, we need comprehensive test coverage. Please add:

  1. Unit tests for the controller method
  2. Integration tests for the endpoint
  3. Authorization test cases

Test scenarios should include:

  • Successful status retrieval
  • Not found scenarios
  • Authorization failures

Example test structure:

describe('NotificationsController', () => {
  describe('getNotificationStatus', () => {
    it('should return status for existing notification', async () => {
      // Test implementation
    });

    it('should throw NotFoundException for non-existent notification', async () => {
      // Test implementation
    });

    it('should require proper scope', async () => {
      // Test implementation
    });
  });
});

@rafnarnason rafnarnason removed the deploy-feature Deploys features to dev label Dec 11, 2024
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.

2 participants