Skip to content

Commit

Permalink
[AO] Fix add_to_case functional test (#163155)
Browse files Browse the repository at this point in the history
Fixes #156312, fixes #156677, fixes #156928, fixes #156929, fixes
#156588

## Summary

Fixes the functional test based on @dmlemeshko 's suggestion.

Flaky test runner [50]:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2776
Flaky test runner [200]:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2804
Flaky test runner [200]:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2843
--> After the last change related to redirect, failures in this test are
related to #163427

[DONE] ~~**[On hold]** Will merge it after investigating
#156588 to make sure all the
related issues are fixed for this function test.~~

(cherry picked from commit b97059c)
  • Loading branch information
maryam-saeidi committed Aug 22, 2023
1 parent 653a0d7 commit 3e314df
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 () => {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/test/functional/services/observability/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

/**
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 3e314df

Please sign in to comment.