diff --git a/src/app/Archives/AllArchivedRecordingsTable.tsx b/src/app/Archives/AllArchivedRecordingsTable.tsx index 36e44c52a..039cb0abf 100644 --- a/src/app/Archives/AllArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllArchivedRecordingsTable.tsx @@ -87,7 +87,7 @@ export const AllArchivedRecordingsTable: React.FC { - console.log("++API Response Data:", directories); // Log the fetched data to the console + //console.log("++API Response Data:", directories); // Log the fetched data to the console setDirectories(directories.map((dir) => ({ ...dir, targetAsObs: of(getTargetFromDirectory(dir)) }))); setIsLoading(false); @@ -97,7 +97,7 @@ export const AllArchivedRecordingsTable: React.FC { - console.error("++API Error:", error); + //console.error("++API Error:", error); setIsLoading(false); setErrorMessage(error.message); diff --git a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx index 1bd33f923..b322187b5 100644 --- a/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx +++ b/src/app/Archives/AllTargetsArchivedRecordingsTable.tsx @@ -103,15 +103,25 @@ export const AllTargetsArchivedRecordingsTable: React.FC { setArchivesForTargets((old) => { + console.log("+++recording", recording); + console.log("old2: ",JSON.stringify(old, null, 2)); const matchingTargets = old.filter(({ target }) => target.jvmId === recording.jvmId); + console.log("++Match2: ", matchingTargets); + console.log("+++target.jvmID2: ",target.jvmId); + console.log("+++recording.jvmID2: ",recording.jvmId); for (const matchedTarget of matchingTargets) { - const targetIdx = old.findIndex(({ target }) => target.connectUrl === matchedTarget.target.connectUrl); + console.log("++Target: ",matchedTarget.target); + const targetIdx = old.findIndex(({ target }) => target.connectUrl === matchedTarget.target.connectUrl); + console.log("+++target.connectUrl2: ",matchedTarget.target.connectUrl); + console.log("+++recording.jvmID2: ",recording.jvmId); const recordings = [...matchedTarget.recordings]; if (delta === 1) { + console.log("++ADDED2"); recordings.push(recording); } else { const recordingIdx = recordings.findIndex((r) => r.name === recording.name); + console.log("DELETED2"); recordings.splice(recordingIdx, 1); } diff --git a/src/app/Recordings/ArchivedRecordingsTable.tsx b/src/app/Recordings/ArchivedRecordingsTable.tsx index 8916d201b..4e6e59609 100644 --- a/src/app/Recordings/ArchivedRecordingsTable.tsx +++ b/src/app/Recordings/ArchivedRecordingsTable.tsx @@ -338,11 +338,19 @@ export const ArchivedRecordingsTable: React.FC = ( const eventConnectUrlLabel = event.message.recording.metadata.labels.find( (label) => label.key === 'connectUrl', ); - + console.log("++delete current Target: ", currentTarget); + console.log("+++ delete event: ",event); + console.log("++delete event connect URL:", eventConnectUrlLabel); const matchesUploadsUrlAndJvmId = currentTarget?.connectUrl === 'uploads' && event.message.recording.jvmId === 'uploads'; + console.log("++delete current TargetUrl: ", currentTarget?.connectUrl); + console.log("++ delete event Url: ", eventConnectUrlLabel?.value); + + console.log("++ delete currentTarget jvmID: ", currentTarget.jvmId); + console.log("++ delete event jvmID: ", event.message.recording.jvmId); if (isUploadsTable && matchesUploadsUrlAndJvmId) { + console.log("+++ is upload"); refreshRecordingList(); } if ( @@ -371,6 +379,10 @@ export const ArchivedRecordingsTable: React.FC = ( propsTarget, context.notificationChannel.messages(NotificationCategory.RecordingMetadataUpdated), ]).subscribe(([currentTarget, event]) => { + console.log("++current Target: ", currentTarget); + console.log("+++ event: ",event); + console.log("+++ event metadata labels: ", event.message.recording.metadata.labels); + const eventConnectUrlLabel = event.message.recording.metadata.labels.find( (label) => label.key === 'connectUrl', ); @@ -381,6 +393,12 @@ export const ArchivedRecordingsTable: React.FC = ( ) { return; } + console.log("++current TargetUrl: ", currentTarget?.connectUrl); + console.log("++ event url: ", eventConnectUrlLabel?.value); + + console.log("++ event jvmID: ", event.message.recording.jvmId); + console.log("++ currentTarget jvmID: ", currentTarget.jvmId); + setRecordings((oldRecordings) => { return oldRecordings.map((recording) => { if (recording.name === event.message.recording.name) { diff --git a/src/test/Archives/AllTargetsArchivedRecordingsTable.test.tsx b/src/test/Archives/AllTargetsArchivedRecordingsTable.test.tsx index 8a021df10..795a7a35d 100644 --- a/src/test/Archives/AllTargetsArchivedRecordingsTable.test.tsx +++ b/src/test/Archives/AllTargetsArchivedRecordingsTable.test.tsx @@ -24,11 +24,12 @@ import { render, renderSnapshot } from '../utils'; const mockConnectUrl1 = 'service:jmx:rmi://someUrl1'; const mockAlias1 = 'fooTarget1'; const mockTarget1: Target = { + jvmId: 'foo', connectUrl: mockConnectUrl1, alias: mockAlias1, - jvmId: 'foo', labels: [], annotations: { cryostat: [], platform: [] }, + recordings: [], }; const mockConnectUrl2 = 'service:jmx:rmi://someUrl2'; const mockAlias2 = 'fooTarget2'; @@ -37,11 +38,12 @@ const mockAlias3 = 'fooTarget3'; const mockNewConnectUrl = 'service:jmx:rmi://someNewUrl'; const mockNewAlias = 'newTarget'; const mockNewTarget: Target = { + jvmId: 'foo', connectUrl: mockNewConnectUrl, alias: mockNewAlias, - jvmId: 'foo', labels: [], annotations: { cryostat: [], platform: [] }, + recordings: [], }; const mockCount1 = 1; const mockCount2 = 3; @@ -54,6 +56,20 @@ const mockTargetFoundNotification = { }, } as NotificationMessage; +const mockRecording = { + jvmId: 'foo', + name: 'SampleRecording', + downloadUrl: 'http://downloadurl.com/sample', + reportUrl: 'http://reporturl.com/sample', + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + ] + }, + size: 1234, + archivedTime: 987654321 +}; + const mockTargetLostNotification = { message: { event: { kind: 'LOST', serviceRef: mockTarget1 }, @@ -62,7 +78,8 @@ const mockTargetLostNotification = { const mockRecordingSavedNotification = { message: { - target: mockConnectUrl3, + jvmId: mockConnectUrl3, + recording: mockRecording, }, } as NotificationMessage; @@ -79,7 +96,16 @@ const mockTargetsAndCountsResponse = { target: { alias: mockAlias1, connectUrl: mockConnectUrl1, + jvmId: 'foo', archivedRecordings: { + jvmId: 'foo', + name: 'fooRecording1', + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'connectUrl', value: 'service:jmx:rmi://someUrl1' } + ] + }, aggregate: { count: mockCount1, }, @@ -90,7 +116,16 @@ const mockTargetsAndCountsResponse = { target: { alias: mockAlias2, connectUrl: mockConnectUrl2, + jvmId: 'foo', archivedRecordings: { + jvmId: 'foo', + name: 'fooRecording2', + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'connectUrl', value: 'service:jmx:rmi://someUrl2' } + ] + }, aggregate: { count: mockCount2, }, @@ -101,7 +136,16 @@ const mockTargetsAndCountsResponse = { target: { alias: mockAlias3, connectUrl: mockConnectUrl3, + jvmId: 'foo', archivedRecordings: { + jvmId: 'foo', + name: 'fooRecording3', + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'connectUrl', value: 'service:jmx:rmi://someUrl3' } + ] + }, aggregate: { count: mockCount3, }, @@ -111,13 +155,24 @@ const mockTargetsAndCountsResponse = { ], }, }; - +console.log("++mock targets and count", JSON.stringify(mockTargetsAndCountsResponse, null, 2)); const mockNewTargetCountResponse = { data: { targetNodes: [ { target: { + jvmId: 'foo', + connectUrl: mockNewConnectUrl, + alias: mockNewAlias, archivedRecordings: { + jvmId: 'foo', + name: 'fooRecording1', + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'connectUrl', value: 'service:jmx:rmi://someUrl3' } + ] + }, aggregate: { count: mockNewCount, }, @@ -127,6 +182,7 @@ const mockNewTargetCountResponse = { ], }, }; +console.log("++mock new target and count", JSON.stringify(mockNewTargetCountResponse, null, 2)); jest.mock('@app/Recordings/ArchivedRecordingsTable', () => { return { diff --git a/src/test/RecordingMetadata/BulkEditLabels.test.tsx b/src/test/RecordingMetadata/BulkEditLabels.test.tsx index 4745612ec..5841260bd 100644 --- a/src/test/RecordingMetadata/BulkEditLabels.test.tsx +++ b/src/test/RecordingMetadata/BulkEditLabels.test.tsx @@ -76,14 +76,16 @@ const mockActiveRecording: ActiveRecording = { const mockActiveLabelsNotification = { message: { target: mockConnectUrl, - recordingName: 'someActiveRecording', - jvmId: mockJvmId, - metadata: { - labels: [ - { key: 'someLabel', value: 'someValue' }, - { key: 'someNewLabel', value: 'someNewValue' }, + recording: { + name: 'someActiveRecording', + jvmId: mockJvmId, + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'someNewLabel', value: 'someNewValue' }, ], }, + }, }, } as NotificationMessage; @@ -92,13 +94,15 @@ const mockActiveRecordingResponse = [mockActiveRecording]; const mockArchivedLabelsNotification = { message: { target: mockConnectUrl, - recordingName: 'someArchivedRecording_some_random', - jvmId: mockJvmId, - metadata: { - labels: [ - { key: 'someLabel', value: 'someValue' }, - { key: 'someNewLabel', value: 'someNewValue' }, + recording: { + name: 'someArchivedRecording_some_random', + jvmId: mockJvmId, + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'someNewLabel', value: 'someNewValue' }, ], + } }, }, } as NotificationMessage; diff --git a/src/test/Recordings/ArchivedRecordingsTable.test.tsx b/src/test/Recordings/ArchivedRecordingsTable.test.tsx index 59a9509b9..9db8f11f1 100644 --- a/src/test/Recordings/ArchivedRecordingsTable.test.tsx +++ b/src/test/Recordings/ArchivedRecordingsTable.test.tsx @@ -82,12 +82,20 @@ mockMetadataFile.text = jest.fn(() => const mockRecording: ArchivedRecording = { name: 'someRecording', + jvmId: mockJvmId, downloadUrl: 'http://downloadUrl', reportUrl: 'http://reportUrl', - metadata: { labels: mockRecordingLabels }, + metadata: { + labels: [ + { key: 'someLabel', value: 'someValue' }, + { key: 'connectUrl', value: 'service:jmx:rmi://someUrl' } + ] + }, size: 2048, archivedTime: 2048, }; +console.log("++mockRecording", mockRecording); +console.log("++mockRecording Stringify", JSON.stringify(mockRecording, null, 2)); const mockArchivedRecordingsResponse = { data: { @@ -102,6 +110,7 @@ const mockArchivedRecordingsResponse = { ], }, }; +console.log("++mockRecording Response", mockArchivedRecordingsResponse); const mockAllArchivedRecordingsResponse = { data: { @@ -114,6 +123,7 @@ const mockAllArchivedRecordingsResponse = { }, }, }; +console.log("++mockRecording All archived", mockAllArchivedRecordingsResponse); const mockAnotherRecording = { ...mockRecording, name: 'anotherRecording' }; const mockCreateNotification = { @@ -122,9 +132,11 @@ const mockCreateNotification = { const mockLabelsNotification = { message: { target: mockConnectUrl, - recordingName: 'someRecording', - jvmId: mockJvmId, - metadata: { labels: [{ key: 'someLabel', value: 'someUpdatedValue' }] }, + recording: { + name: 'someRecording', + jvmId: mockJvmId, + metadata: { labels: [{ key: 'someLabel', value: 'someUpdatedValue' }] }, + } }, } as NotificationMessage; const mockDeleteNotification = { @@ -276,11 +288,17 @@ describe('', () => { expect(size).toBeInTheDocument(); expect(size).toBeVisible(); - mockRecordingLabels.forEach((entry) => { + /* mockRecordingLabels.forEach((entry) => { const label = screen.getByText(`${entry.key}: ${entry.value}`); expect(label).toBeInTheDocument(); expect(label).toBeVisible(); - }); + }); */ + + for (const entry of mockRecordingLabels) { + const label = await screen.findByText(`${entry.key}: ${entry.value}`); + expect(label).toBeInTheDocument(); + expect(label).toBeVisible(); + } const actionIcon = within(screen.getByLabelText(`${mockRecording.name}-actions`)).getByLabelText('Actions'); expect(actionIcon).toBeInTheDocument();