diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.test.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.test.tsx new file mode 100644 index 0000000000000..ac3e1c23f4beb --- /dev/null +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.test.tsx @@ -0,0 +1,58 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { render } from '@testing-library/react'; +import { EuiFlyout } from '@elastic/eui'; +import { Flyout } from '.'; + +jest.mock('@elastic/eui', () => { + const actual = jest.requireActual('@elastic/eui'); + + return { + ...actual, + EuiFlyout: jest.fn(({ children }: { children: React.ReactNode }) =>
{children}
), + }; +}); + +describe('Assistant settings flyout', () => { + const requiredProps = { + flyoutVisible: true, + onClose: jest.fn(), + onSaveCancelled: jest.fn(), + onSaveConfirmed: jest.fn(), + }; + + beforeEach(() => { + (EuiFlyout as unknown as jest.Mock).mockClear(); + }); + + it('passes aria-label from the title to EuiFlyout', () => { + const title = 'Edit system prompt'; + const mockedEuiFlyout = EuiFlyout as unknown as jest.Mock; + render( + +
{'Body'}
+
+ ); + + const firstCallProps = mockedEuiFlyout.mock.calls[0]?.[0]; + expect(firstCallProps?.['aria-label']).toBe(title); + }); + + it('does not pass aria-label when the title is missing', () => { + const mockedEuiFlyout = EuiFlyout as unknown as jest.Mock; + render( + +
{'Body'}
+
+ ); + + const firstCallProps = mockedEuiFlyout.mock.calls[0]?.[0]; + expect(firstCallProps?.['aria-label']).toBeUndefined(); + }); +}); diff --git a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.tsx b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.tsx index b54f43c6a3aa4..ce498a82fcf9f 100644 --- a/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.tsx +++ b/x-pack/platform/packages/shared/kbn-elastic-assistant/impl/assistant/common/components/assistant_settings_management/flyout/index.tsx @@ -46,6 +46,7 @@ const FlyoutComponent: React.FC = ({ data-test-subj={'flyout'} ownFocus onClose={onClose} + aria-label={title} css={css` max-width: 656px; `}