Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AO] Fix add_to_case functional test #163155

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,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');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of a race condition, sometimes the redirect happens quickly, and as a result, /home path is compared to /kibana. I removed the extra redirect and added a check after this line to ensure the page is loaded properly before moving to the next step.

This should fix the failure in this part which prevented role creation after this step and as a result, having a not found when deleting the role (AxiosError: Request failed with status code 404)

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