From 54d773a19a1e21b7b2ead9cd9439d1ae005b8255 Mon Sep 17 00:00:00 2001
From: Raymond Zhou <56318341+rayzhou-bit@users.noreply.github.com>
Date: Wed, 7 Sep 2022 12:22:27 -0400
Subject: [PATCH] Feat shared widget componentries and layout (#107)
---
.../__snapshots__/index.test.jsx.snap | 2 +
.../containers/EditorContainer/hooks.js | 7 +-
.../containers/EditorContainer/hooks.test.jsx | 8 +-
.../containers/EditorContainer/index.jsx | 7 +-
.../containers/EditorContainer/index.test.jsx | 4 +-
.../components/VideoEditorModal.jsx | 16 ++-
.../components/CollapsibleFormWidget.jsx | 62 ++++++--
.../components/CollapsibleFormWidget.test.jsx | 28 ++++
.../components/ErrorSummary.jsx | 40 ++++++
.../components/ErrorSummary.test.jsx | 17 +++
.../components/TranscriptsWidget.jsx | 23 ++-
.../components/VideoSourceWidget.jsx | 4 +-
.../CollapsibleFormWidget.test.jsx.snap | 135 ++++++++++++++++++
.../__snapshots__/ErrorSummary.test.jsx.snap | 23 +++
.../VideoSettingsModal/components/hooks.js | 12 +-
.../VideoSettingsModal/components/messages.js | 22 +++
.../components/VideoSettingsModal/index.jsx | 31 +++-
src/editors/containers/VideoEditor/hooks.js | 80 +++++++++++
.../containers/VideoEditor/hooks.test.js | 72 ++++++++++
src/editors/containers/VideoEditor/index.jsx | 12 +-
src/editors/hooks.js | 29 ++--
src/setupTest.js | 6 +
22 files changed, 593 insertions(+), 47 deletions(-)
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/CollapsibleFormWidget.test.jsx
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ErrorSummary.jsx
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ErrorSummary.test.jsx
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/__snapshots__/CollapsibleFormWidget.test.jsx.snap
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/__snapshots__/ErrorSummary.test.jsx.snap
create mode 100644 src/editors/containers/VideoEditor/components/VideoSettingsModal/components/messages.js
create mode 100644 src/editors/containers/VideoEditor/hooks.js
create mode 100644 src/editors/containers/VideoEditor/hooks.test.js
diff --git a/src/editors/containers/EditorContainer/__snapshots__/index.test.jsx.snap b/src/editors/containers/EditorContainer/__snapshots__/index.test.jsx.snap
index 19f735d73..dc5051f11 100644
--- a/src/editors/containers/EditorContainer/__snapshots__/index.test.jsx.snap
+++ b/src/editors/containers/EditorContainer/__snapshots__/index.test.jsx.snap
@@ -41,6 +41,7 @@ exports[`EditorContainer component render snapshot: initialized. enable save and
"handleSaveClicked": Object {
"dispatch": [MockFunction react-redux.dispatch],
"getContent": [MockFunction props.getContent],
+ "validateEntry": [MockFunction props.validateEntry],
},
}
}
@@ -86,6 +87,7 @@ exports[`EditorContainer component render snapshot: not initialized. disable sav
"handleSaveClicked": Object {
"dispatch": [MockFunction react-redux.dispatch],
"getContent": [MockFunction props.getContent],
+ "validateEntry": [MockFunction props.validateEntry],
},
}
}
diff --git a/src/editors/containers/EditorContainer/hooks.js b/src/editors/containers/EditorContainer/hooks.js
index 32f3a8346..77eae480a 100644
--- a/src/editors/containers/EditorContainer/hooks.js
+++ b/src/editors/containers/EditorContainer/hooks.js
@@ -23,7 +23,7 @@ export const setAssetToStaticUrl = (images, getContent) => {
imgsArray.forEach(image => {
imageUrls.push({ portableUrl: image.portableUrl, displayName: image.displayName });
});
- const imageSrcs = content.split('src="');
+ const imageSrcs = typeof content === 'string' ? content.split('src="') : [];
imageSrcs.forEach(src => {
if (src.startsWith('/asset') && imageUrls.length > 0) {
const nameFromEditorSrc = src.substring(src.lastIndexOf('@') + 1, src.indexOf('"'));
@@ -44,15 +44,16 @@ export const setAssetToStaticUrl = (images, getContent) => {
return content;
};
-export const handleSaveClicked = ({ getContent, dispatch }) => {
+export const handleSaveClicked = ({ dispatch, getContent, validateEntry }) => {
const destination = useSelector(selectors.app.returnUrl);
const analytics = useSelector(selectors.app.analytics);
const images = useSelector(selectors.app.images);
return () => saveBlock({
+ analytics,
content: setAssetToStaticUrl(images, getContent),
destination,
- analytics,
dispatch,
+ validateEntry,
});
};
export const handleCancelClicked = ({ onClose }) => {
diff --git a/src/editors/containers/EditorContainer/hooks.test.jsx b/src/editors/containers/EditorContainer/hooks.test.jsx
index 3929d4bb2..a9f027017 100644
--- a/src/editors/containers/EditorContainer/hooks.test.jsx
+++ b/src/editors/containers/EditorContainer/hooks.test.jsx
@@ -59,12 +59,17 @@ describe('EditorContainer hooks', () => {
it('returns callback to saveBlock with dispatch and content from setAssetToStaticUrl', () => {
const getContent = () => 'myTestContentValue';
const setAssetToStaticUrl = () => 'myTestContentValue';
+ const validateEntry = () => 'vaLIdAteENTry';
const output = hooks.handleSaveClicked({
getContent,
- images: { portableUrl: '/static/sOmEuiMAge.jpeg', displayName: 'sOmEuiMAge' },
+ images: {
+ portableUrl: '/static/sOmEuiMAge.jpeg',
+ displayName: 'sOmEuiMAge',
+ },
destination: 'testDEsTURL',
analytics: 'soMEanALytics',
dispatch,
+ validateEntry,
});
output();
expect(appHooks.saveBlock).toHaveBeenCalledWith({
@@ -72,6 +77,7 @@ describe('EditorContainer hooks', () => {
destination: reactRedux.useSelector(selectors.app.returnUrl),
analytics: reactRedux.useSelector(selectors.app.analytics),
dispatch,
+ validateEntry,
});
});
});
diff --git a/src/editors/containers/EditorContainer/index.jsx b/src/editors/containers/EditorContainer/index.jsx
index c554781f3..8d8258cc1 100644
--- a/src/editors/containers/EditorContainer/index.jsx
+++ b/src/editors/containers/EditorContainer/index.jsx
@@ -13,6 +13,7 @@ export const EditorContainer = ({
children,
getContent,
onClose,
+ validateEntry,
}) => {
const dispatch = useDispatch();
const isInitialized = hooks.isInitialized();
@@ -34,7 +35,7 @@ export const EditorContainer = ({
{isInitialized && children}
Some test string
); + test('snapshots: renders as expected with default props', () => { + expect( + shallow(
+
English: {transcripts.formValue.english}
Allow downloads: {allowDownload.formValue ? 'True' : 'False' }
@@ -33,4 +43,11 @@ export const TranscriptWidget = () => { ); }; +TranscriptWidget.defaultProps = { + error: {}, +}; +TranscriptWidget.propTypes = { + error: PropTypes.node, +}; + export default TranscriptWidget; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget.jsx index 512e6551d..e38166dc7 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget.jsx @@ -34,7 +34,9 @@ export const VideoSourceWidget = () => { }); return ( -+ Some test string +
+ ++ Some test string +
+ +
+