From 8a54c809495bc08782359073d9392f25c8eb6499 Mon Sep 17 00:00:00 2001 From: Dominique Clarke Date: Thu, 23 Jun 2022 13:47:10 -0400 Subject: [PATCH] [8.3] [Synthetics] adjust enabled key for browser monitors (#135016) * synthetics - adjust enabled key for browser monitors * Update x-pack/test/api_integration/apis/uptime/rest/add_monitor_project.ts --- .../synthetics_service/normalizers/browser.ts | 2 +- .../apis/uptime/rest/add_monitor_project.ts | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/synthetics/server/synthetics_service/normalizers/browser.ts b/x-pack/plugins/synthetics/server/synthetics_service/normalizers/browser.ts index 92d598192844b..207945d4e95d1 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/normalizers/browser.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/normalizers/browser.ts @@ -101,7 +101,7 @@ export const normalizeProjectMonitor = ({ [ConfigKey.ORIGINAL_SPACE]: namespace || defaultFields[ConfigKey.ORIGINAL_SPACE], [ConfigKey.CUSTOM_HEARTBEAT_ID]: `${monitor.id}-${projectId}-${namespace}`, [ConfigKey.TIMEOUT]: null, - [ConfigKey.ENABLED]: monitor.enabled || defaultFields[ConfigKey.ENABLED], + [ConfigKey.ENABLED]: monitor.enabled ?? defaultFields[ConfigKey.ENABLED], }; return { ...DEFAULT_FIELDS[DataStream.BROWSER], diff --git a/x-pack/test/api_integration/apis/uptime/rest/add_monitor_project.ts b/x-pack/test/api_integration/apis/uptime/rest/add_monitor_project.ts index 7556f9e1de606..822a297e6bcb8 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/add_monitor_project.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/add_monitor_project.ts @@ -629,5 +629,43 @@ export default function ({ getService }: FtrProviderContext) { ]); } }); + + it('project monitors - is able to enable and disable monitors', async () => { + try { + await supertest + .put(API_URLS.SYNTHETICS_MONITORS_PROJECT) + .set('kbn-xsrf', 'true') + .send(projectMonitors); + + await supertest + .put(API_URLS.SYNTHETICS_MONITORS_PROJECT) + .set('kbn-xsrf', 'true') + .send({ + ...projectMonitors, + monitors: [ + { + ...projectMonitors.monitors[0], + enabled: false, + }, + ], + }) + .expect(200); + const response = await supertest + .get(API_URLS.SYNTHETICS_MONITORS) + .query({ + query: `${syntheticsMonitorType}.attributes.journey_id: ${projectMonitors.monitors[0].id}`, + }) + .set('kbn-xsrf', 'true') + .expect(200); + const { monitors } = response.body; + expect(monitors[0].attributes.enabled).eql(false); + } finally { + await Promise.all([ + projectMonitors.monitors.map((monitor) => { + return deleteMonitor(monitor.id, projectMonitors.project); + }), + ]); + } + }); }); }