[8.9] [AO] Fix add_to_case functional test (#163155) (#164436)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[AO] Fix add_to_case functional test
(#163155)](https://github.com/elastic/kibana/pull/163155)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

Co-authored-by: Maryam Saeidi <maryam.saeidi@elastic.co>
This commit is contained in:
Kibana Machine 2023-08-22 09:20:40 -04:00 committed by GitHub
parent 59b16e06dd
commit 499993f892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 14 deletions

View file

@ -255,7 +255,11 @@ export function AlertActions({
isOpen={isPopoverOpen}
panelPaddingSize="none"
>
<EuiContextMenuPanel size="s" items={actionsMenuItems} />
<EuiContextMenuPanel
size="s"
items={actionsMenuItems}
data-test-subj="alertsTableActionsMenu"
/>
</EuiPopover>
</EuiFlexItem>
</>

View file

@ -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 () => {

View file

@ -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 () => {

View file

@ -11,9 +11,11 @@ import { FtrProviderContext } from '../../ftr_provider_context';
type CreateRolePayload = Pick<Role, 'metadata' | 'elasticsearch' | 'kibana'>;
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);

View file

@ -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();