Skip to content

Commit

Permalink
[Security Solution][Data Quality Dashboard] fix tests and potential t…
Browse files Browse the repository at this point in the history
…ests timing out on ci (elastic#196591)

addresses elastic#196216

Removing accessibility selectors to ensure 10x speed of tests with
data-test-subj locators.

(cherry picked from commit b5a705e)
  • Loading branch information
kapral18 committed Nov 18, 2024
1 parent 256ffda commit 4f2c818
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,20 @@ describe('IndicesDetails', () => {
describe('tour', () => {
test('it renders the tour wrapping view history button of first row of first non-empty pattern', async () => {
const wrapper = await screen.findByTestId('historicalResultsTour');
const button = within(wrapper).getByRole('button', { name: 'View history' });
expect(button).toBeInTheDocument();
const button = within(wrapper).getByTestId(
'viewHistoryAction-.internal.alerts-security.alerts-default-000001'
);
expect(button).toHaveAttribute('data-tour-element', patterns[1]);

expect(
screen.getByRole('dialog', { name: 'Introducing data quality history' })
).toBeInTheDocument();
expect(screen.getByTestId('historicalResultsTourPanel')).toHaveTextContent(
'Introducing data quality history'
);
});

describe('when the tour is dismissed', () => {
test('it hides the tour and persists in localStorage', async () => {
const wrapper = await screen.findByRole('dialog', {
name: 'Introducing data quality history',
});

const button = within(wrapper).getByRole('button', { name: 'Close' });

const wrapper = screen.getByTestId('historicalResultsTourPanel');
const button = within(wrapper).getByText('Close');
await userEvent.click(button);

await waitFor(() => expect(screen.queryByTestId('historicalResultsTour')).toBeNull());
Expand All @@ -127,24 +124,22 @@ describe('IndicesDetails', () => {
const firstNonEmptyPatternAccordionWrapper = await screen.findByTestId(
`${patterns[1]}PatternPanel`
);
const accordionToggle = within(firstNonEmptyPatternAccordionWrapper).getByRole('button', {
name: /Pass/,
});
const accordionToggle = within(firstNonEmptyPatternAccordionWrapper).getByTestId(
'indexResultBadge'
);
await userEvent.click(accordionToggle);

const secondPatternAccordionWrapper = screen.getByTestId(`${patterns[2]}PatternPanel`);
const historicalResultsWrapper = await within(secondPatternAccordionWrapper).findByTestId(
'historicalResultsTour'
);
const button = within(historicalResultsWrapper).getByRole('button', {
name: 'View history',
});
const button = within(historicalResultsWrapper).getByTestId(
`viewHistoryAction-${patternIndexNames[patterns[2]][0]}`
);
expect(button).toHaveAttribute('data-tour-element', patterns[2]);

expect(
screen.getByRole('dialog', { name: 'Introducing data quality history' })
).toBeInTheDocument();
}, 10000);
expect(screen.getByTestId('historicalResultsTourPanel')).toBeInTheDocument();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const HistoricalResultsTour: FC<Props> = ({
repositionOnScroll
anchor={anchorElement}
zIndex={zIndex}
panelProps={{
'data-test-subj': 'historicalResultsTourPanel',
}}
footerAction={[
<EuiButtonEmpty size="xs" color="text" onClick={onDismissTour}>
{CLOSE}
Expand Down
Loading

0 comments on commit 4f2c818

Please sign in to comment.