Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uptime] Expand synthetic journey step thumbnail on hover #89179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { PingTimestamp } from './ping_timestamp';
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { fireEvent, waitFor } from '@testing-library/react';
import React from 'react';
import { render } from '../../../../../lib/helper/rtl_helpers';
import { NavButtons, NavButtonsProps } from './nav_buttons';

describe('NavButtons', () => {
let defaultProps: NavButtonsProps;

beforeEach(() => {
defaultProps = {
maxSteps: 3,
stepNumber: 2,
setStepNumber: jest.fn(),
setIsImagePopoverOpen: jest.fn(),
};
});

it('labels prev and next buttons', () => {
const { getByLabelText } = render(<NavButtons {...defaultProps} />);

expect(getByLabelText('Previous step'));
expect(getByLabelText('Next step'));
});

it('increments step number on next click', async () => {
const { getByLabelText } = render(<NavButtons {...defaultProps} />);

const nextButton = getByLabelText('Next step');

fireEvent.click(nextButton);

await waitFor(() => {
expect(defaultProps.setStepNumber).toHaveBeenCalledTimes(1);
expect(defaultProps.setStepNumber).toHaveBeenCalledWith(3);
});
});

it('decrements step number on prev click', async () => {
const { getByLabelText } = render(<NavButtons {...defaultProps} />);

const nextButton = getByLabelText('Previous step');

fireEvent.click(nextButton);

await waitFor(() => {
expect(defaultProps.setStepNumber).toHaveBeenCalledTimes(1);
expect(defaultProps.setStepNumber).toHaveBeenCalledWith(1);
});
});

it('disables `next` button on final step', () => {
defaultProps.stepNumber = 3;

const { getByLabelText } = render(<NavButtons {...defaultProps} />);

// getByLabelText('Next step');
expect(getByLabelText('Next step')).toHaveAttribute('disabled');
expect(getByLabelText('Previous step')).not.toHaveAttribute('disabled');
});

it('disables `prev` button on final step', () => {
defaultProps.stepNumber = 1;

const { getByLabelText } = render(<NavButtons {...defaultProps} />);

expect(getByLabelText('Next step')).not.toHaveAttribute('disabled');
expect(getByLabelText('Previous step')).toHaveAttribute('disabled');
});

it('opens popover when mouse enters', async () => {
const { getByLabelText } = render(<NavButtons {...defaultProps} />);

const nextButton = getByLabelText('Next step');

fireEvent.mouseEnter(nextButton);

await waitFor(() => {
expect(defaultProps.setIsImagePopoverOpen).toHaveBeenCalledTimes(1);
expect(defaultProps.setIsImagePopoverOpen).toHaveBeenCalledWith(true);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiButtonIcon, EuiFlexItem, EuiFlexGroup } from '@elastic/eui';
import React from 'react';
import { nextAriaLabel, prevAriaLabel } from './translations';

export interface NavButtonsProps {
maxSteps?: number;
setIsImagePopoverOpen: React.Dispatch<React.SetStateAction<boolean>>;
setStepNumber: React.Dispatch<React.SetStateAction<number>>;
stepNumber: number;
}

export const NavButtons: React.FC<NavButtonsProps> = ({
maxSteps,
setIsImagePopoverOpen,
setStepNumber,
stepNumber,
}) => (
<EuiFlexGroup
className="stepArrows"
gutterSize="s"
alignItems="center"
onMouseEnter={() => setIsImagePopoverOpen(true)}
style={{ position: 'absolute', bottom: 0, left: 30 }}
>
<EuiFlexItem grow={false}>
<EuiButtonIcon
disabled={stepNumber === 1}
color="subdued"
size="s"
onClick={() => {
setStepNumber(stepNumber - 1);
}}
iconType="arrowLeft"
aria-label={prevAriaLabel}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
disabled={stepNumber === maxSteps}
color="subdued"
size="s"
onClick={() => {
setStepNumber(stepNumber + 1);
}}
iconType="arrowRight"
aria-label={nextAriaLabel}
/>
</EuiFlexItem>
</EuiFlexGroup>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { render } from '../../../../../lib/helper/rtl_helpers';
import { NoImageAvailable } from './no_image_available';

describe('NoImageAvailable', () => {
it('renders expected text', () => {
const { getByText } = render(<NoImageAvailable />);

expect(getByText('No image available'));
});
});
Loading