forked from KaotoIO/kaoto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PropertiesField): Reduce padding and start with expandable open
Currently, the `PropertiesField` component overflows from the containing `Form`. This commit: * Reduces its padding * Changes the containing `Td` so it can limit the overflow * Extracts the `PropertiesFieldEmpty` state component * Add a few missing tests fix: KaotoIO#1473
- Loading branch information
Showing
24 changed files
with
2,098 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { act, render } from '@testing-library/react'; | ||
import { KaotoSchemaDefinition } from '../../models'; | ||
import { CanvasFormTabsProvider } from '../../providers'; | ||
import { UniformsWrapper } from '../../stubs/TestUniformsWrapper'; | ||
import { TimerComponentSchema } from '../../stubs/timer.component.schema'; | ||
import { CustomAutoFields } from './CustomAutoFields'; | ||
|
||
describe('CustomAutoFields', () => { | ||
it('renders `AutoFields` for common fields', () => { | ||
let wrapper: ReturnType<typeof render> | undefined; | ||
|
||
act(() => { | ||
wrapper = render( | ||
<CanvasFormTabsProvider> | ||
<UniformsWrapper model={{}} schema={TimerComponentSchema as KaotoSchemaDefinition['schema']}> | ||
<CustomAutoFields /> | ||
</UniformsWrapper> | ||
</CanvasFormTabsProvider>, | ||
); | ||
}); | ||
|
||
expect(wrapper?.asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('render `NoFieldFound` when there are no fields', () => { | ||
let wrapper: ReturnType<typeof render> | undefined; | ||
|
||
act(() => { | ||
wrapper = render( | ||
<CanvasFormTabsProvider> | ||
<UniformsWrapper model={{}} schema={{ type: 'object' } as KaotoSchemaDefinition['schema']}> | ||
<CustomAutoFields /> | ||
</UniformsWrapper> | ||
</CanvasFormTabsProvider>, | ||
); | ||
}); | ||
|
||
expect(wrapper?.asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react'; | ||
import { CanvasFormTabsContext, CanvasFormTabsContextResult } from '../../providers'; | ||
import { NoFieldFound } from './NoFieldFound'; | ||
|
||
describe('NoFieldFound Component', () => { | ||
it('should render null if canvasFormTabsContext is not provided', () => { | ||
const { container } = render(<NoFieldFound />); | ||
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
it('should render the alert with the correct tab name', () => { | ||
const mockContextValue: CanvasFormTabsContextResult = { | ||
selectedTab: 'Required', | ||
onTabChange: jest.fn(), | ||
}; | ||
|
||
render( | ||
<CanvasFormTabsContext.Provider value={mockContextValue}> | ||
<NoFieldFound /> | ||
</CanvasFormTabsContext.Provider>, | ||
); | ||
|
||
expect(screen.getByTestId('no-field-found')).toBeInTheDocument(); | ||
expect(screen.getByText('No Required fields found')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onTabChange when the button is clicked', () => { | ||
const mockContextValue: CanvasFormTabsContextResult = { | ||
selectedTab: 'Required', | ||
onTabChange: jest.fn(), | ||
}; | ||
|
||
render( | ||
<CanvasFormTabsContext.Provider value={mockContextValue}> | ||
<NoFieldFound /> | ||
</CanvasFormTabsContext.Provider>, | ||
); | ||
|
||
const button = screen.getByRole('button', { name: /All/i }); | ||
fireEvent.click(button); | ||
|
||
expect(mockContextValue.onTabChange).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.