Skip to content

Commit

Permalink
improve test resiliance
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Sep 23, 2020
1 parent 895e87b commit abb4a0c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,40 @@ When(/^the user filters by "([^"]*)"$/, (filterName) => {
cy.get('.euiStat__title-isLoading').should('not.be.visible');
cy.get(`#local-filter-${filterName}`).click();

if (filterName === 'os') {
cy.get('span.euiSelectableListItem__text', DEFAULT_TIMEOUT)
.contains('Mac OS X')
.click();
} else {
cy.get('span.euiSelectableListItem__text', DEFAULT_TIMEOUT)
.contains('DE')
.click();
}
cy.get('[data-cy=applyFilter]').click();
cy.get(`#local-filter-popover-${filterName}`, DEFAULT_TIMEOUT).within(() => {
if (filterName === 'os') {
const osItem = cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(2);
osItem.should('have.text', 'Mac OS X8 ');
osItem.click();

// sometimes click doesn't work as expected so we need to retry here
osItem.invoke('attr', 'aria-selected').then((val) => {
if (val === 'false') {
cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(2).click();
}
});
} else {
const deItem = cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(0);
deItem.should('have.text', 'DE28 ');
deItem.click();

// sometimes click doesn't work as expected so we need to retry here
deItem.invoke('attr', 'aria-selected').then((val) => {
if (val === 'false') {
cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(0).click();
}
});
}
cy.get('[data-cy=applyFilter]').click();
});

cy.get(`div#local-filter-values-${filterName}`, DEFAULT_TIMEOUT).within(
() => {
cy.get('span.euiBadge__content')
.eq(0)
.should('have.text', filterName === 'os' ? 'Mac OS X' : 'DE');
}
);
});

Then(/^it filters the client metrics "([^"]*)"$/, (filterName) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
*/

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from '../apm';
import { verifyClientMetrics } from './client_metrics_helper';
import { DEFAULT_TIMEOUT } from './csm_dashboard';

When('the user changes the selected service name', (filterName) => {
When('the user changes the selected service name', () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
cy.get(`[data-cy=serviceNameFilter]`, { timeout: DEFAULT_TIMEOUT }).select(
'client'
);
cy.get(`[data-cy=serviceNameFilter]`, DEFAULT_TIMEOUT).select('client');
});

Then(`it displays relevant client metrics`, () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/e2e/ingest-data/replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function setRumAgent(item) {
if (item.body) {
item.body = item.body.replace(
'"name":"client"',
'"name":"opbean-client-rum"'
'"name":"elastic-frontend"'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ const BadgeText = styled.div`
interface Props {
value: string[];
onRemove: (val: string) => void;
name: string;
}

const removeFilterLabel = i18n.translate(
'xpack.apm.uifilter.badge.removeFilter',
{ defaultMessage: 'Remove filter' }
);

function FilterBadgeList({ onRemove, value }: Props) {
function FilterBadgeList({ onRemove, value, name }: Props) {
return (
<EuiFlexGrid gutterSize="s">
<EuiFlexGrid gutterSize="s" id={`local-filter-values-${name}`}>
{value.map((val) => (
<EuiFlexItem key={val} grow={false}>
<EuiBadge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function Filter({ name, title, options, onChange, value, showCount }: Props) {
searchable={true}
>
{(list, search) => (
<SelectContainer>
<SelectContainer id={`local-filter-popover-${name}`}>
<EuiFlexGroup direction="column" gutterSize="none">
<FlexItem grow={true}>
<EuiTitle size="xxxs" textTransform="uppercase">
Expand Down Expand Up @@ -159,6 +159,7 @@ function Filter({ name, title, options, onChange, value, showCount }: Props) {
{value.length ? (
<>
<FilterBadgeList
name={name}
onRemove={(val) => {
onChange(value.filter((v) => val !== v));
}}
Expand Down

0 comments on commit abb4a0c

Please sign in to comment.