Skip to content

Conversation

@ChengShi-1
Copy link
Contributor

@ChengShi-1 ChengShi-1 commented Jul 11, 2025

What this PR does / why we need it:

Inspired by 2025 Q3

Referring to native api
Get All Notifications by User
Delete Notification by User

Set displayAsRead
https://github.com/IQSS/dataverse/pull/11664/files

Which issue(s) this PR closes:

Related Dataverse PRs:

IQSS/dataverse#11696

Special notes for your reviewer:

Test env. variables should be changed back after IQSS/dataverse#11696 is merged

Suggestions on how to test this:

Is there a release notes update needed for this change?:

Additional documentation:

@ChengShi-1 ChengShi-1 linked an issue Jul 11, 2025 that may be closed by this pull request
@ChengShi-1 ChengShi-1 added Size: 3 A percentage of a sprint. 2.1 hours. Original size: 3 labels Jul 11, 2025
@github-actions github-actions bot added FY26 Sprint 1 FY26 Sprint 1 (2025-07-02 - 2025-07-16) GREI Re-arch GREI re-architecture-related SPA.Q3.2025 labels Jul 11, 2025
@ChengShi-1 ChengShi-1 self-assigned this Jul 11, 2025
@ChengShi-1 ChengShi-1 moved this to Ready for Review ⏩ in IQSS Dataverse Project Jul 11, 2025
@ChengShi-1 ChengShi-1 removed their assignment Jul 11, 2025
@ekraffmiller ekraffmiller self-assigned this Jul 17, 2025
@ekraffmiller ekraffmiller moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Jul 17, 2025
Copy link
Contributor

@ekraffmiller ekraffmiller left a comment

Choose a reason for hiding this comment

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

looks good! I just have some comments about naming.

@ChengShi-1
Copy link
Contributor Author

Hi Ellen @ekraffmiller , thanks for review! I made changes based on suggestion.
Do you think we should change the type property of notification to enum according to https://github.com/IQSS/dataverse/blob/23d47a3063576c69a4efaad1bd07e9e89b0a3151/src/main/java/edu/harvard/iq/dataverse/UserNotification.java#L36

@ChengShi-1 ChengShi-1 added the SPA.Q3.2025.6 Account Page: Notifications label Jul 17, 2025
@cmbz cmbz added the FY26 Sprint 2 FY26 Sprint 2 (2025-07-16 - 2025-07-30) label Jul 17, 2025
@ekraffmiller
Copy link
Contributor

Hi Ellen @ekraffmiller , thanks for review! I made changes based on suggestion. Do you think we should change the type property of notification to enum according to https://github.com/IQSS/dataverse/blob/23d47a3063576c69a4efaad1bd07e9e89b0a3151/src/main/java/edu/harvard/iq/dataverse/UserNotification.java#L36

Hi @ChengShi-1, yes that sounds good 👍
Also, in looking at the UI, I noticed that we need to display whether the file has been read or not. There is a field, displayAsRead that is used in the JSF notifications table, and another field unreadNotificationCount that is used in the Dataverse Header: https://github.com/IQSS/dataverse/blob/23d47a3063576c69a4efaad1bd07e9e89b0a3151/src/main/java/edu/harvard/iq/dataverse/DataverseHeaderFragment.java#L154.
So I think we need to request an update to the Notifications API to get the 'displayAsRead' field, and also we need an API endpoint to update a notification as read when the user views the table.

@ChengShi-1
Copy link
Contributor Author

ChengShi-1 commented Jul 17, 2025

@ekraffmiller right, we need this. I just create an issue to dataverse repo for it. IQSS/dataverse#11650

import { Notification } from '../models/Notification'

export interface INotificationsRepository {
getAllNotificationsByUser(): Promise<Notification[]>

Choose a reason for hiding this comment

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

A pagination feature would be nice:)

@cmbz cmbz added the FY26 Sprint 3 (2025-07-30 - 2025-08-13) label Jul 31, 2025
@ekraffmiller
Copy link
Contributor

Waiting for version of the notifications API, IQSS/dataverse#11673

@cmbz cmbz added the FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) label Aug 14, 2025
@ChengShi-1 ChengShi-1 added Original size: 10 and removed Size: 3 A percentage of a sprint. 2.1 hours. labels Aug 15, 2025
@ChengShi-1 ChengShi-1 removed their assignment Aug 18, 2025
@ChengShi-1 ChengShi-1 moved this from In Progress 💻 to Ready for Review ⏩ in IQSS Dataverse Project Aug 18, 2025
@ekraffmiller ekraffmiller moved this from Ready for Review ⏩ to In Review 🔎 in IQSS Dataverse Project Aug 20, 2025
Copy link
Contributor

@ekraffmiller ekraffmiller left a comment

Choose a reason for hiding this comment

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

Hi @ChengShi-1 it looks good! just some comments about naming conventions, and a question about the integration test.

import { UseCase } from '../../../core/domain/useCases/UseCase'
import { INotificationsRepository } from '../repositories/INotificationsRepository'

export class GetUnreadCount implements UseCase<number> {
Copy link
Contributor

Choose a reason for hiding this comment

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

to follow the naming convention we have in other use cases, change to GetUnreadNotificationsCount?

expect(assignRoleNotification?.type).toBe(NotificationType.ASSIGNROLE)
expect(assignRoleNotification?.sentTimestamp).toBeDefined()
expect(assignRoleNotification?.displayAsRead).toBeDefined()
expect(assignRoleNotification?.dataverseDisplayName).toBeDefined()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm getting flaky behavior when running this locally - the test fails even though it succeeds on Github. Can you try to reproduce that? If needed, you could avoid relying on the existence of a notification by creating one before running the test.

 FAIL  test/integration/notifications/NotificationsRepository.test.ts (9.565 s)

 RUNS  test/integration/files/DirectUpload.test.ts
 RUNS  test/integration/notifications/NotificationsRepository.test.ts
 RUNS  test/integration/datasets/DatasetsRepository.test.ts
 RUNS  test/integration/collections/CollectionsRepository.test.ts
 RUNS  test/integration/files/FilesRepository.test.ts
  ● NotificationsRepository › should find notification with ASSIGNROLE type

    expect(received).toBeDefined()

    Received: undefined

      101 |     expect(assignRoleNotification?.sentTimestamp).toBeDefined()
      102 |     expect(assignRoleNotification?.displayAsRead).toBeDefined()
    > 103 |     expect(assignRoleNotification?.dataverseDisplayName).toBeDefined()
          |                                                          ^
      104 |
      105 |     expect(assignRoleNotification?.roleAssignments).toBeDefined()
      106 |     expect(assignRoleNotification?.roleAssignments?.length).toBeGreaterThan(0)

      at test/integration/notifications/NotificationsRepository.test.ts:103:58
      at fulfilled (test/integration/notifications/NotificationsRepository.test.ts:5:58)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! The notifications.find(...) gave a deleted object there as the 1st eligible element,
assignRoleNotification { id: 139, type: 'ASSIGNROLE', displayAsRead: false, sentTimestamp: '2025-08-22T13:28:34Z', objectDeleted: true }
so I add a line to filter out deleted objects there

Copy link
Contributor

@ekraffmiller ekraffmiller left a comment

Choose a reason for hiding this comment

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

looks good, approved!

@github-project-automation github-project-automation bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Aug 22, 2025
@ofahimIQSS
Copy link
Contributor

tests passing, merging

@ofahimIQSS ofahimIQSS merged commit 68fcaa7 into develop Aug 22, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Ready for QA ⏩ to Merged 🚀 in IQSS Dataverse Project Aug 22, 2025
@ofahimIQSS ofahimIQSS deleted the 334-create-use-cases-for-get-notifications-and-delete-notifications branch August 22, 2025 15:21
@ekraffmiller ekraffmiller restored the 334-create-use-cases-for-get-notifications-and-delete-notifications branch August 24, 2025 22:12
@scolapasta scolapasta moved this from Merged 🚀 to Done 🧹 in IQSS Dataverse Project Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY26 Sprint 1 FY26 Sprint 1 (2025-07-02 - 2025-07-16) FY26 Sprint 2 FY26 Sprint 2 (2025-07-16 - 2025-07-30) FY26 Sprint 3 (2025-07-30 - 2025-08-13) FY26 Sprint 4 FY26 Sprint 4 (2025-08-13 - 2025-08-27) GREI Re-arch GREI re-architecture-related Original size: 3 Original size: 10 SPA.Q3.2025 SPA.Q3.2025.6 Account Page: Notifications

Projects

Status: Done 🧹

Development

Successfully merging this pull request may close these issues.

Create Use Cases for Get Notifications and Delete Notifications

6 participants