Skip to content

Commit 0f2dd4a

Browse files
authored
fix: ensure hyperlink renders correctly based on videoSource presence (#2400)
* fix: ensure hyperlink renders correctly based on videoSource presence * refactor: remove unnecessary blank lines in VideoPreviewWidget tests
1 parent 6646c8e commit 0f2dd4a

File tree

2 files changed

+50
-1
lines changed
  • src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget

2 files changed

+50
-1
lines changed

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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}

src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.test.jsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)