diff --git a/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.test.ts b/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.test.ts index 407442ea0f..2c0a423ded 100644 --- a/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.test.ts +++ b/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.test.ts @@ -9,16 +9,6 @@ jest.mock('../../../../react-services', () => ({ }), })); -const mockedResponseClusterStatus = { - data: { - data: { - enabled: 'yes', - running: 'yes', - }, - error: 0, - }, -}; - describe('Register agent service', () => { beforeEach(() => jest.clearAllMocks()); describe('getRemoteConfiguration', () => { @@ -51,14 +41,13 @@ describe('Register agent service', () => { }, }; - WzRequest.apiReq = jest - .fn() - .mockResolvedValueOnce(mockedResponseClusterStatus) - .mockResolvedValueOnce(mockedResponse); + WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse); const nodeName = 'example-node'; const res = await RegisterAgentService.getRemoteConfiguration( - 'example-node', + nodeName, + false, ); + console.log(res); expect(res.name).toBe(nodeName); expect(res.haveSecureConnection).toBe(true); }); @@ -84,13 +73,11 @@ describe('Register agent service', () => { }, }, }; - WzRequest.apiReq = jest - .fn() - .mockResolvedValueOnce(mockedResponseClusterStatus) - .mockResolvedValueOnce(mockedResponse); + WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse); const nodeName = 'example-node'; const res = await RegisterAgentService.getRemoteConfiguration( - 'example-node', + nodeName, + false, ); expect(res.name).toBe(nodeName); expect(res.haveSecureConnection).toBe(false); @@ -124,13 +111,11 @@ describe('Register agent service', () => { }, }, }; - WzRequest.apiReq = jest - .fn() - .mockResolvedValueOnce(mockedResponseClusterStatus) - .mockResolvedValueOnce(mockedResponse); + WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse); const nodeName = 'example-node'; const res = await RegisterAgentService.getRemoteConfiguration( - 'example-node', + nodeName, + false, ); expect(res.name).toBe(nodeName); expect(res.isUdp).toEqual(true); @@ -164,13 +149,11 @@ describe('Register agent service', () => { }, }, }; - WzRequest.apiReq = jest - .fn() - .mockResolvedValueOnce(mockedResponseClusterStatus) - .mockResolvedValueOnce(mockedResponse); + WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse); const nodeName = 'example-node'; const res = await RegisterAgentService.getRemoteConfiguration( - 'example-node', + nodeName, + false, ); expect(res.name).toBe(nodeName); expect(res.isUdp).toEqual(false); @@ -204,13 +187,11 @@ describe('Register agent service', () => { }, }, }; - WzRequest.apiReq = jest - .fn() - .mockResolvedValueOnce(mockedResponseClusterStatus) - .mockResolvedValueOnce(mockedResponse); + WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse); const nodeName = 'example-node'; const res = await RegisterAgentService.getRemoteConfiguration( - 'example-node', + nodeName, + false, ); expect(res.name).toBe(nodeName); expect(res.isUdp).toEqual(false); diff --git a/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.tsx b/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.tsx index 9f9b23f411..19de19808e 100644 --- a/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.tsx +++ b/plugins/main/public/components/endpoints-summary/register-agent/services/register-agent-services.tsx @@ -73,7 +73,7 @@ async function getRemoteConfiguration( {}, ); } - const items = ((result.data || {}).data || {}).affected_items || []; + const items = result?.data?.data?.affected_items || []; const remote = items[0]?.remote; if (remote) { const remoteFiltered = remote.filter((item: RemoteItem) => {