Skip to content

Commit

Permalink
chore: increase show tooltip delay to 1 second (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloomca authored Dec 12, 2023
1 parent aabf4bd commit 0991d82
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Reactist follows [semantic versioning](https://semver.org/) and doesn't introduce breaking changes (API-wise) in minor or patch releases. However, the appearance of a component might change in a minor or patch release so keep an eye on redesigns and make sure your app still looks and feels like you expect it.

# v22.3.1

- [Tweak] Increase showing tooltip delay to 1 second from 500ms

# v22.3.0

- [Build] Add support for Node v21
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"email": "[email protected]",
"url": "http://doist.com"
},
"version": "22.3.0",
"version": "22.3.1",
"license": "MIT",
"homepage": "https://github.com/Doist/reactist#readme",
"repository": {
Expand Down
48 changes: 34 additions & 14 deletions src/components/time/time.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { axe } from 'jest-axe'
import { Time } from './time'
import userEvent from '@testing-library/user-event'

import { SHOW_DELAY } from '../../tooltip/tooltip'

describe('Time', () => {
beforeAll(() => {
jest.useFakeTimers()
Expand Down Expand Up @@ -70,9 +72,14 @@ describe('Time', () => {
render(<Time time={testDate} tooltipOnHover />)

userEvent.hover(screen.getByText('March 22, 1991'))
await waitFor(() => {
expect(screen.getByRole('tooltip', { name: 'March 22, 1991, 1:37 PM' })).toBeVisible()
})
await waitFor(
() => {
expect(
screen.getByRole('tooltip', { name: 'March 22, 1991, 1:37 PM' }),
).toBeVisible()
},
{ timeout: SHOW_DELAY + 10 },
)

userEvent.unhover(screen.getByText('March 22, 1991'))
await waitFor(() => {
Expand All @@ -84,9 +91,12 @@ describe('Time', () => {
render(<Time time={testDate} tooltipOnHover tooltip="Test" />)

userEvent.hover(screen.getByText('March 22, 1991'))
await waitFor(() => {
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeVisible()
})
await waitFor(
() => {
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeVisible()
},
{ timeout: SHOW_DELAY + 10 },
)

userEvent.unhover(screen.getByText('March 22, 1991'))
await waitFor(() => {
Expand All @@ -98,10 +108,15 @@ describe('Time', () => {
render(<Time time={dayjs().unix()} tooltipOnHover expandOnHover />)
userEvent.hover(screen.getByText('moments ago'))

await waitFor(() => {
expect(screen.getByRole('tooltip', { name: dayjs().format('LL, LT') })).toBeVisible()
expect(screen.getByText('moments ago')).toBeVisible()
})
await waitFor(
() => {
expect(
screen.getByRole('tooltip', { name: dayjs().format('LL, LT') }),
).toBeVisible()
expect(screen.getByText('moments ago')).toBeVisible()
},
{ timeout: SHOW_DELAY + 10 },
)

userEvent.unhover(screen.getByText('moments ago'))
await waitFor(() => {
Expand All @@ -113,10 +128,15 @@ describe('Time', () => {
render(<Time time={dayjs().unix()} tooltipOnHover expandFullyOnHover />)
userEvent.hover(screen.getByText('moments ago'))

await waitFor(() => {
expect(screen.getByRole('tooltip', { name: dayjs().format('LL, LT') })).toBeVisible()
expect(screen.getByText('moments ago')).toBeVisible()
})
await waitFor(
() => {
expect(
screen.getByRole('tooltip', { name: dayjs().format('LL, LT') }),
).toBeVisible()
expect(screen.getByText('moments ago')).toBeVisible()
},
{ timeout: SHOW_DELAY + 10 },
)

userEvent.unhover(screen.getByText('moments ago'))
await waitFor(() => {
Expand Down
15 changes: 11 additions & 4 deletions src/tooltip/tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,12 @@ describe('Tooltip', () => {
const button = screen.getByRole('button', { name: 'Click me' })
userEvent.tab()

await waitFor(() => {
expect(button).toHaveAccessibleDescription('tooltip content here')
})
await waitFor(
() => {
expect(button).toHaveAccessibleDescription('tooltip content here')
},
{ timeout: SHOW_DELAY + 10 },
)
})

it('does not acknowledge the className prop, but exceptionallySetClassName instead', async () => {
Expand All @@ -267,7 +270,11 @@ describe('Tooltip', () => {
// available when we hover or focus the button, and not before.
userEvent.tab()

const tooltip = await screen.findByRole('tooltip', { name: 'I’m a tooltip' })
const tooltip = await screen.findByRole(
'tooltip',
{ name: 'I’m a tooltip' },
{ timeout: SHOW_DELAY + 10 },
)
expect(tooltip).toHaveClass('right')
expect(tooltip).not.toHaveClass('wrong')
})
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type TooltipProps = {
}

// These are exported to be used in the tests, they are not meant to be exported publicly
export const SHOW_DELAY = 500
export const SHOW_DELAY = 1000
export const HIDE_DELAY = 100

function useDelayedTooltipState(initialState: AriakitTooltipStateProps) {
Expand Down

0 comments on commit 0991d82

Please sign in to comment.