This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(UIKIT-1163,PageHeader): Добавлена возможность отображать тултип …
…основным actions (#1086)
- Loading branch information
1 parent
2075a4b
commit 16c2ecd
Showing
3 changed files
with
260 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { renderWithTheme, screen, userEvents } from '@astral/tests'; | ||
|
||
import { PageHeader } from './PageHeader'; | ||
|
||
describe('PageHeader', () => { | ||
it('Note для основных действий отображается в tooltip', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
main: [ | ||
{ | ||
text: 'Отправка по маршруту', | ||
note: 'Кнопка', | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const button = screen.getByRole('button'); | ||
|
||
await userEvents.hover(button); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Кнопка'); | ||
}); | ||
|
||
it('DisabledReason для основных действий отображается в tooltip при disabled=true', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
main: [ | ||
{ | ||
text: 'Отправка по маршруту', | ||
disabled: true, | ||
disabledReason: 'Заблокировано', | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const item = screen.getByLabelText('Заблокировано'); | ||
|
||
await userEvents.hover(item); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Заблокировано'); | ||
}); | ||
|
||
it('DisabledReason для вторичных действий отображается в tooltip при disabled=true', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
secondary: [ | ||
{ | ||
text: 'Отправка по маршруту', | ||
disabled: true, | ||
disabledReason: 'Заблокировано', | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const secondaryActionButton = screen.getByRole('button'); | ||
|
||
await userEvents.click(secondaryActionButton); | ||
|
||
const item = await screen.findByLabelText('Заблокировано'); | ||
|
||
await userEvents.hover(item); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Заблокировано'); | ||
}); | ||
|
||
it('Note для вторичных действий отображается в tooltip', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
secondary: [ | ||
{ | ||
text: 'Отправка по маршруту', | ||
note: 'Кнопка', | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const secondaryActionButton = screen.getByRole('button'); | ||
|
||
await userEvents.click(secondaryActionButton); | ||
|
||
const item = await screen.findByLabelText('Кнопка'); | ||
|
||
await userEvents.hover(item); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Кнопка'); | ||
}); | ||
|
||
it('DisabledReason для вторичных видимых действий отображается в tooltip при disabled=true', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
secondaryVisible: [ | ||
{ | ||
name: 'Отправка по маршруту', | ||
icon: <svg />, | ||
disabled: true, | ||
disableReason: 'Заблокировано', | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const item = await screen.findByLabelText('Заблокировано'); | ||
|
||
await userEvents.hover(item); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Заблокировано'); | ||
}); | ||
|
||
it('Tooltip отображается для вторичных видимых действий', async () => { | ||
renderWithTheme( | ||
<PageHeader | ||
title="Черновик" | ||
actions={{ | ||
secondaryVisible: [ | ||
{ | ||
name: 'Отправка по маршруту', | ||
icon: <svg />, | ||
}, | ||
], | ||
}} | ||
/>, | ||
); | ||
|
||
const button = screen.getByRole('button'); | ||
|
||
await userEvents.hover(button); | ||
|
||
const tooltip = await screen.findByRole('tooltip'); | ||
|
||
expect(tooltip).toBeVisible(); | ||
expect(tooltip).toHaveTextContent('Отправка по маршруту'); | ||
}); | ||
}); |