From 0821bc1fce1f04c6addee17c0ce65776e4297a56 Mon Sep 17 00:00:00 2001 From: shahzad31 Date: Thu, 24 Oct 2024 09:22:18 +0200 Subject: [PATCH 1/2] update tests --- .../alert_rules/custom_status_alert.journey.ts | 18 +++--------------- .../journeys/services/synthetics_services.ts | 9 +++++---- .../synthetics/page_objects/synthetics_app.tsx | 5 +++++ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts index 58f59995faabc..b89f294392da5 100644 --- a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts +++ b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { journey, step, before, after, expect } from '@elastic/synthetics'; +import { journey, step, before, after } from '@elastic/synthetics'; import { RetryService } from '@kbn/ftr-common-functional-services'; import { syntheticsAppPageProvider } from '../../page_objects/synthetics_app'; import { SyntheticsServices } from '../services/synthetics_services'; @@ -61,19 +61,7 @@ journey(`CustomStatusAlert`, async ({ page, params }) => { }); step('verify rule creation', async () => { - await retry.try(async () => { - const rules = await services.getRules(); - expect(rules.length).toBe(3); - expect(rules[2].params).toStrictEqual({ - condition: { - downThreshold: 3, - locationsThreshold: 1, - groupBy: 'locationId', - window: { - numberOfChecks: 5, - }, - }, - }); - }); + await syntheticsApp.goToRulesPage(); + await page.waitForSelector(`text='Synthetics status rule'`); }); }); diff --git a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts index 23c5ef45d1383..b2d2b12ee944c 100644 --- a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts +++ b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts @@ -222,11 +222,12 @@ export class SyntheticsServices { } async getRules() { - const response = await axios.get(this.kibanaUrl + '/internal/alerting/rules/_find', { - auth: { username: 'elastic', password: 'changeme' }, - headers: { 'kbn-xsrf': 'true' }, + const response = await this.requester.request({ + path: `/internal/alerting/rules/_find`, + method: 'GET', }); - return response.data.data; + + return response.data?.data; } async setupTestConnector() { diff --git a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx index f6d5ce45b96c3..931694da554ca 100644 --- a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx +++ b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/page_objects/synthetics_app.tsx @@ -393,5 +393,10 @@ export function syntheticsAppPageProvider({ const isDisabled = await addMonitorBtn.isDisabled(); return !isDisabled; }, + + async goToRulesPage() { + const rulesPage = '/app/observability/alerts/rules'; + await page.goto(basePath + rulesPage); + }, }; } From cd131146500f20cc9fd60fcfccc47bb2bba1808a Mon Sep 17 00:00:00 2001 From: shahzad31 Date: Thu, 24 Oct 2024 09:22:55 +0200 Subject: [PATCH 2/2] update --- .../journeys/alert_rules/custom_status_alert.journey.ts | 3 --- .../synthetics/journeys/services/synthetics_services.ts | 9 --------- 2 files changed, 12 deletions(-) diff --git a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts index b89f294392da5..3d45e0698f616 100644 --- a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts +++ b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/alert_rules/custom_status_alert.journey.ts @@ -6,7 +6,6 @@ */ import { journey, step, before, after } from '@elastic/synthetics'; -import { RetryService } from '@kbn/ftr-common-functional-services'; import { syntheticsAppPageProvider } from '../../page_objects/synthetics_app'; import { SyntheticsServices } from '../services/synthetics_services'; @@ -14,8 +13,6 @@ journey(`CustomStatusAlert`, async ({ page, params }) => { const syntheticsApp = syntheticsAppPageProvider({ page, kibanaUrl: params.kibanaUrl, params }); const services = new SyntheticsServices(params); - const getService = params.getService; - const retry: RetryService = getService('retry'); const firstCheckTime = new Date(Date.now()).toISOString(); diff --git a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts index b2d2b12ee944c..5c356492f1c24 100644 --- a/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts +++ b/x-pack/plugins/observability_solution/synthetics/e2e/synthetics/journeys/services/synthetics_services.ts @@ -221,15 +221,6 @@ export class SyntheticsServices { } } - async getRules() { - const response = await this.requester.request({ - path: `/internal/alerting/rules/_find`, - method: 'GET', - }); - - return response.data?.data; - } - async setupTestConnector() { const indexConnector = { name: 'test index',