diff --git a/packages/@react-spectrum/s2/src/ActionButton.tsx b/packages/@react-spectrum/s2/src/ActionButton.tsx index be70cb4396f..4ed24b9e0d9 100644 --- a/packages/@react-spectrum/s2/src/ActionButton.tsx +++ b/packages/@react-spectrum/s2/src/ActionButton.tsx @@ -291,7 +291,8 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton orientation = 'horizontal', staticColor = props.staticColor, isQuiet = props.isQuiet, - size = props.size || 'M' + size = props.size || 'M', + isDisabled } = ctx || {}; let {isProgressVisible} = usePendingState(isPending); @@ -299,6 +300,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton return ( (props.UNSAFE_className || '') + btnStyles({ diff --git a/packages/@react-spectrum/s2/test/ActionButtonGroup.test.tsx b/packages/@react-spectrum/s2/test/ActionButtonGroup.test.tsx new file mode 100644 index 00000000000..9565351a525 --- /dev/null +++ b/packages/@react-spectrum/s2/test/ActionButtonGroup.test.tsx @@ -0,0 +1,65 @@ +/* + * Copyright 2024 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import {ActionButton, ActionButtonGroup, Text} from '../src'; +import {render} from '@react-spectrum/test-utils-internal'; + +describe('ActionButtonGroup', () => { + + it('can disable all buttons from the group', async () => { + let {getAllByRole} = render( + + Bold + Italic + Underline + + ); + + + let buttons = getAllByRole('button'); + expect(buttons[0]).toBeDisabled(); + expect(buttons[1]).toBeDisabled(); + expect(buttons[2]).toBeDisabled(); + }); + + it('can set disable individually', async () => { + let {getAllByRole} = render( + + Bold + Italic + Underline + + ); + + + let buttons = getAllByRole('button'); + expect(buttons[0]).toBeDisabled(); + expect(buttons[1]).not.toBeDisabled(); + expect(buttons[2]).not.toBeDisabled(); + }); + + it('can override the group disable', async () => { + let {getAllByRole} = render( + + Bold + Italic + Underline + + ); + + + let buttons = getAllByRole('button'); + expect(buttons[0]).not.toBeDisabled(); + expect(buttons[1]).toBeDisabled(); + expect(buttons[2]).toBeDisabled(); + }); +}); diff --git a/packages/@react-spectrum/s2/test/ToggleButtonGroup.test.tsx b/packages/@react-spectrum/s2/test/ToggleButtonGroup.test.tsx new file mode 100644 index 00000000000..c0d87ca68b1 --- /dev/null +++ b/packages/@react-spectrum/s2/test/ToggleButtonGroup.test.tsx @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import {render} from '@react-spectrum/test-utils-internal'; +import {Text, ToggleButton, ToggleButtonGroup} from '../src'; + +describe('ToggleButtonGroup', () => { + + it('can disable all buttons from the group', async () => { + let {getAllByRole} = render( + + Bold + Italic + Underline + + ); + + + let buttons = getAllByRole('radio'); + expect(buttons[0]).toBeDisabled(); + expect(buttons[1]).toBeDisabled(); + expect(buttons[2]).toBeDisabled(); + }); +}); diff --git a/packages/react-aria-components/test/SearchField.test.js b/packages/react-aria-components/test/SearchField.test.js index 736273c8220..e319e5cd93c 100644 --- a/packages/react-aria-components/test/SearchField.test.js +++ b/packages/react-aria-components/test/SearchField.test.js @@ -118,6 +118,9 @@ describe('SearchField', () => { expect(document.getElementById(input.getAttribute('aria-describedby'))).toHaveTextContent('Constraints not satisfied'); expect(document.activeElement).toBe(input); + expect(input.parentElement).toHaveAttribute('data-invalid'); + expect(input.parentElement).toHaveAttribute('data-required'); + await user.keyboard('Devon'); expect(input).toHaveAttribute('aria-describedby'); @@ -127,6 +130,22 @@ describe('SearchField', () => { expect(input).not.toHaveAttribute('aria-describedby'); }); + it('supports readonly', async () => { + let {getByRole} = render( +
+ + + + + +
+ ); + + let input = getByRole('searchbox'); + + expect(input.parentElement).toHaveAttribute('data-readonly'); + }); + it('should support form prop', () => { let {getByRole} = render( diff --git a/packages/react-aria-components/test/Select.test.js b/packages/react-aria-components/test/Select.test.js index 4328ecfc904..25ce2caa762 100644 --- a/packages/react-aria-components/test/Select.test.js +++ b/packages/react-aria-components/test/Select.test.js @@ -162,6 +162,30 @@ describe('Select', () => { expect(trigger).toHaveTextContent('Select an animal'); }); + it('should support empty state', async () => { + let {getByTestId, getByRole} = render( + + ); + let selectTester = testUtilUser.createTester('Select', {root: getByTestId('select')}); + await selectTester.open(); + + let listbox = getByRole('listbox'); + expect(listbox).toHaveAttribute('data-empty', 'true'); + + let option = getByRole('option'); + expect(option).toHaveTextContent('No results'); + }); + it('should support render props', async () => { let {getByTestId} = render(