-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from nearform/issue-23-tooltips
feat: add tooltip scenario
- Loading branch information
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Delete } from '@mui/icons-material' | ||
import { | ||
Button, | ||
IconButton, | ||
Link, | ||
Stack, | ||
Tooltip, | ||
Typography | ||
} from '@mui/material' | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import Layout from '../components/Layout' | ||
import PageSetup from '../components/PageSetup' | ||
|
||
const TooltipPage = (): JSX.Element => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<Layout> | ||
<PageSetup | ||
title={t('scenarios.tooltip-page.title')} | ||
description={t('scenarios.tooltip-page.description')} | ||
information={t('scenarios.tooltip-page.information')} | ||
/> | ||
<Stack | ||
direction='column' | ||
justifyContent='center' | ||
alignItems='center' | ||
spacing={6} | ||
> | ||
<Tooltip | ||
title={t('scenarios.tooltip-page.no-permission')} | ||
arrow | ||
placement='right' | ||
> | ||
<span data-testid='delete-button'> | ||
<IconButton disabled> | ||
<Delete /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
|
||
<Tooltip | ||
arrow | ||
placement='right' | ||
title={ | ||
<> | ||
{t('scenarios.tooltip-page.more-information-msg')}{' '} | ||
<Link | ||
color='inherit' | ||
href='https://github.com/nearform/testing-playground' | ||
> | ||
{'Testing Playground'} | ||
</Link> | ||
</> | ||
} | ||
> | ||
<Button variant='outlined' data-testid='more-info-button'> | ||
{t('scenarios.tooltip-page.more-information')} | ||
</Button> | ||
</Tooltip> | ||
|
||
<Tooltip | ||
title={t('scenarios.tooltip-page.really-long-text')} | ||
arrow | ||
placement='right' | ||
sx={{ width: '10rem' }} | ||
> | ||
<Typography noWrap data-testid='text'> | ||
{t('scenarios.tooltip-page.really-long-text')} | ||
</Typography> | ||
</Tooltip> | ||
</Stack> | ||
</Layout> | ||
) | ||
} | ||
|
||
export default TooltipPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { screen, waitFor } from '@testing-library/react' | ||
import userEvent from '@testing-library/user-event' | ||
import React from 'react' | ||
import { beforeEach, describe, expect, it } from 'vitest' | ||
|
||
import TestRenderer from './TestRenderer' | ||
import TooltipPage from '../scenarios/Tooltip.scenario' | ||
|
||
describe('CheckBox component', () => { | ||
beforeEach(() => { | ||
sessionStorage.clear() | ||
}) | ||
|
||
it('renders tooltip when hovering disabled button', async () => { | ||
TestRenderer(<TooltipPage />) | ||
await userEvent.hover(screen.getByTestId('delete-button')) | ||
await waitFor(() => { | ||
expect(screen.getByRole('tooltip')).toBeVisible() | ||
}) | ||
}) | ||
|
||
it('renders tooltip when hovering active button', async () => { | ||
TestRenderer(<TooltipPage />) | ||
await userEvent.hover(screen.getByTestId('more-info-button')) | ||
await waitFor(() => { | ||
expect(screen.getByRole('tooltip')).toBeVisible() | ||
}) | ||
}) | ||
|
||
it('renders tooltip when hovering truncated text', async () => { | ||
TestRenderer(<TooltipPage />) | ||
await userEvent.hover(screen.getByTestId('text')) | ||
await waitFor(() => { | ||
expect(screen.getByRole('tooltip')).toBeVisible() | ||
}) | ||
}) | ||
}) |