Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Positioning 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 959 Changed
vr-tests-react-components/ProgressBar converged 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png 44 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png 25 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png 175 Changed
vr-tests-react-components/TagPicker 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled.chromium.png 677 Changed
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed

There were 2 duplicate changes discarded. Check the build logs for more information.

"type": "patch",
"comment": "test: add SplitButton regression coverage for ref forwarding, default menu icon, and slot element metadata",
"packageName": "@fluentui/react-button",
"email": "vgenaev@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import userEvent from '@testing-library/user-event';
import { isSlot, SLOT_ELEMENT_TYPE_SYMBOL } from '@fluentui/react-utilities';
import { isConformant } from '../../testing/isConformant';
import { SplitButton } from './SplitButton';
import { Button } from '../Button/Button';
import { MenuButton } from '../MenuButton/MenuButton';
import { useSplitButton_unstable } from './useSplitButton';
import type { SplitButtonProps } from './SplitButton.types';

describe('SplitButton', () => {
Expand Down Expand Up @@ -176,4 +181,51 @@ describe('SplitButton', () => {
userEvent.click(primaryActionButton);
expect(onClick).not.toHaveBeenCalled();
});

it('forwards a ref to the root DIV element', () => {
let rootElement: Element | null = null;
const { container } = render(
<SplitButton
ref={node => {
rootElement = node;
}}
>
This is a button
</SplitButton>,
);

expect(rootElement).toBeInstanceOf(HTMLDivElement);
expect(rootElement).toBe(container.firstElementChild);
});

it('renders the default styled menu icon (chevron) when no menu icon is provided', () => {
const { getAllByRole } = render(<SplitButton>This is a button</SplitButton>);
const [, menuButton] = getAllByRole('button');

expect(menuButton.querySelector('svg')).toBeTruthy();
});

it('renders an explicit menu icon instead of the default chevron', () => {
const { getAllByRole } = render(<SplitButton menuIcon="Test MenuIcon">This is a button</SplitButton>);
const [, menuButton] = getAllByRole('button');

expect(menuButton.textContent).toBe('Test MenuIcon');
expect(menuButton.querySelector('svg')).toBeFalsy();
});

it('resolves child slot element metadata to the styled Button and MenuButton components', () => {
const { result } = renderHook(() => useSplitButton_unstable({ children: 'This is a button' }, React.createRef()));

const { primaryActionButton, menuButton } = result.current;

expect(isSlot(primaryActionButton)).toBe(true);
expect(isSlot(menuButton)).toBe(true);

if (!isSlot(primaryActionButton) || !isSlot(menuButton)) {
return;
}

expect(primaryActionButton[SLOT_ELEMENT_TYPE_SYMBOL]).toBe(Button);
expect(menuButton[SLOT_ELEMENT_TYPE_SYMBOL]).toBe(MenuButton);
});
});
Loading