File tree Expand file tree Collapse file tree
src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export const VideoPreviewWidget = ({
4747 < Stack gap = { 1 } className = "justify-content-center" >
4848 < h4 className = "text-primary mb-0" > { blockTitle } </ h4 >
4949 < LanguageNamesWidget transcripts = { transcripts } />
50- { videoType && (
50+ { videoType && videoSource && (
5151 < Hyperlink
5252 className = "text-primary x-small"
5353 destination = { videoSource }
Original file line number Diff line number Diff line change @@ -43,5 +43,54 @@ describe('VideoPreviewWidget', () => {
4343 ) ;
4444 expect ( screen . queryByText ( 'No transcripts added' ) ) . toBeInTheDocument ( ) ;
4545 } ) ;
46+
47+ test ( 'renders hyperlink when videoSource is provided' , ( ) => {
48+ render (
49+ < VideoPreviewWidget
50+ videoSource = "https://example.com/video.mp4"
51+ intl = { mockIntl }
52+ transcripts = { [ ] }
53+ blockTitle = "Test Video"
54+ thumbnail = ""
55+ /> ,
56+ ) ;
57+
58+ const hyperlink = screen . getByRole ( 'link' ) ;
59+ expect ( hyperlink ) . toBeInTheDocument ( ) ;
60+ expect ( hyperlink ) . toHaveAttribute ( 'href' , 'https://example.com/video.mp4' ) ;
61+ expect ( hyperlink ) . toHaveAttribute ( 'target' , '_blank' ) ;
62+ expect ( hyperlink ) . toHaveAttribute ( 'rel' , 'noopener noreferrer' ) ;
63+ } ) ;
64+
65+ test ( 'does not render hyperlink when videoSource is empty' , ( ) => {
66+ render (
67+ < VideoPreviewWidget
68+ videoSource = ""
69+ intl = { mockIntl }
70+ transcripts = { [ ] }
71+ blockTitle = "Test Video"
72+ thumbnail = ""
73+ /> ,
74+ ) ;
75+
76+ const hyperlink = screen . queryByRole ( 'link' ) ;
77+ expect ( hyperlink ) . not . toBeInTheDocument ( ) ;
78+ } ) ;
79+
80+ test ( 'renders YouTube video type as hyperlink when videoSource is YouTube URL' , ( ) => {
81+ render (
82+ < VideoPreviewWidget
83+ videoSource = "https://youtu.be/dQw4w9WgXcQ"
84+ intl = { mockIntl }
85+ transcripts = { [ ] }
86+ blockTitle = "YouTube Video"
87+ thumbnail = ""
88+ /> ,
89+ ) ;
90+
91+ const hyperlink = screen . getByRole ( 'link' ) ;
92+ expect ( hyperlink ) . toBeInTheDocument ( ) ;
93+ expect ( hyperlink ) . toHaveAttribute ( 'href' , 'https://youtu.be/dQw4w9WgXcQ' ) ;
94+ } ) ;
4695 } ) ;
4796} ) ;
You can’t perform that action at this time.
0 commit comments