forked from mattermost/mattermost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-58402] Migrate tooltips of 'components/emoji_picker_skin.tsx' & '…
…components/emoji_picker_category' to WithTooltip (mattermost#27146)
- Loading branch information
1 parent
76774e6
commit 11c2951
Showing
5 changed files
with
92 additions
and
40 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
.../src/components/emoji_picker/components/__snapshots__/emoji_picker_category.test.tsx.snap
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,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EmojiPickerCategory should match snapshot 1`] = ` | ||
<DocumentFragment> | ||
<a | ||
aria-label="categoryId" | ||
class="emoji-picker__category" | ||
href="#" | ||
> | ||
<i | ||
class="categoryClass" | ||
/> | ||
</a> | ||
</DocumentFragment> | ||
`; |
58 changes: 58 additions & 0 deletions
58
webapp/channels/src/components/emoji_picker/components/emoji_picker_category.test.tsx
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,58 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {act, screen} from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import type {Category} from 'components/emoji_picker/types'; | ||
|
||
import {renderWithContext, userEvent} from 'tests/react_testing_utils'; | ||
|
||
import EmojiPickerCategory from './emoji_picker_category'; | ||
import type {Props} from './emoji_picker_category'; | ||
|
||
const categoryMessage = 'categoryMessage'; | ||
const defaultProps: Props = { | ||
category: { | ||
className: 'categoryClass', | ||
emojiIds: ['emojiId'], | ||
id: 'categoryId', | ||
message: categoryMessage, | ||
name: 'recent', | ||
} as Category, | ||
categoryRowIndex: 0, | ||
selected: false, | ||
enable: true, | ||
onClick: jest.fn(), | ||
}; | ||
|
||
describe('EmojiPickerCategory', () => { | ||
test('should match snapshot', () => { | ||
const {asFragment} = renderWithContext(<EmojiPickerCategory {...defaultProps}/>); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
test('should be disabled when prop is passed disabled', () => { | ||
const props = { | ||
...defaultProps, | ||
enable: false, | ||
}; | ||
|
||
renderWithContext(<EmojiPickerCategory {...props}/>); | ||
|
||
// TODO: Change when we actually disabled the element when enable is false | ||
expect(screen.getByRole('link')).toHaveClass('emoji-picker__category disable'); | ||
}); | ||
|
||
test('should have tooltip on hover', async () => { | ||
renderWithContext(<EmojiPickerCategory {...defaultProps}/>); | ||
|
||
await act(async () => { | ||
const emojiPickerCategory = screen.getByRole('link'); | ||
userEvent.hover(emojiPickerCategory); | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
}); | ||
|
||
expect(screen.getByText(categoryMessage)).toBeVisible(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
@charset 'UTF-8'; | ||
|
||
.tooltip { | ||
z-index: 2000; | ||
max-width: 220px; | ||
font-family: inherit; | ||
pointer-events: none; | ||
|