Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sumac] chore: hide transcripts in video preview for library (#1459) #1474

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import hooks from './hooks';
import LanguageNamesWidget from './LanguageNamesWidget';
import videoThumbnail from '../../../../../../data/images/videoThumbnail.svg';

const VideoPreviewWidget = ({
// Exporting to test this component separately
export const VideoPreviewWidget = ({
thumbnail,
videoSource,
transcripts,
blockTitle,
isLibrary,
intl,
}) => {
const imgRef = React.useRef();
Expand Down Expand Up @@ -45,7 +47,10 @@ const VideoPreviewWidget = ({
/>
<Stack gap={1} className="justify-content-center">
<h4 className="text-primary mb-0">{blockTitle}</h4>
<LanguageNamesWidget transcripts={transcripts} />
{!isLibrary && (
// Since content libraries v2 don't support static assets yet, we can't include transcripts.
<LanguageNamesWidget transcripts={transcripts} />
)}
{videoType && (
<Hyperlink
className="text-primary x-small"
Expand All @@ -69,13 +74,15 @@ VideoPreviewWidget.propTypes = {
thumbnail: PropTypes.string.isRequired,
transcripts: PropTypes.arrayOf(PropTypes.string).isRequired,
blockTitle: PropTypes.string.isRequired,
isLibrary: PropTypes.bool.isRequired,
};

export const mapStateToProps = (state) => ({
transcripts: selectors.video.transcripts(state),
videoSource: selectors.video.videoSource(state),
thumbnail: selectors.video.thumbnail(state),
blockTitle: selectors.app.blockTitle(state),
isLibrary: selectors.app.isLibrary(state),
});

export default injectIntl(connect(mapStateToProps)(VideoPreviewWidget));
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {
initializeMocks,
render,
screen,
} from '../../../../../../../testUtils';

import { VideoPreviewWidget } from '.';

describe('VideoPreviewWidget', () => {
const mockIntl = {
formatMessage: (message) => message.defaultMessage,
};

beforeEach(() => {
initializeMocks();
});

describe('render', () => {
test('renders transcripts section in preview for courses', () => {
render(
<VideoPreviewWidget
videoSource="some-source"
isLibrary={false}
intl={mockIntl}
transcripts={[]}
blockTitle="some title"
thumbnail=""
/>,
);
expect(screen.queryByText('No transcripts added')).toBeInTheDocument();
});

test('hides transcripts section in preview for libraries', () => {
render(
<VideoPreviewWidget
videoSource="some-source"
isLibrary
intl={mockIntl}
transcripts={[]}
blockTitle="some title"
thumbnail=""
/>,
);
expect(screen.queryByText('No transcripts added')).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import LicenseWidget from './components/LicenseWidget';
import ThumbnailWidget from './components/ThumbnailWidget';
import TranscriptWidget from './components/TranscriptWidget';
import VideoSourceWidget from './components/VideoSourceWidget';
import VideoPreviewWidget from './components/VideoPreviewWidget';
// Using default import to get selectors connected VideoSourceWidget
import ConnectedVideoPreviewWidget from './components/VideoPreviewWidget';
import './index.scss';
import SocialShareWidget from './components/SocialShareWidget';
import messages from '../../messages';
Expand Down Expand Up @@ -42,7 +43,7 @@ const VideoSettingsModal: React.FC<Props> = ({
</Button>
)}
<ErrorSummary />
<VideoPreviewWidget />
<ConnectedVideoPreviewWidget />
<VideoSourceWidget />
{!isLibrary && (
<SocialShareWidget />
Expand Down