From 0375352d1a4be01e31653b40b75f78c9981c4882 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 14 Dec 2023 11:39:03 -0500 Subject: [PATCH] remove WsClientActivity notifications --- .../Services/NotificationChannel.service.tsx | 2 +- .../Shared/Services/Notifications.service.tsx | 13 +-- src/app/Shared/Services/api.types.ts | 1 - src/app/Shared/Services/api.utils.ts | 13 --- src/mirage/index.ts | 20 +---- .../Settings/NotificationControl.test.tsx | 12 +-- .../NotificationControl.test.tsx.snap | 87 +++++-------------- 7 files changed, 34 insertions(+), 114 deletions(-) diff --git a/src/app/Shared/Services/NotificationChannel.service.tsx b/src/app/Shared/Services/NotificationChannel.service.tsx index ffcd717853..d3e747879c 100644 --- a/src/app/Shared/Services/NotificationChannel.service.tsx +++ b/src/app/Shared/Services/NotificationChannel.service.tsx @@ -127,7 +127,7 @@ export class NotificationChannel { fn.apply(this.notifications, [ 'WebSocket connection lost', msg, - NotificationCategory.WsClientActivity, + 'Client Status', fn === this.notifications.info, ]); }, diff --git a/src/app/Shared/Services/Notifications.service.tsx b/src/app/Shared/Services/Notifications.service.tsx index 9a61e65fe1..e7f52707e4 100644 --- a/src/app/Shared/Services/Notifications.service.tsx +++ b/src/app/Shared/Services/Notifications.service.tsx @@ -98,12 +98,7 @@ export class NotificationService { cryostatStatusNotifications(): Observable { return this.notifications().pipe( - map((a) => - a.filter( - (n) => - (this.isWsClientActivity(n) || this.isJvmDiscovery(n)) && !NotificationService.isProblemNotification(n), - ), - ), + map((a) => a.filter((n) => this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n))), ); } @@ -153,11 +148,7 @@ export class NotificationService { } private isActionNotification(n: Notification): boolean { - return !this.isWsClientActivity(n) && !this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n); - } - - private isWsClientActivity(n: Notification): boolean { - return n.category === NotificationCategory.WsClientActivity; + return !this.isJvmDiscovery(n) && !NotificationService.isProblemNotification(n); } private isJvmDiscovery(n: Notification): boolean { diff --git a/src/app/Shared/Services/api.types.ts b/src/app/Shared/Services/api.types.ts index 86cd9f6d77..11cf9fa6f8 100644 --- a/src/app/Shared/Services/api.types.ts +++ b/src/app/Shared/Services/api.types.ts @@ -537,7 +537,6 @@ export interface Notification { } export enum NotificationCategory { - WsClientActivity = 'WsClientActivity', TargetJvmDiscovery = 'TargetJvmDiscovery', ActiveRecordingCreated = 'ActiveRecordingCreated', ActiveRecordingStopped = 'ActiveRecordingStopped', diff --git a/src/app/Shared/Services/api.utils.ts b/src/app/Shared/Services/api.utils.ts index 5eb3caf731..b4cc3df1a6 100644 --- a/src/app/Shared/Services/api.utils.ts +++ b/src/app/Shared/Services/api.utils.ts @@ -222,19 +222,6 @@ export const messageKeys = new Map([ }, } as NotificationMessageMapper, ], - [ - NotificationCategory.WsClientActivity, - { - variant: AlertVariant.info, - title: 'WebSocket Client Activity', - body: (evt) => { - const addr = Object.keys(evt.message)[0]; - const status = evt.message[addr]; - return `Client at ${addr} ${status}`; - }, - hidden: true, - } as NotificationMessageMapper, - ], [ NotificationCategory.ActiveRecordingCreated, { diff --git a/src/mirage/index.ts b/src/mirage/index.ts index 5de3574e1e..9bc8be6245 100644 --- a/src/mirage/index.ts +++ b/src/mirage/index.ts @@ -27,25 +27,7 @@ export const startMirage = ({ environment = 'development' } = {}) => { // Create a mock server socket to send notifications let websocket: Client; - wsServer.on('connection', (socket) => { - websocket = socket; - socket.on('message', (_) => { - socket.send( - JSON.stringify({ - meta: { - category: 'WsClientActivity', - type: { - type: 'application', - subtype: 'json', - }, - }, - message: { - '127.0.0.1': 'accepted', - }, - }), - ); - }); - }); + wsServer.on('connection', (_) => {}); // Create a MirageJS Server to intercept network requests return createServer({ diff --git a/src/test/Settings/NotificationControl.test.tsx b/src/test/Settings/NotificationControl.test.tsx index 3c4779a352..290fa8e062 100644 --- a/src/test/Settings/NotificationControl.test.tsx +++ b/src/test/Settings/NotificationControl.test.tsx @@ -147,14 +147,14 @@ describe('', () => { await user.click(expandButton); - const webSocketAct = screen.getByLabelText('WebSocket Client Activity'); - expect(webSocketAct).toBeInTheDocument(); - expect(webSocketAct).toBeVisible(); - expect(webSocketAct).toBeChecked(); + const targetDiscovery = screen.getByLabelText('Target JVM Discovery'); + expect(targetDiscovery).toBeInTheDocument(); + expect(targetDiscovery).toBeVisible(); + expect(targetDiscovery).toBeChecked(); - await user.click(webSocketAct); + await user.click(targetDiscovery); - expect(webSocketAct).not.toBeChecked(); + expect(targetDiscovery).not.toBeChecked(); expect(enableSwitch).not.toBeChecked(); }); }); diff --git a/src/test/Settings/__snapshots__/NotificationControl.test.tsx.snap b/src/test/Settings/__snapshots__/NotificationControl.test.tsx.snap index 1bbb529eaa..81dc3ffc8d 100644 --- a/src/test/Settings/__snapshots__/NotificationControl.test.tsx.snap +++ b/src/test/Settings/__snapshots__/NotificationControl.test.tsx.snap @@ -239,45 +239,6 @@ exports[` renders correctly 1`] = ` data-ouia-component-id="OUIA-Generated-Switch-2" data-ouia-component-type="PF4/Switch" data-ouia-safe={true} - htmlFor="WsClientActivity" - > - - - - - - -
-