Skip to content

Commit

Permalink
test case for clicking on add to new case button
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Oct 12, 2021
1 parent ff64372 commit 40b847d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({
{userCanCrud && (
<EuiContextMenuItem
aria-label={ariaLabel}
data-test-subj="attach-alert-to-case-button"
data-test-subj="add-existing-case-menu-item"
onClick={addExistingCaseClick}
// needs forced size="s" since it is lazy loaded and the EuiContextMenuPanel can not initialize the size
size="s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const AddToCaseActionComponent: React.FC<AddToCaseActionProps> = ({
{userCanCrud && (
<EuiContextMenuItem
aria-label={ariaLabel}
data-test-subj="attach-alert-to-case-button"
data-test-subj="add-new-case-item"
onClick={addNewCaseClick}
// needs forced size="s" since it is lazy loaded and the EuiContextMenuPanel can not initialize the size
size="s"
Expand Down
16 changes: 14 additions & 2 deletions x-pack/test/functional/services/observability/alerts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ const ALERTS_FLYOUT_SELECTOR = 'alertsFlyout';
const COPY_TO_CLIPBOARD_BUTTON_SELECTOR = 'copy-to-clipboard';
const ALERTS_TABLE_CONTAINER_SELECTOR = 'events-viewer-panel';
const ACTION_COLUMN_INDEX = 1;
const ADD_TO_EXISTING_CASE_SELECTOR = 'attach-alert-to-case-button';
const ADD_TO_NEW_CASE_SELECTOR = 'attach-alert-to-case-button';
// CASES
const ADD_TO_EXISTING_CASE_SELECTOR = 'add-existing-case-menu-item';
const ADD_TO_NEW_CASE_SELECTOR = 'add-new-case-item';
const CREATE_CASE_FLYOUT = 'create-case-flyout';

type WorkflowStatus = 'open' | 'acknowledged' | 'closed';

Expand Down Expand Up @@ -207,6 +209,14 @@ export function ObservabilityAlertsCommonProvider({
return await testSubjects.missingOrFail(ADD_TO_NEW_CASE_SELECTOR);
};

const addToNewCaseButtonClick = async () => {
return await (await getAddToNewCaseSelector()).click();
};

const getCreateCaseFlyoutOrFail = async () => {
return await testSubjects.existOrFail(CREATE_CASE_FLYOUT);
};

return {
getQueryBar,
clearQueryBar,
Expand Down Expand Up @@ -238,5 +248,7 @@ export function ObservabilityAlertsCommonProvider({
getAddToNewCaseSelector,
getAddToNewCaseSelectorOrFail,
missingAddToNewCaseSelectorOrFail,
getCreateCaseFlyoutOrFail,
addToNewCaseButtonClick,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export default ({ getService, getPageObjects }: FtrProviderContext) => {
});
});

it('opens a flyout when Add to new case is clicked', async () => {});
it('opens a flyout when Add to new case is clicked', async () => {
await retry.try(async () => {
await observability.alerts.common.openActionsMenuForRow(0);
await observability.alerts.common.addToNewCaseButtonClick();
await observability.alerts.common.getCreateCaseFlyoutOrFail();
});
});

it('opens a modal when Add to existing case is clicked', async () => {});
});
Expand Down

0 comments on commit 40b847d

Please sign in to comment.