From 80e2b51aa8b6a9137d6223a73b0964709a868cf1 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Fri, 4 Aug 2023 13:04:35 +0200 Subject: [PATCH 1/3] Fix functional test --- .../services/observability/alerts/add_to_case.ts | 3 ++- .../observability/pages/alerts/add_to_case.ts | 16 +++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/x-pack/test/functional/services/observability/alerts/add_to_case.ts b/x-pack/test/functional/services/observability/alerts/add_to_case.ts index 7211325fad2a1..6197273243432 100644 --- a/x-pack/test/functional/services/observability/alerts/add_to_case.ts +++ b/x-pack/test/functional/services/observability/alerts/add_to_case.ts @@ -52,7 +52,8 @@ export function ObservabilityAlertsAddToCaseProvider({ getService }: FtrProvider }; const closeFlyout = async () => { - return await (await testSubjects.find('euiFlyoutCloseButton')).click(); + await testSubjects.click('euiFlyoutCloseButton'); // click close button + await testSubjects.missingOrFail('euiFlyoutCloseButton'); // wait for flyout to be closed }; const getAddToExistingCaseModalOrFail = async () => { diff --git a/x-pack/test/observability_functional/apps/observability/pages/alerts/add_to_case.ts b/x-pack/test/observability_functional/apps/observability/pages/alerts/add_to_case.ts index cd33c64cc0183..062678ec989ca 100644 --- a/x-pack/test/observability_functional/apps/observability/pages/alerts/add_to_case.ts +++ b/x-pack/test/observability_functional/apps/observability/pages/alerts/add_to_case.ts @@ -25,8 +25,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { await esArchiver.unload('x-pack/test/functional/es_archives/observability/alerts'); }); - // FLAKY: https://github.com/elastic/kibana/issues/156312 - describe.skip('When user has all privileges for cases', () => { + describe('When user has all privileges for cases', () => { before(async () => { await observability.users.setTestUserRole( observability.users.defineBasicObservabilityRole({ @@ -42,9 +41,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { }); it('renders case options in the overflow menu', async () => { - await retry.try(async () => { - await observability.alerts.common.openActionsMenuForRow(0); - }); + await observability.alerts.common.openActionsMenuForRow(0); await retry.try(async () => { await observability.alerts.addToCase.getAddToExistingCaseSelectorOrFail(); @@ -64,9 +61,7 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { }); it('opens a modal when Add to existing case is clicked', async () => { - await retry.try(async () => { - await observability.alerts.common.openActionsMenuForRow(0); - }); + await observability.alerts.common.openActionsMenuForRow(0); await retry.try(async () => { await observability.alerts.addToCase.addToExistingCaseButtonClick(); @@ -91,9 +86,8 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => { }); it('does not render case options in the overflow menu', async () => { - await retry.try(async () => { - await observability.alerts.common.openActionsMenuForRow(0); - }); + await observability.alerts.common.openActionsMenuForRow(0); + await retry.try(async () => { await observability.alerts.addToCase.missingAddToExistingCaseSelectorOrFail(); await observability.alerts.addToCase.missingAddToNewCaseSelectorOrFail(); From 3d59d88e4c998ff6de79fe6a622f1b3dee409e37 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Mon, 7 Aug 2023 17:12:20 +0200 Subject: [PATCH 2/3] Wait for the actoin menu to appear in functional test --- .../public/pages/alerts/components/alert_actions.tsx | 6 +++++- .../test/functional/services/observability/alerts/common.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx b/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx index b82b45f1065e2..14afd4994b2be 100644 --- a/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx +++ b/x-pack/plugins/observability/public/pages/alerts/components/alert_actions.tsx @@ -248,7 +248,11 @@ export function AlertActions({ isOpen={isPopoverOpen} panelPaddingSize="none" > - + diff --git a/x-pack/test/functional/services/observability/alerts/common.ts b/x-pack/test/functional/services/observability/alerts/common.ts index 7a3f1f609a403..5986de63a2d74 100644 --- a/x-pack/test/functional/services/observability/alerts/common.ts +++ b/x-pack/test/functional/services/observability/alerts/common.ts @@ -20,6 +20,7 @@ const DATE_WITH_DATA = { const ALERTS_FLYOUT_SELECTOR = 'alertsFlyout'; const FILTER_FOR_VALUE_BUTTON_SELECTOR = 'filterForValue'; const ALERTS_TABLE_CONTAINER_SELECTOR = 'alertsTable'; +const ALERTS_TABLE_ACTIONS_MENU_SELECTOR = 'alertsTableActionsMenu'; const VIEW_RULE_DETAILS_SELECTOR = 'viewRuleDetails'; const VIEW_RULE_DETAILS_FLYOUT_SELECTOR = 'viewRuleDetailsFlyout'; @@ -209,6 +210,7 @@ export function ObservabilityAlertsCommonProvider({ const openActionsMenuForRow = retryOnStale.wrap(async (rowIndex: number) => { const actionsOverflowButton = await getActionsButtonByIndex(rowIndex); await actionsOverflowButton.click(); + await testSubjects.existOrFail(ALERTS_TABLE_ACTIONS_MENU_SELECTOR); }); const viewRuleDetailsButtonClick = async () => { From fe0dd26684fd8af0e8938ff7f8d14ba41e1e9d00 Mon Sep 17 00:00:00 2001 From: Maryam Saeidi Date: Thu, 10 Aug 2023 14:33:13 +0200 Subject: [PATCH 3/3] Navigate to /home instead of /kibana and ensure the home page is loaded --- x-pack/test/functional/services/observability/users.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional/services/observability/users.ts b/x-pack/test/functional/services/observability/users.ts index 4e33afe270223..ba67ce8602f50 100644 --- a/x-pack/test/functional/services/observability/users.ts +++ b/x-pack/test/functional/services/observability/users.ts @@ -11,9 +11,11 @@ import { FtrProviderContext } from '../../ftr_provider_context'; type CreateRolePayload = Pick; const OBSERVABILITY_TEST_ROLE_NAME = 'observability-functional-test-role'; +const HOME_PAGE_SELECTOR = 'homeApp'; export function ObservabilityUsersProvider({ getPageObject, getService }: FtrProviderContext) { const security = getService('security'); + const testSubjects = getService('testSubjects'); const commonPageObject = getPageObject('common'); /** @@ -24,7 +26,8 @@ export function ObservabilityUsersProvider({ getPageObject, getService }: FtrPro */ const setTestUserRole = async (roleDefinition: CreateRolePayload) => { // return to neutral grounds to avoid running into permission problems on reload - await commonPageObject.navigateToActualUrl('kibana'); + await commonPageObject.navigateToActualUrl('home'); + await testSubjects.existOrFail(HOME_PAGE_SELECTOR); await security.role.create(OBSERVABILITY_TEST_ROLE_NAME, roleDefinition);