mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Synthetics] Drop empty project field (#134021)
* Drop empty project field * add unit test
This commit is contained in:
parent
7bfcb52901
commit
47ec76937a
2 changed files with 37 additions and 12 deletions
|
@ -269,6 +269,28 @@ describe('formatHeartbeatRequest', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('sets project fields as null when project id is empty', () => {
|
||||
const monitorId = 'test-monitor-id';
|
||||
const monitor = { ...testBrowserConfig, project_id: '' } as SyntheticsMonitor;
|
||||
const actual = formatHeartbeatRequest({
|
||||
monitor,
|
||||
monitorId,
|
||||
});
|
||||
|
||||
expect(actual).toEqual({
|
||||
...monitor,
|
||||
id: monitorId,
|
||||
fields: {
|
||||
config_id: monitorId,
|
||||
'monitor.project.name': undefined,
|
||||
'monitor.project.id': undefined,
|
||||
run_once: undefined,
|
||||
test_run_id: undefined,
|
||||
},
|
||||
fields_under_root: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('supports run once', () => {
|
||||
const monitorId = 'test-monitor-id';
|
||||
const actual = formatHeartbeatRequest({
|
||||
|
|
|
@ -82,15 +82,18 @@ export const formatHeartbeatRequest = ({
|
|||
customHeartbeatId?: string;
|
||||
runOnce?: boolean;
|
||||
testRunId?: string;
|
||||
}): SyntheticsConfig => ({
|
||||
...monitor,
|
||||
id: customHeartbeatId || monitorId,
|
||||
fields: {
|
||||
config_id: monitorId,
|
||||
'monitor.project.name': (monitor as BrowserFields)[ConfigKey.PROJECT_ID],
|
||||
'monitor.project.id': (monitor as BrowserFields)[ConfigKey.PROJECT_ID],
|
||||
run_once: runOnce,
|
||||
test_run_id: testRunId,
|
||||
},
|
||||
fields_under_root: true,
|
||||
});
|
||||
}): SyntheticsConfig => {
|
||||
const projectId = (monitor as BrowserFields)[ConfigKey.PROJECT_ID];
|
||||
return {
|
||||
...monitor,
|
||||
id: customHeartbeatId || monitorId,
|
||||
fields: {
|
||||
config_id: monitorId,
|
||||
'monitor.project.name': projectId || undefined,
|
||||
'monitor.project.id': projectId || undefined,
|
||||
run_once: runOnce,
|
||||
test_run_id: testRunId,
|
||||
},
|
||||
fields_under_root: true,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue