diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx index d352ccef51a9..14d3495cb96e 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.test.tsx @@ -9,11 +9,11 @@ import React from 'react'; import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { render } from '../../../lib/helper/rtl_helpers'; -import { DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types'; +import { ConfigKey, DataStream, HTTPFields, ScheduleUnit } from '../../../../common/runtime_types'; import { MonitorManagementList } from './monitor_list'; import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; -describe('', () => { +describe('', () => { const setRefresh = jest.fn(); const setPageSize = jest.fn(); const setPageIndex = jest.fn(); @@ -110,4 +110,64 @@ describe('', () => { expect(setPageIndex).toBeCalledWith(2); expect(setRefresh).toBeCalledWith(true); }); + + it.each([ + [DataStream.BROWSER, ConfigKey.SOURCE_INLINE], + [DataStream.HTTP, ConfigKey.URLS], + [DataStream.TCP, ConfigKey.HOSTS], + [DataStream.ICMP, ConfigKey.HOSTS], + ])( + 'appends inline to the monitor id for browser monitors and omits for lightweight checks', + (type, configKey) => { + const id = '123456'; + const name = 'sample monitor'; + const browserState = { + monitorManagementList: { + ...state.monitorManagementList, + list: { + ...state.monitorManagementList.list, + monitors: [ + { + id, + attributes: { + name, + schedule: { + unit: ScheduleUnit.MINUTES, + number: '1', + }, + [configKey]: 'test', + type, + tags: [`tag-1`], + }, + }, + ], + }, + }, + }; + + render( + , + { state: browserState } + ); + + const link = screen.getByText(name) as HTMLAnchorElement; + + expect(link.href).toEqual( + expect.stringContaining( + `/app/uptime/monitor/${Buffer.from( + `${id}${type === DataStream.BROWSER ? `-inline` : ''}`, + 'utf8' + ).toString('base64')}` + ) + ); + + expect(setPageIndex).toBeCalledWith(2); + expect(setRefresh).toBeCalledWith(true); + } + ); }); diff --git a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx index 75c94c2d07d1..a0785df79bd7 100644 --- a/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/uptime/public/components/monitor_management/monitor_list/monitor_list.tsx @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; import { EuiBasicTable, EuiPanel, EuiSpacer, EuiLink } from '@elastic/eui'; import { SyntheticsMonitorSavedObject } from '../../../../common/types'; import { MonitorManagementList as MonitorManagementListState } from '../../../state/reducers/monitor_management'; -import { MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types'; +import { DataStream, MonitorFields, SyntheticsMonitor } from '../../../../common/runtime_types'; import { UptimeSettingsContext } from '../../../contexts'; import { Actions } from './actions'; import { MonitorLocations } from './monitor_locations'; @@ -66,14 +66,19 @@ export const MonitorManagementList = ({ defaultMessage: 'Monitor name', }), render: ({ - attributes: { name }, + attributes: { name, type }, id, }: { attributes: Partial; id: string; }) => ( {name}