Skip to content

Commit

Permalink
CI Text fixes / prefixes (elastic#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
opauloh authored Feb 24, 2022
1 parent 9370452 commit 704b3eb
Show file tree
Hide file tree
Showing 19 changed files with 105 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('DetailPanelAccordion component', () => {
<DetailPanelAccordion id={TEST_ID} listItems={TEST_LIST_ITEM} title={TEST_TITLE} />
);

expect(renderResult.queryByTestId('sessionViewer:detail-panel-accordion')).toBeVisible();
expect(renderResult.queryByTestId('sessionView:detail-panel-accordion')).toBeVisible();
});

it('should render acoordion with tooltip', async () => {
Expand All @@ -47,9 +47,9 @@ describe('DetailPanelAccordion component', () => {
/>
);

expect(renderResult.queryByTestId('sessionViewer:detail-panel-accordion')).toBeVisible();
expect(renderResult.queryByTestId('sessionView:detail-panel-accordion')).toBeVisible();
expect(
renderResult.queryByTestId('sessionViewer:detail-panel-accordion-tooltip')
renderResult.queryByTestId('sessionView:detail-panel-accordion-tooltip')
).toBeVisible();
});

Expand All @@ -65,9 +65,9 @@ describe('DetailPanelAccordion component', () => {
/>
);

expect(renderResult.queryByTestId('sessionViewer:detail-panel-accordion')).toBeVisible();
expect(renderResult.queryByTestId('sessionView:detail-panel-accordion')).toBeVisible();
const extraActionButton = renderResult.getByTestId(
'sessionViewer:detail-panel-accordion-action'
'sessionView:detail-panel-accordion-action'
);
expect(extraActionButton).toHaveTextContent(ACTION_TEXT);
extraActionButton.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const DetailPanelAccordion = ({
<span>{title}</span>
</EuiFlexItem>
{tooltipContent && (
<EuiFlexItem grow={false} data-test-subj="sessionViewer:detail-panel-accordion-tooltip">
<EuiFlexItem grow={false} data-test-subj="sessionView:detail-panel-accordion-tooltip">
<EuiIconTip content={tooltipContent} />
</EuiFlexItem>
)}
Expand All @@ -61,14 +61,14 @@ export const DetailPanelAccordion = ({
size="s"
color="primary"
onClick={onExtraActionClick}
data-test-subj="sessionViewer:detail-panel-accordion-action"
data-test-subj="sessionView:detail-panel-accordion-action"
>
{extraActionTitle}
</EuiButtonEmpty>
) : null
}
css={styles.accordion}
data-test-subj="sessionViewer:detail-panel-accordion"
data-test-subj="sessionView:detail-panel-accordion"
>
<DetailPanelDescriptionList listItems={listItems} />
</EuiAccordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ describe('DetailPanelDescriptionList component', () => {
<DetailPanelDescriptionList listItems={TEST_LIST_ITEM} />
);

expect(
renderResult.queryByTestId('sessionViewer:detail-panel-description-list')
).toBeVisible();
expect(renderResult.queryByTestId('sessionView:detail-panel-description-list')).toBeVisible();

// check list items are rendered
expect(renderResult.queryByText(TEST_FIRST_TITLE)).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const DetailPanelDescriptionList = ({ listItems }: DetailPanelDescription
css={styles.descriptionList}
titleProps={{ style: styles.tabListTitle }}
descriptionProps={{ style: styles.tabListDescription }}
data-test-subj="sessionViewer:detail-panel-description-list"
data-test-subj="sessionView:detail-panel-description-list"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('DetailPanelHostTab component', () => {

// expand host os accordion
renderResult
.queryByTestId('sessionViewer:detail-panel-accordion')
.queryByTestId('sessionView:detail-panel-accordion')
?.querySelector('button')
?.click();
expect(renderResult.queryByText('os.family')).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { DetailPanelListItem } from './index';
const TEST_STRING = 'item title';
const TEST_CHILD = <span>{TEST_STRING}</span>;
const TEST_COPY_STRING = 'test copy button';
const BUTTON_TEST_ID = 'test-copy-button';
const BUTTON_TEST_ID = 'sessionView:test-copy-button';
const TEST_COPY = <button data-test-subj={BUTTON_TEST_ID}>{TEST_COPY_STRING}</button>;
const LIST_ITEM_TEST_ID = 'sessionViewer:detail-panel-list-item';
const LIST_ITEM_TEST_ID = 'sessionView:detail-panel-list-item';
const WAIT_TIMEOUT = 500;

describe('DetailPanelListItem component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const DetailPanelListItem = ({
}

return (
<EuiText {...props} data-test-subj="sessionViewer:detail-panel-list-item">
<EuiText {...props} data-test-subj="sessionView:detail-panel-list-item">
{children}
{isHovered && copy}
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('ProcessTree component', () => {
onProcessSelected={jest.fn()}
/>
);
expect(renderResult.queryByTestId('sessionViewProcessTree')).toBeTruthy();
expect(renderResult.queryAllByTestId('processTreeNode')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:sessionViewProcessTree')).toBeTruthy();
expect(renderResult.queryAllByTestId('sessionView:processTreeNode')).toBeTruthy();
});

it('should insert a DOM element used to highlight a process when selectedProcess is set', () => {
Expand All @@ -55,6 +55,9 @@ describe('ProcessTree component', () => {
/>
);

// click on view more button
renderResult.getByTestId('sessionView:processTreeNodeChildProcessesButton').click();

expect(
renderResult
.queryByTestId('sessionView:processTreeSelectionArea')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export const ProcessTree = ({
}

return (
<div ref={scrollerRef} css={styles.scroller} data-test-subj="sessionViewProcessTree">
<div
ref={scrollerRef}
css={styles.scroller}
data-test-subj="sessionView:sessionViewProcessTree"
>
{hasPreviousPage &&
renderLoadMoreButton(
<FormattedMessage id="xpack.sessionView.loadPrevious" defaultMessage="Load previous" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ describe('ProcessTreeAlerts component', () => {
it('should return null if no alerts', async () => {
renderResult = mockedContext.render(<ProcessTreeAlerts alerts={[]} />);

expect(renderResult.queryByTestId('sessionViewAlertDetails')).toBeNull();
expect(renderResult.queryByTestId('sessionView:sessionViewAlertDetails')).toBeNull();
});

it('should return an array of alert details', async () => {
renderResult = mockedContext.render(<ProcessTreeAlerts alerts={mockAlerts} />);

expect(renderResult.queryByTestId('sessionViewAlertDetails')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:sessionViewAlertDetails')).toBeTruthy();
mockAlerts.forEach((alert) => {
if (!alert.kibana) {
return;
}
const { uuid, rule, original_event: event, workflow_status: status } = alert.kibana.alert;
const { name, query, severity } = rule;

expect(renderResult.queryByTestId(`sessionViewAlertDetail-${uuid}`)).toBeTruthy();
expect(renderResult.queryByTestId(`sessionViewAlertDetailViewRule-${uuid}`)).toBeTruthy();
expect(
renderResult.queryByTestId(`sessionView:sessionViewAlertDetail-${uuid}`)
).toBeTruthy();
expect(
renderResult.queryByTestId(`sessionView:sessionViewAlertDetailViewRule-${uuid}`)
).toBeTruthy();
expect(renderResult.queryAllByText(new RegExp(event.action, 'i')).length).toBeTruthy();
expect(renderResult.queryAllByText(new RegExp(status, 'i')).length).toBeTruthy();
expect(renderResult.queryAllByText(new RegExp(name, 'i')).length).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ProcessTreeAlerts({ alerts }: ProcessTreeAlertsDeps) {
const isLastAlert = index < alerts.length - 1;

return (
<EuiText key={uuid} size="s" data-test-subj={`sessionViewAlertDetail-${uuid}`}>
<EuiText key={uuid} size="s" data-test-subj={`sessionView:sessionViewAlertDetail-${uuid}`}>
<EuiFlexGroup>
<EuiFlexItem>
<h6>
Expand Down Expand Up @@ -81,7 +81,7 @@ export function ProcessTreeAlerts({ alerts }: ProcessTreeAlertsDeps) {
<EuiButton
size="s"
href={getRuleUrl(alert)}
data-test-subj={`sessionViewAlertDetailViewRule-${uuid}`}
data-test-subj={`sessionView:sessionViewAlertDetailViewRule-${uuid}`}
>
<FormattedMessage id="xpack.sessionView.viewRule" defaultMessage="View rule" />
</EuiButton>
Expand All @@ -98,7 +98,7 @@ export function ProcessTreeAlerts({ alerts }: ProcessTreeAlertsDeps) {
};

return (
<div css={styles.container} data-test-subj="sessionViewAlertDetails">
<div css={styles.container} data-test-subj="sessionView:sessionViewAlertDetails">
{alerts.map(renderAlertDetails)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('ProcessTreeNode component', () => {
it('should render given a valid process', async () => {
renderResult = mockedContext.render(<ProcessTreeNode process={processMock} />);

expect(renderResult.queryByTestId('processTreeNode')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:processTreeNode')).toBeTruthy();
});

it('should have an alternate rendering for a session leader', async () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={userEnteredProcessMock} />);

expect(renderResult.queryByTestId('processTreeNodeUserIcon')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:processTreeNodeUserIcon')).toBeTruthy();
});

it('renders Exec icon for executed process', async () => {
Expand All @@ -77,7 +77,7 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={executedProcessMock} />);

expect(renderResult.queryByTestId('processTreeNodeExecIcon')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:processTreeNodeExecIcon')).toBeTruthy();
});

it('renders Root Escalation flag properly', async () => {
Expand All @@ -104,7 +104,9 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={rootEscalationProcessMock} />);

expect(renderResult.queryByTestId('processTreeNodeRootEscalationFlag')).toBeTruthy();
expect(
renderResult.queryByTestId('sessionView:processTreeNodeRootEscalationFlag')
).toBeTruthy();
});

it('executes callback function when user Clicks', async () => {
Expand All @@ -114,7 +116,7 @@ describe('ProcessTreeNode component', () => {
<ProcessTreeNode process={processMock} onProcessSelected={onProcessSelected} />
);

userEvent.click(renderResult.getByTestId('processTreeNodeRow'));
userEvent.click(renderResult.getByTestId('sessionView:processTreeNodeRow'));
expect(onProcessSelected).toHaveBeenCalled();
});

Expand All @@ -130,7 +132,7 @@ describe('ProcessTreeNode component', () => {
// @ts-ignore
windowGetSelectionSpy.mockImplementation(() => ({ type: 'Range' }));

userEvent.click(renderResult.getByTestId('processTreeNodeRow'));
userEvent.click(renderResult.getByTestId('sessionView:processTreeNodeRow'));
expect(onProcessSelected).not.toHaveBeenCalled();

// cleanup
Expand All @@ -149,9 +151,9 @@ describe('ProcessTreeNode component', () => {
<ProcessTreeNode process={sessionViewAlertProcessMock} />
);
userEvent.click(renderResult.getByTestId('processTreeNodeAlertButton'));
expect(renderResult.queryByTestId('sessionViewAlertDetails')).toBeTruthy();
expect(renderResult.queryByTestId('sessionView:sessionViewAlertDetails')).toBeTruthy();
userEvent.click(renderResult.getByTestId('processTreeNodeAlertButton'));
expect(renderResult.queryByTestId('sessionViewAlertDetails')).toBeFalsy();
expect(renderResult.queryByTestId('sessionView:sessionViewAlertDetails')).toBeFalsy();
});
});
describe('Child processes', () => {
Expand All @@ -163,7 +165,9 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={processMockWithChildren} />);

expect(renderResult.queryByTestId('processTreeNodeChildProcessesButton')).toBeTruthy();
expect(
renderResult.queryByTestId('sessionView:processTreeNodeChildProcessesButton')
).toBeTruthy();
});
it('toggle Child processes nodes when Child processes button is clicked', async () => {
const processMockWithChildren: typeof processMock = {
Expand All @@ -173,13 +177,17 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={processMockWithChildren} />);

expect(renderResult.getAllByTestId('processTreeNode')).toHaveLength(1);
expect(renderResult.getAllByTestId('sessionView:processTreeNode')).toHaveLength(1);

userEvent.click(renderResult.getByTestId('processTreeNodeChildProcessesButton'));
expect(renderResult.getAllByTestId('processTreeNode')).toHaveLength(2);
userEvent.click(
renderResult.getByTestId('sessionView:processTreeNodeChildProcessesButton')
);
expect(renderResult.getAllByTestId('sessionView:processTreeNode')).toHaveLength(2);

userEvent.click(renderResult.getByTestId('processTreeNodeChildProcessesButton'));
expect(renderResult.getAllByTestId('processTreeNode')).toHaveLength(1);
userEvent.click(
renderResult.getByTestId('sessionView:processTreeNodeChildProcessesButton')
);
expect(renderResult.getAllByTestId('sessionView:processTreeNode')).toHaveLength(1);
});
});
describe('Search', () => {
Expand All @@ -189,9 +197,9 @@ describe('ProcessTreeNode component', () => {

renderResult = mockedContext.render(<ProcessTreeNode process={processMock} />);

expect(renderResult.getByTestId('processNodeSearchHighlight').textContent).toEqual(
'/vagrant'
);
expect(
renderResult.getByTestId('sessionView:processNodeSearchHighlight').textContent
).toEqual('/vagrant');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function ProcessTreeNode({

if (text) {
const html = text.replace(regex, (match) => {
return `<span data-test-subj="processNodeSearchHighlight" style="${styles.searchHighlight}">${match}</span>`;
return `<span data-test-subj="sessionView:processNodeSearchHighlight" style="${styles.searchHighlight}">${match}</span>`;
});

// eslint-disable-next-line no-unsanitized/property
Expand Down Expand Up @@ -131,7 +131,7 @@ export function ProcessTreeNode({
key="group-leaders-only-button"
css={styles.getButtonStyle(ButtonType.children)}
onClick={onShowGroupLeaderOnlyClick}
data-test-subj="processTreeNodeChildProcessesButton"
data-test-subj="sessionView:processTreeNodeChildProcessesButton"
>
<FormattedMessage
id="xpack.sessionView.plusCountMore"
Expand All @@ -155,7 +155,7 @@ export function ProcessTreeNode({
key="child-processes-button"
css={styles.getButtonStyle(ButtonType.children)}
onClick={() => setChildrenExpanded(!childrenExpanded)}
data-test-subj="processTreeNodeChildProcessesButton"
data-test-subj="sessionView:processTreeNodeChildProcessesButton"
>
<FormattedMessage
id="xpack.sessionView.childProcesses"
Expand Down Expand Up @@ -233,13 +233,13 @@ export function ProcessTreeNode({
<span>
{process.isUserEntered() && (
<EuiIcon
data-test-subj="processTreeNodeUserIcon"
data-test-subj="sessionView:processTreeNodeUserIcon"
css={styles.userEnteredIcon}
type="user"
/>
)}
{hasExec ? (
<EuiIcon data-test-subj="processTreeNodeExecIcon" type="console" />
<EuiIcon data-test-subj="sessionView:processTreeNodeExecIcon" type="console" />
) : (
<EuiIcon type="branch" />
)}
Expand All @@ -255,7 +255,7 @@ export function ProcessTreeNode({
if (user.name === 'root' && user.id !== parent.user.id) {
return (
<EuiButton
data-test-subj="processTreeNodeRootEscalationFlag"
data-test-subj="sessionView:processTreeNodeRootEscalationFlag"
css={styles.getButtonStyle(ButtonType.userChanged)}
>
<FormattedMessage
Expand Down Expand Up @@ -288,10 +288,14 @@ export function ProcessTreeNode({
data-id={id}
key={id + searchMatched}
css={styles.processNode}
data-test-subj="processTreeNode"
data-test-subj="sessionView:processTreeNode"
>
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
<div data-test-subj="processTreeNodeRow" css={styles.wrapper} onClick={onProcessClicked}>
<div
data-test-subj="sessionView:processTreeNodeRow"
css={styles.wrapper}
onClick={onProcessClicked}
>
{isSessionLeader ? renderSessionLeader() : renderProcess()}
{renderRootEscalation()}
{renderButtons()}
Expand Down
Loading

0 comments on commit 704b3eb

Please sign in to comment.