File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed
src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export const VideoPreviewWidget = ({
47
47
< Stack gap = { 1 } className = "justify-content-center" >
48
48
< h4 className = "text-primary mb-0" > { blockTitle } </ h4 >
49
49
< LanguageNamesWidget transcripts = { transcripts } />
50
- { videoType && (
50
+ { videoType && videoSource && (
51
51
< Hyperlink
52
52
className = "text-primary x-small"
53
53
destination = { videoSource }
Original file line number Diff line number Diff line change @@ -43,5 +43,54 @@ describe('VideoPreviewWidget', () => {
43
43
) ;
44
44
expect ( screen . queryByText ( 'No transcripts added' ) ) . toBeInTheDocument ( ) ;
45
45
} ) ;
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
+ } ) ;
46
95
} ) ;
47
96
} ) ;
You can’t perform that action at this time.
0 commit comments