Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
bug(UIKIT-1691,PageHeader): Исправлена работа onClick у SecondaryVisi…
Browse files Browse the repository at this point in the history
…bleAction (#1088)
  • Loading branch information
pan1caisreal authored Aug 12, 2024
1 parent a09a70b commit 46bde0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const ButtonGroupSecondaryVisibleActions = ({
actions,
}: ButtonGroupMainActionProps) => {
return actions.map((action) => {
const { name, icon, disableReason, disabled, onClick, ...mainProps } =
action;
const { name, icon, disableReason, disabled, ...mainProps } = action;

return (
<Tooltip
Expand Down
26 changes: 25 additions & 1 deletion packages/components/src/PageHeader/PageHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import { renderWithTheme, screen, userEvents } from '@astral/tests';

import { PageHeader } from './PageHeader';
Expand Down Expand Up @@ -165,4 +165,28 @@ describe('PageHeader', () => {
expect(tooltip).toBeVisible();
expect(tooltip).toHaveTextContent('Отправка по маршруту');
});

it('OnClick вызывается при нажатии на вторичные видимые действия', async () => {
const onClickSpy = vi.fn();

renderWithTheme(
<PageHeader
title="Черновик"
actions={{
secondaryVisible: [
{
name: 'Отправка по маршруту',
icon: <svg />,
onClick: onClickSpy,
},
],
}}
/>,
);

const button = screen.getByRole('button');

await userEvents.click(button);
expect(onClickSpy).toBeCalled();
});
});

0 comments on commit 46bde0a

Please sign in to comment.