Skip to content

Commit

Permalink
fix(archives): add ArchivedRecordingCreated notification hook to refr…
Browse files Browse the repository at this point in the history
…esh All Archives view (#576) (#580)

* add ArchivedRecordingCreated notification hook to refresh allArchives

* fix tests

(cherry picked from commit e220ce9)

Co-authored-by: Max Cao <macao@redhat.com>
  • Loading branch information
mergify[bot] and maxcao13 authored Oct 27, 2022
1 parent 7bf2e01 commit 358e2cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/app/Archives/AllArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ export const AllArchivedRecordingsTable: React.FunctionComponent<AllArchivedReco
);
}, [addSubscription, context.notificationChannel, refreshDirectoriesAndCounts]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingCreated).subscribe((v) => {
refreshDirectoriesAndCounts();
})
);
}, [addSubscription, context.notificationChannel, refreshDirectoriesAndCounts]);

React.useEffect(() => {
addSubscription(
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted).subscribe((v) => {
Expand Down
11 changes: 8 additions & 3 deletions src/test/Archives/AllArchivedRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,30 @@ jest

jest
.spyOn(defaultServices.notificationChannel, 'messages')
.mockReturnValueOnce(of()) // renders correctly
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of()) // renders correctly // NotificationCategory.RecordingMetadataUpdated
.mockReturnValueOnce(of()) // NotificationCategory.ActiveRecordingSaved
.mockReturnValueOnce(of()) // NotificationCategory.ArchivedRecordingCreated
.mockReturnValueOnce(of()) // NotificationCategory.ArchivedRecordingDeleted

.mockReturnValueOnce(of()) // shows no recordings when empty
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())

.mockReturnValueOnce(of()) // has the correct table elements
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())

.mockReturnValueOnce(of()) // correctly handles the search function
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())

.mockReturnValueOnce(of()) // expands targets to show their <ArchivedRecordingsTable />
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())
.mockReturnValueOnce(of())

.mockReturnValueOnce(of(mockRecordingSavedNotification)) // increments the count when an archived recording is saved
.mockReturnValueOnce(of())
Expand Down

0 comments on commit 358e2cc

Please sign in to comment.