diff --git a/assets/js/components/ClusterDetails/ChecksResultOverview.jsx b/assets/js/components/ClusterDetails/ChecksResultOverview.jsx index 16e5aaaf93..df0542858e 100644 --- a/assets/js/components/ClusterDetails/ChecksResultOverview.jsx +++ b/assets/js/components/ClusterDetails/ChecksResultOverview.jsx @@ -18,8 +18,12 @@ function ChecksResultOverview({ }) { if (loading || pendingStates.includes(data?.status)) { return ( -
- +
+

Check Summary

+ + Checks execution running... + +
); } diff --git a/assets/js/components/ClusterDetails/ChecksResultOverview.test.jsx b/assets/js/components/ClusterDetails/ChecksResultOverview.test.jsx index 4c31d36f49..762535f83e 100644 --- a/assets/js/components/ClusterDetails/ChecksResultOverview.test.jsx +++ b/assets/js/components/ClusterDetails/ChecksResultOverview.test.jsx @@ -12,6 +12,10 @@ describe('ChecksResultOverview component', () => { render(); expect(screen.getByRole('alert')).toBeVisible(); + expect(screen.queryByText('Check Summary')).toBeInTheDocument(); + expect( + screen.queryByText('Checks execution running...') + ).toBeInTheDocument(); expect(screen.queryByText('Passing')).not.toBeInTheDocument(); expect(screen.queryByText('Warning')).not.toBeInTheDocument(); expect(screen.queryByText('Critical')).not.toBeInTheDocument(); diff --git a/assets/js/components/Spinner.jsx b/assets/js/components/Spinner.jsx index a2ba877924..3881a1ac50 100644 --- a/assets/js/components/Spinner.jsx +++ b/assets/js/components/Spinner.jsx @@ -1,14 +1,10 @@ import React from 'react'; -import { computedIconCssClass } from '@lib/icon'; - import { EOS_LOADING_ANIMATED } from 'eos-icons-react'; -function Spinner({ centered = false }) { +function Spinner({ className = '', size = 'm' }) { return ( -
- +
+
); } diff --git a/assets/js/components/Spinner.stories.jsx b/assets/js/components/Spinner.stories.jsx new file mode 100644 index 0000000000..5206f95f50 --- /dev/null +++ b/assets/js/components/Spinner.stories.jsx @@ -0,0 +1,27 @@ +import Spinner from './Spinner'; + +export default { + title: 'Spinner', + component: Spinner, +}; + +export const Default = { + argTypes: { + className: { + control: 'text', + description: 'Add padding or margin', + table: { + type: { summary: 'string' }, + }, + }, + size: { + control: { type: 'radio' }, + options: ['xs', 's', 'base', 'm', 'l', 'xl', 'xxl', 'xxxl'], + description: 'How big should be the spinner?', + table: { + type: { summary: 'string' }, + defaultValue: { summary: 'm' }, + }, + }, + }, +}; diff --git a/assets/js/components/Spinner.test.jsx b/assets/js/components/Spinner.test.jsx new file mode 100644 index 0000000000..78c998edb4 --- /dev/null +++ b/assets/js/components/Spinner.test.jsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import Spinner from './Spinner'; + +describe('Spinner', () => { + it('renders the spinner component with default props', () => { + render(); + const spinnerElement = screen.getByRole('alert'); + expect(spinnerElement).toBeInTheDocument(); + expect(spinnerElement).toHaveAttribute('aria-label', 'Loading'); + expect(spinnerElement.firstChild).toHaveClass('fill-jungle-green-500'); + }); + + it('renders the spinner component with custom props', () => { + render(); + const spinnerElement = screen.getByRole('alert'); + expect(spinnerElement).toBeInTheDocument(); + expect(spinnerElement).toHaveAttribute('aria-label', 'Loading'); + expect(spinnerElement).toHaveClass('pt-12'); + expect(spinnerElement.firstChild).toHaveAttribute('width', '32'); + }); +});