Skip to content

Commit abb4a0c

Browse files
committed
improve test resiliance
1 parent 895e87b commit abb4a0c

File tree

5 files changed

+43
-19
lines changed

5 files changed

+43
-19
lines changed

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/csm_filters.ts

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,40 @@ When(/^the user filters by "([^"]*)"$/, (filterName) => {
1414
cy.get('.euiStat__title-isLoading').should('not.be.visible');
1515
cy.get(`#local-filter-${filterName}`).click();
1616

17-
if (filterName === 'os') {
18-
cy.get('span.euiSelectableListItem__text', DEFAULT_TIMEOUT)
19-
.contains('Mac OS X')
20-
.click();
21-
} else {
22-
cy.get('span.euiSelectableListItem__text', DEFAULT_TIMEOUT)
23-
.contains('DE')
24-
.click();
25-
}
26-
cy.get('[data-cy=applyFilter]').click();
17+
cy.get(`#local-filter-popover-${filterName}`, DEFAULT_TIMEOUT).within(() => {
18+
if (filterName === 'os') {
19+
const osItem = cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(2);
20+
osItem.should('have.text', 'Mac OS X8 ');
21+
osItem.click();
22+
23+
// sometimes click doesn't work as expected so we need to retry here
24+
osItem.invoke('attr', 'aria-selected').then((val) => {
25+
if (val === 'false') {
26+
cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(2).click();
27+
}
28+
});
29+
} else {
30+
const deItem = cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(0);
31+
deItem.should('have.text', 'DE28 ');
32+
deItem.click();
33+
34+
// sometimes click doesn't work as expected so we need to retry here
35+
deItem.invoke('attr', 'aria-selected').then((val) => {
36+
if (val === 'false') {
37+
cy.get('li.euiSelectableListItem', DEFAULT_TIMEOUT).eq(0).click();
38+
}
39+
});
40+
}
41+
cy.get('[data-cy=applyFilter]').click();
42+
});
43+
44+
cy.get(`div#local-filter-values-${filterName}`, DEFAULT_TIMEOUT).within(
45+
() => {
46+
cy.get('span.euiBadge__content')
47+
.eq(0)
48+
.should('have.text', filterName === 'os' ? 'Mac OS X' : 'DE');
49+
}
50+
);
2751
});
2852

2953
Then(/^it filters the client metrics "([^"]*)"$/, (filterName) => {

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/service_name_filter.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
*/
66

77
import { When, Then } from 'cypress-cucumber-preprocessor/steps';
8-
import { DEFAULT_TIMEOUT } from '../apm';
98
import { verifyClientMetrics } from './client_metrics_helper';
9+
import { DEFAULT_TIMEOUT } from './csm_dashboard';
1010

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

1917
Then(`it displays relevant client metrics`, () => {

x-pack/plugins/apm/e2e/ingest-data/replay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function setRumAgent(item) {
9696
if (item.body) {
9797
item.body = item.body.replace(
9898
'"name":"client"',
99-
'"name":"opbean-client-rum"'
99+
'"name":"elastic-frontend"'
100100
);
101101
}
102102
}

x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/FilterBadgeList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ const BadgeText = styled.div`
1919
interface Props {
2020
value: string[];
2121
onRemove: (val: string) => void;
22+
name: string;
2223
}
2324

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

29-
function FilterBadgeList({ onRemove, value }: Props) {
30+
function FilterBadgeList({ onRemove, value, name }: Props) {
3031
return (
31-
<EuiFlexGrid gutterSize="s">
32+
<EuiFlexGrid gutterSize="s" id={`local-filter-values-${name}`}>
3233
{value.map((val) => (
3334
<EuiFlexItem key={val} grow={false}>
3435
<EuiBadge

x-pack/plugins/apm/public/components/shared/LocalUIFilters/Filter/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function Filter({ name, title, options, onChange, value, showCount }: Props) {
113113
searchable={true}
114114
>
115115
{(list, search) => (
116-
<SelectContainer>
116+
<SelectContainer id={`local-filter-popover-${name}`}>
117117
<EuiFlexGroup direction="column" gutterSize="none">
118118
<FlexItem grow={true}>
119119
<EuiTitle size="xxxs" textTransform="uppercase">
@@ -159,6 +159,7 @@ function Filter({ name, title, options, onChange, value, showCount }: Props) {
159159
{value.length ? (
160160
<>
161161
<FilterBadgeList
162+
name={name}
162163
onRemove={(val) => {
163164
onChange(value.filter((v) => val !== v));
164165
}}

0 commit comments

Comments
 (0)