Palette: Enable accessibility attributes on Button component

Refactored the `Button` component to accept and spread standard HTML button attributes.
This allows developers to add `aria-label`, `aria-expanded`, and other accessibility properties,
which were previously ignored.

Added unit tests to verify that attributes are correctly passed to the DOM element.
This commit is contained in:
google-labs-jules[bot]
2026-01-25 01:36:53 +00:00
parent 949d5ab8b9
commit 2eb8c57a50
2 changed files with 28 additions and 9 deletions

View File

@@ -0,0 +1,23 @@
// @vitest-environment jsdom
import { render, screen, cleanup } from '@testing-library/react';
import { describe, it, expect, afterEach } from 'vitest';
import { Button } from '../Button';
import React from 'react';
describe('Button', () => {
afterEach(() => {
cleanup();
});
it('passes aria-label to the button element', () => {
render(<Button aria-label="Test Label">Click me</Button>);
const button = screen.getByRole('button', { name: /test label/i });
expect(button).toBeTruthy();
});
it('passes other HTML attributes', () => {
render(<Button data-testid="custom-button">Click me</Button>);
const button = screen.getByTestId('custom-button');
expect(button).toBeTruthy();
});
});