Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Aug 12, 2021
1 parent af0f496 commit 3c576a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
4 changes: 4 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const ID_FIELD = '[data-test-subj="timeline"] [data-test-subj="field-name

export const ID_TOGGLE_FIELD = '[data-test-subj="toggle-field-_id"]';

export const ID_HOVER_ACTION_OVERFLOW_BTN = '[data-test-subj="more-actions-_id"]';

export const LOCKED_ICON = '[data-test-subj="timeline-date-picker-lock-button"]';

export const UNLOCKED_ICON = '[data-test-subj="timeline-date-picker-unlock-button"]';
Expand Down Expand Up @@ -266,3 +268,5 @@ export const TIMELINE_TAB_CONTENT_PINNED = '[data-test-subj="timeline-tab-conten

export const TIMELINE_TAB_CONTENT_GRAPHS_NOTES =
'[data-test-subj="timeline-tab-content-graph-notes"]';

export const TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN = '[data-test-subj="more-actions-@timestamp"]';
17 changes: 17 additions & 0 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ID_FIELD,
ID_HEADER_FIELD,
ID_TOGGLE_FIELD,
ID_HOVER_ACTION_OVERFLOW_BTN,
NOTES_TAB_BUTTON,
NOTES_TEXT_AREA,
OPEN_TIMELINE_ICON,
Expand Down Expand Up @@ -64,6 +65,7 @@ import {
TIMELINE_CREATE_TEMPLATE_FROM_TIMELINE_BTN,
TIMELINE_COLLAPSED_ITEMS_BTN,
TIMELINE_TAB_CONTENT_EQL,
TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN,
} from '../screens/timeline';
import { REFRESH_BUTTON, TIMELINE } from '../screens/timelines';

Expand Down Expand Up @@ -189,7 +191,14 @@ export const attachTimelineToExistingCase = () => {
cy.get(ATTACH_TIMELINE_TO_EXISTING_CASE_ICON).click({ force: true });
};

const clickIdHoverActionOverflowButton = () => {
cy.get(ID_HOVER_ACTION_OVERFLOW_BTN).should('exist');

cy.get(ID_HOVER_ACTION_OVERFLOW_BTN).click({ force: true });
};

export const clickIdToggleField = () => {
clickIdHoverActionOverflowButton();
cy.get(ID_HEADER_FIELD).should('not.exist');

cy.get(ID_TOGGLE_FIELD).click({
Expand Down Expand Up @@ -294,7 +303,15 @@ export const unpinFirstEvent = () => {
cy.get(PIN_EVENT).first().click({ force: true });
};

const clickTimestampHoverActionOverflowButton = () => {
cy.get(TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN).should('exist');

cy.get(TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN).click({ force: true });
};

export const clickTimestampToggleField = () => {
clickTimestampHoverActionOverflowButton();

cy.get(TIMESTAMP_TOGGLE_FIELD).should('exist');

cy.get(TIMESTAMP_TOGGLE_FIELD).click({ force: true });
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const OverflowButton: React.FC<OverflowButtonProps> = React.memo(
<Component
aria-label={MORE_ACTIONS}
buttonRef={defaultFocusedButtonRef}
data-test-subj="add-to-timeline"
data-test-subj={`more-actions-${field}`}
icon="boxesHorizontal"
iconType="boxesHorizontal"
onClick={onClick}
Expand All @@ -81,7 +81,7 @@ const OverflowButton: React.FC<OverflowButtonProps> = React.memo(
aria-label={MORE_ACTIONS}
buttonRef={defaultFocusedButtonRef}
className="timelines__hoverActionButton"
data-test-subj="more-actions"
data-test-subj={`more-actions-${field}`}
iconSize="s"
iconType="boxesHorizontal"
onClick={onClick}
Expand All @@ -96,7 +96,15 @@ const OverflowButton: React.FC<OverflowButtonProps> = React.memo(
<EuiContextMenuPanel items={items} />
</EuiPopover>
),
[Component, defaultFocusedButtonRef, onClick, isOverflowPopoverOpen, closePopOver, items]
[
Component,
defaultFocusedButtonRef,
field,
onClick,
isOverflowPopoverOpen,
closePopOver,
items,
]
);

return showTooltip ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const mockHoverActions = {
getCopyButton: () => <>{'Copy button'}</>,
getFilterForValueButton: () => <>{'Filter button'}</>,
getFilterOutValueButton: () => <>{'Filter out button'}</>,
getOverflowButton: () => <>{'Overflow button'}</>,
};

0 comments on commit 3c576a3

Please sign in to comment.