From 024da0fe2e7897891ee8443412328d2bd7c64dcf Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Fri, 21 Feb 2025 10:41:50 +0100 Subject: [PATCH 1/4] Attempt to fix flaky test --- .../apps/observability/pages/alerts/custom_threshold.ts | 1 + .../observability/pages/alerts/custom_threshold_preview_chart.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts index 1f69ef8a6003f..14031e066a703 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts @@ -49,6 +49,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { logger, }); await observability.alerts.common.navigateToRulesPage(); + await pageObjects.header.waitUntilLoadingHasFinished(); }); after(async () => { diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts index 188e37d237d90..14c0e61e5e5a2 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts @@ -34,6 +34,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => { logger, }); await observability.alerts.common.navigateToRulesPage(); + await pageObjects.header.waitUntilLoadingHasFinished(); }); after(async () => { From 634eb5daeda8b7e009f31915d9bee68fcbc1cb65 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Fri, 21 Feb 2025 10:47:55 +0100 Subject: [PATCH 2/4] Fix naming --- .../apps/observability/pages/alerts/custom_threshold.ts | 4 ++-- .../pages/alerts/custom_threshold_preview_chart.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts index 14031e066a703..eb8303f29cc2b 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold.ts @@ -18,7 +18,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { const logger = getService('log'); const retry = getService('retry'); const toasts = getService('toasts'); - const PageObjects = getPageObjects(['header']); + const pageObjects = getPageObjects(['header']); describe('Custom threshold rule', function () { this.tags('includeFirefox'); @@ -60,7 +60,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { it('shows the custom threshold rule in the observability section', async () => { await observability.alerts.rulesPage.clickCreateRuleButton(); - await PageObjects.header.waitUntilLoadingHasFinished(); + await pageObjects.header.waitUntilLoadingHasFinished(); await observability.alerts.rulesPage.clickOnObservabilityCategory(); await observability.alerts.rulesPage.clickOnCustomThresholdRule(); }); diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts index 14c0e61e5e5a2..eddbcaaae2734 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts @@ -9,7 +9,7 @@ import expect from 'expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; export default ({ getService, getPageObject }: FtrProviderContext) => { - const common = getPageObject('common'); + const pageObjects = getPageObject(['common', 'header']); const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -47,7 +47,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => { await observability.alerts.rulesPage.clickCreateRuleButton(); await observability.alerts.rulesPage.clickOnObservabilityCategory(); await observability.alerts.rulesPage.clickOnCustomThresholdRule(); - await common.sleep(1000); + await pageObjects.common.sleep(1000); expect(await find.existsByCssSelector('[data-rendering-count="2"]')).toBe(true); }); From 5557e91e7aadb8afdb4489bf011adde35e3a4411 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Fri, 21 Feb 2025 10:49:10 +0100 Subject: [PATCH 3/4] Change getPageObject to getPageObjects --- .../pages/alerts/custom_threshold_preview_chart.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts index eddbcaaae2734..637506c91fb90 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/custom_threshold_preview_chart.ts @@ -8,8 +8,7 @@ import expect from 'expect'; import { FtrProviderContext } from '../../../../ftr_provider_context'; -export default ({ getService, getPageObject }: FtrProviderContext) => { - const pageObjects = getPageObject(['common', 'header']); +export default ({ getService, getPageObjects }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); const kibanaServer = getService('kibanaServer'); @@ -17,6 +16,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => { const find = getService('find'); const logger = getService('log'); const retry = getService('retry'); + const pageObjects = getPageObjects(['common', 'header']); describe('Custom threshold preview chart', () => { const observability = getService('observability'); From 61e1f5999f6848b8610e131a13519e0f43cb4f14 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Fri, 21 Feb 2025 11:24:30 +0100 Subject: [PATCH 4/4] Add log --- .../test/functional/services/observability/alerts/rules_page.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/test/functional/services/observability/alerts/rules_page.ts b/x-pack/test/functional/services/observability/alerts/rules_page.ts index f5b16dc3914ab..588e64fca0bfb 100644 --- a/x-pack/test/functional/services/observability/alerts/rules_page.ts +++ b/x-pack/test/functional/services/observability/alerts/rules_page.ts @@ -12,6 +12,7 @@ const CUSTOM_THRESHOLD_RULE_TYPE_SELECTOR = 'observability.rules.custom_threshol export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const find = getService('find'); + const log = getService('log'); const getManageRulesPageHref = async () => { const manageRulesPageButton = await testSubjects.find('manageRulesPageButton'); @@ -21,6 +22,7 @@ export function ObservabilityAlertsRulesProvider({ getService }: FtrProviderCont const clickCreateRuleButton = async () => { await testSubjects.existOrFail('createRuleButton'); const createRuleButton = await testSubjects.find('createRuleButton'); + log.debug(`clicking on ${await createRuleButton.getAttribute('innerText')}`); return await createRuleButton.click(); };