fix(integrations.mocked): [Bug] Notification details screen shows something went wrong toast when viewing unviewed notification #778 - #860
Conversation
…rvice Opening an unviewed notification triggers an automatic mark-as-read request from NotificationDetails.client.tsx for users with the mark_read permission. The mocked Notifications service threw NotImplementedException, so the request failed and the frontend showed a "Something went wrong" toast. markAs now updates the notification status in the in-memory mocks (across all locale variants, since ids are shared) and completes successfully.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe mocked notifications integration now updates notification status and timestamps across localized collections. The service delegates requests to the mapper and returns a delayed void observable instead of throwing an exception. ChangesNotification status marking
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for packages/configs/vitest-config
File CoverageNo changed files found. |
| * so all locale variants are updated to keep the mocked data consistent. | ||
| * Returns `true` when a notification with the given id was found. | ||
| */ | ||
| export const markNotificationAs = (request: Notifications.Request.MarkNotificationAsRequest): boolean => { |
There was a problem hiding this comment.
does this mean that once marked as viewed, it will stay that way until nestjs app restarts? i'm not sure if this is a desired behavior, as for mocked/demo purposes it should be possible to "retry" marking it as viewed from time to time without having to restart/redeploy the app; perhaps some timeout could be added that switched back to unviewed state after e.g. 5min?
What does this PR do?
Related Ticket(s)
Key Changes
packages/integrations/mocked/src/modules/notifications/notifications.service.ts—markAs()no longer throwsNotImplementedException. It delegates to a new mapper function and returnsof(undefined).pipe(responseDelay()), so the request completes with201instead of501.packages/integrations/mocked/src/modules/notifications/notifications.mapper.ts— newmarkNotificationAs()updatesstatusandupdatedAton the in-memory mocks. It updates all three locale arrays (MOCK_NOTIFICATIONS_EN/PL/DE) because the same notification ids are shared across locales, so mutating only one would leave the mocked data inconsistent between languages.booleanso a caller can distinguish the case if ever needed.Side effects
NotificationDetails.client.tsxkeeps its error toast, which is still correct for genuine network failures — the bug was purely in the backend mock.@o2s/integrations.mockedis the only integration implementingNotifications.Service, so no other integration is affected.patchchangeset for@o2s/integrations.mocked.How to test
No migrations or new dependencies needed.
npm run devand log in asjohn@example.com/user(default org: Tech Solutions Inc,cust-002, which has thenotifications:mark_readpermission).Alternatively, against the API directly (
AUTH_JWT_SECRET=secretfromapps/api-harmonization/.env.local), with a JWT whosecustomer.permissionsgrantsnotifications: ['view', 'mark_read']:Verified on a running
api-harmonizationinstance:201on thePOST, status flips toVIEWEDin all three locales, and a token withoutmark_read(prospect oncust-003) is still rejected by the permission guard withMissing required permissions: notifications:mark_read.tsc --noEmitandeslint --max-warnings=0are clean, and the existing@o2s/integrations.mockedtest suite passes (28/28).Media (Loom or gif)
Summary by CodeRabbit