From 0f2dd4a88ffacc7aff4173677e2755e040bf6126 Mon Sep 17 00:00:00 2001 From: Pradeep Date: Thu, 28 Aug 2025 15:14:17 +0530 Subject: [PATCH] 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 --- .../components/VideoPreviewWidget/index.jsx | 2 +- .../VideoPreviewWidget/index.test.jsx | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.jsx index b3340b13a..610984556 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/index.jsx @@ -47,7 +47,7 @@ export const VideoPreviewWidget = ({

{blockTitle}

- {videoType && ( + {videoType && videoSource && ( { ); expect(screen.queryByText('No transcripts added')).toBeInTheDocument(); }); + + test('renders hyperlink when videoSource is provided', () => { + render( + , + ); + + const hyperlink = screen.getByRole('link'); + expect(hyperlink).toBeInTheDocument(); + expect(hyperlink).toHaveAttribute('href', 'https://example.com/video.mp4'); + expect(hyperlink).toHaveAttribute('target', '_blank'); + expect(hyperlink).toHaveAttribute('rel', 'noopener noreferrer'); + }); + + test('does not render hyperlink when videoSource is empty', () => { + render( + , + ); + + const hyperlink = screen.queryByRole('link'); + expect(hyperlink).not.toBeInTheDocument(); + }); + + test('renders YouTube video type as hyperlink when videoSource is YouTube URL', () => { + render( + , + ); + + const hyperlink = screen.getByRole('link'); + expect(hyperlink).toBeInTheDocument(); + expect(hyperlink).toHaveAttribute('href', 'https://youtu.be/dQw4w9WgXcQ'); + }); }); });