Skip to content

Commit

Permalink
[Security Solution] Unskip cypress tests (#86653) (#87768)
Browse files Browse the repository at this point in the history
* unskip data provider cypress test

* remove extra whitespace for filter classes

* remove cy.wait

* update functional test

* fix cypress and add tabType to dataTestSubj

* fix cypress test

* revert createNewTimeline task

* fix dependency

* fix line error

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
angorayc and kibanamachine authored Jan 8, 2021
1 parent 2362ddd commit aa1412d
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 25 deletions.
9 changes: 8 additions & 1 deletion src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@ export function FilterItem(props: Props) {
const dataTestSubjNegated = filter.meta.negate ? 'filter-negated' : '';
const dataTestSubjDisabled = `filter-${isDisabled(labelConfig) ? 'disabled' : 'enabled'}`;
const dataTestSubjPinned = `filter-${isFilterPinned(filter) ? 'pinned' : 'unpinned'}`;
return `filter ${dataTestSubjDisabled} ${dataTestSubjKey} ${dataTestSubjValue} ${dataTestSubjPinned} ${dataTestSubjNegated}`;
return classNames(
'filter',
dataTestSubjDisabled,
dataTestSubjKey,
dataTestSubjValue,
dataTestSubjPinned,
dataTestSubjNegated
);
}

function getPanels() {
Expand Down
10 changes: 9 additions & 1 deletion test/functional/services/filter_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import classNames from 'classnames';
import { FtrProviderContext } from '../ftr_provider_context';

export function FilterBarProvider({ getService, getPageObjects }: FtrProviderContext) {
Expand Down Expand Up @@ -45,7 +46,14 @@ export function FilterBarProvider({ getService, getPageObjects }: FtrProviderCon
const filterPinnedState = pinned ? 'pinned' : 'unpinned';
const filterNegatedState = negated ? 'filter-negated' : '';
return testSubjects.exists(
`filter filter-${filterActivationState} filter-key-${key} filter-value-${value} filter-${filterPinnedState} ${filterNegatedState}`,
classNames(
'filter',
`filter-${filterActivationState}`,
key !== '' && `filter-key-${key}`,
value !== '' && `filter-value-${value}`,
`filter-${filterPinnedState}`,
filterNegatedState
),
{
allowHidden: true,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import { closeTimeline, createNewTimeline } from '../tasks/timeline';
import { HOSTS_URL } from '../urls/navigation';
import { cleanKibana } from '../tasks/common';

// FLAKY: https://github.com/elastic/kibana/issues/85098
// FLAKY: https://github.com/elastic/kibana/issues/62060
describe.skip('timeline data providers', () => {
describe('timeline data providers', () => {
before(() => {
cleanKibana();
loginAndWaitForPage(HOSTS_URL);
Expand Down
22 changes: 16 additions & 6 deletions x-pack/plugins/security_solution/cypress/screens/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ export const SAVE_FILTER_BTN = '[data-test-subj="saveFilter"]';
export const SEARCH_OR_FILTER_CONTAINER =
'[data-test-subj="timeline-search-or-filter-search-container"]';

export const QUERY_TAB_EVENTS_TABLE = '[data-test-subj="query-events-table"]';

export const QUERY_TAB_EVENTS_BODY = '[data-test-subj="query-tab-flyout-body"]';

export const QUERY_TAB_EVENTS_FOOTER = '[data-test-subj="query-tab-flyout-footer"]';

export const PINNED_TAB_EVENTS_TABLE = '[data-test-subj="pinned-events-table"]';

export const PINNED_TAB_EVENTS_BODY = '[data-test-subj="pinned-tab-flyout-body"]';

export const PINNED_TAB_EVENTS_FOOTER = '[data-test-subj="pinned-tab-flyout-footer"]';

export const SERVER_SIDE_EVENT_COUNT = '[data-test-subj="server-side-event-count"]';

export const STAR_ICON = '[data-test-subj="timeline-favorite-empty-star"]';
Expand All @@ -111,10 +123,8 @@ export const TIMELINE_DROPPED_DATA_PROVIDERS = '[data-test-subj="providerContain
export const TIMELINE_FIELDS_BUTTON =
'[data-test-subj="timeline"] [data-test-subj="show-field-browser"]';

export const TIMELINE_FILTER = (filter: TimelineFilter) => {
// The space at the end of the line is required. We want to keep it until it is updated.
return `[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned "]`;
};
export const TIMELINE_FILTER = (filter: TimelineFilter) =>
`[data-test-subj="filter filter-enabled filter-key-${filter.field} filter-value-${filter.value} filter-unpinned"]`;

export const TIMELINE_FILTER_FIELD = '[data-test-subj="filterFieldSuggestionList"]';

Expand All @@ -127,9 +137,9 @@ export const TIMELINE_FILTER_VALUE =

export const TIMELINE_FLYOUT = '[data-test-subj="eui-flyout"]';

export const TIMELINE_FLYOUT_HEADER = '[data-test-subj="eui-flyout-header"]';
export const TIMELINE_FLYOUT_HEADER = '[data-test-subj="query-tab-flyout-header"]';

export const TIMELINE_FLYOUT_BODY = '[data-test-subj="eui-flyout-body"]';
export const TIMELINE_FLYOUT_BODY = '[data-test-subj="query-tab-flyout-body"]';

export const TIMELINE_INSPECT_BUTTON = `${TIMELINE_FLYOUT} [data-test-subj="inspect-icon-button"]`;

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export const closeTimeline = () => {

export const createNewTimeline = () => {
cy.get(TIMELINE_SETTINGS_ICON).filter(':visible').click({ force: true });
cy.wait(1000);
cy.get(CREATE_NEW_TIMELINE).should('be.visible');
cy.get(CREATE_NEW_TIMELINE).click();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
<EventsTable
$activePage={activePage}
$columnCount={columnHeaders.length + 1}
data-test-subj="events-table"
data-test-subj={`${tabType}-events-table`}
columnWidths={columnWidths}
onKeyDown={onKeyDown}
$rowCount={data.length}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TestProviders } from '../../../../common/mock/test_providers';

import { Sort } from '../body/sort';
import { useMountAppended } from '../../../../common/utils/use_mount_appended';
import { TimelineId } from '../../../../../common/types/timeline';
import { TimelineId, TimelineTabs } from '../../../../../common/types/timeline';
import { useTimelineEvents } from '../../../containers/index';
import { useTimelineEventsDetails } from '../../../containers/details/index';
import { useSourcererScope } from '../../../../common/containers/sourcerer';
Expand Down Expand Up @@ -117,7 +117,9 @@ describe('PinnedTabContent', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true);
expect(
wrapper.find(`[data-test-subj="${TimelineTabs.pinned}-events-table"]`).exists()
).toEqual(true);
});

it('it shows the timeline footer', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ export const PinnedTabContentComponent: React.FC<Props> = ({

return (
<>
<FullWidthFlexGroup>
<FullWidthFlexGroup data-test-subj={`${TimelineTabs.pinned}-tab`}>
<ScrollableFlexItem grow={2}>
<EventDetailsWidthProvider>
<StyledEuiFlyoutBody data-test-subj="eui-flyout-body" className="timeline-flyout-body">
<StyledEuiFlyoutBody
data-test-subj={`${TimelineTabs.pinned}-tab-flyout-body`}
className="timeline-flyout-body"
>
<StatefulBody
activePage={pageInfo.activePage}
browserFields={browserFields}
Expand All @@ -192,7 +195,7 @@ export const PinnedTabContentComponent: React.FC<Props> = ({
/>
</StyledEuiFlyoutBody>
<StyledEuiFlyoutFooter
data-test-subj="eui-flyout-footer"
data-test-subj={`${TimelineTabs.pinned}-tab-flyout-footer`}
className="timeline-flyout-footer"
>
<Footer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ describe('Timeline', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true);
expect(
wrapper.find(`[data-test-subj="${TimelineTabs.query}-events-table"]`).exists()
).toEqual(true);
});

test('it does render the timeline table when the source is loading with no events', () => {
Expand All @@ -161,7 +163,9 @@ describe('Timeline', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true);
expect(
wrapper.find(`[data-test-subj="${TimelineTabs.query}-events-table"]`).exists()
).toEqual(true);
expect(wrapper.find('[data-test-subj="events"]').exists()).toEqual(false);
});

Expand All @@ -172,7 +176,9 @@ describe('Timeline', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true);
expect(
wrapper.find(`[data-test-subj="${TimelineTabs.query}-events-table"]`).exists()
).toEqual(true);
expect(wrapper.find('[data-test-subj="events"]').exists()).toEqual(false);
});

Expand All @@ -183,7 +189,9 @@ describe('Timeline', () => {
</TestProviders>
);

expect(wrapper.find('[data-test-subj="events-table"]').exists()).toEqual(true);
expect(
wrapper.find(`[data-test-subj="${TimelineTabs.query}-events-table"]`).exists()
).toEqual(true);
expect(wrapper.find('[data-test-subj="events"]').exists()).toEqual(false);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,10 @@ export const QueryTabContentComponent: React.FC<Props> = ({
<FullWidthFlexGroup>
<ScrollableFlexItem grow={2}>
<HideShowContainer $isVisible={!timelineFullScreen}>
<StyledEuiFlyoutHeader data-test-subj="eui-flyout-header" hasBorder={false}>
<StyledEuiFlyoutHeader
data-test-subj={`${activeTab}-tab-flyout-header`}
hasBorder={false}
>
<EuiFlexGroup gutterSize="s" data-test-subj="timeline-date-picker-container">
<DatePicker grow={1}>
<SuperDatePicker id="timeline" timelineId={timelineId} />
Expand Down Expand Up @@ -303,7 +306,10 @@ export const QueryTabContentComponent: React.FC<Props> = ({
</HideShowContainer>

<EventDetailsWidthProvider>
<StyledEuiFlyoutBody data-test-subj="eui-flyout-body" className="timeline-flyout-body">
<StyledEuiFlyoutBody
data-test-subj={`${TimelineTabs.query}-tab-flyout-body`}
className="timeline-flyout-body"
>
<StatefulBody
activePage={pageInfo.activePage}
browserFields={browserFields}
Expand All @@ -320,7 +326,7 @@ export const QueryTabContentComponent: React.FC<Props> = ({
</StyledEuiFlyoutBody>

<StyledEuiFlyoutFooter
data-test-subj="eui-flyout-footer"
data-test-subj={`${TimelineTabs.query}-tab-flyout-footer`}
className="timeline-flyout-footer"
>
{!isBlankTimeline && (
Expand Down

0 comments on commit aa1412d

Please sign in to comment.