mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 08:16:35 +00:00
Merge pull request #17276 from strapi/feature/review-workflow-multiple-initial-colors
Fix: Make stage theme color retrieval more defensive
This commit is contained in:
commit
5f5c6ec185
@ -174,7 +174,7 @@ export function Stage({
|
||||
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
||||
}, [dragPreviewRef, index]);
|
||||
|
||||
const { themeColorName } = colorField.value ? getStageColorByHex(colorField.value) : {};
|
||||
const { themeColorName } = getStageColorByHex(colorField.value) ?? {};
|
||||
|
||||
return (
|
||||
<Box ref={composedRef}>
|
||||
|
@ -19,18 +19,22 @@ const STAGES_FIXTURE = {
|
||||
index: 0,
|
||||
};
|
||||
|
||||
const ComponentFixture = (props) => {
|
||||
const ComponentFixture = ({
|
||||
// eslint-disable-next-line react/prop-types
|
||||
stages = [
|
||||
{
|
||||
color: STAGE_COLOR_DEFAULT,
|
||||
name: 'something',
|
||||
},
|
||||
],
|
||||
...props
|
||||
}) => {
|
||||
const store = configureStore([], [reducer]);
|
||||
|
||||
const formik = useFormik({
|
||||
enableReinitialize: true,
|
||||
initialValues: {
|
||||
stages: [
|
||||
{
|
||||
color: STAGE_COLOR_DEFAULT,
|
||||
name: 'something',
|
||||
},
|
||||
],
|
||||
stages,
|
||||
},
|
||||
validateOnChange: false,
|
||||
});
|
||||
@ -96,4 +100,19 @@ describe('Admin | Settings | Review Workflow | Stage', () => {
|
||||
})
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not crash on a custom color code', async () => {
|
||||
const { getByRole } = setup({
|
||||
isOpen: true,
|
||||
canDelete: false,
|
||||
stages: [
|
||||
{
|
||||
color: '#FF4945',
|
||||
name: 'something',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(getByRole('textbox').value).toBe('something');
|
||||
});
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
},
|
||||
{
|
||||
"name": "In progress",
|
||||
"color": "#FF4945"
|
||||
"color": "#EE5E52"
|
||||
},
|
||||
{
|
||||
"name": "Reviewed",
|
||||
|
Loading…
x
Reference in New Issue
Block a user