-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Beta banner and Beta badge for videos (#1169)
- Loading branch information
1 parent
334d87c
commit 913c976
Showing
14 changed files
with
325 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Badge, OverlayTrigger, Tooltip, | ||
} from '@openedx/paragon'; | ||
import './styles/VideoDetailPage.scss'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
|
||
const BetaBadge = () => ( | ||
<OverlayTrigger | ||
placement="top" | ||
overlay={( | ||
<Tooltip id="video-beta-version-badge" className="video-beta-badge-tooltip"> | ||
<FormattedMessage | ||
id="enterprise.microlearningVideo.beta.tooltip" | ||
defaultMessage="<b>Beta version of the Videos.</b> Some features may not be fully functional yet. We appreciate your patience as we fine-tune the experience." | ||
description="Tooltip message for the beta badge on the video page." | ||
values={{ | ||
// eslint-disable-next-line react/no-unstable-nested-components | ||
b: (msg) => <strong>{msg}</strong>, | ||
}} | ||
/> | ||
</Tooltip> | ||
)} | ||
> | ||
<Badge variant="info" className="ml-2"> | ||
<FormattedMessage | ||
id="enterprise.microlearningVideo.betaBadge.text" | ||
defaultMessage="Beta" | ||
description="Beta badge for the video page." | ||
/> | ||
</Badge> | ||
</OverlayTrigger> | ||
); | ||
|
||
export default BetaBadge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { | ||
Card, Button, | ||
} from '@openedx/paragon'; | ||
import './styles/VideoDetailPage.scss'; | ||
import { Link } from 'react-router-dom'; | ||
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; | ||
import { AppContext } from '@edx/frontend-platform/react'; | ||
import { useContext } from 'react'; | ||
import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import BetaBadge from './BetaBadge'; | ||
import { useEnterpriseCustomer } from '../app/data'; | ||
|
||
const VideoBanner = () => { | ||
const { data: enterpriseCustomer } = useEnterpriseCustomer(); | ||
const { authenticatedUser: { userId } } = useContext(AppContext); | ||
const sendPushEvent = () => { | ||
sendEnterpriseTrackEvent( | ||
enterpriseCustomer.uuid, | ||
'edx.ui.enterprise.learner_portal.video_banner.explore_videos_clicked', | ||
{ | ||
userId, | ||
}, | ||
); | ||
}; | ||
return ( | ||
<div data-testid="video-banner" className="d-flex justify-content-center"> | ||
<Card orientation="horizontal" className="video-banner-class bg-light-300"> | ||
<Card.Section className="col-9 text-primary-500"> | ||
<span className="d-flex justify-content-center align-items-end"> | ||
<h3 className="text-brand-500 pr-1 m-0"> | ||
<FormattedMessage | ||
id="enterprise.microlearning.video.banner.new" | ||
defaultMessage="New!" | ||
description="New badge for the video banner on the video page." | ||
/> | ||
</h3> | ||
<h3 className="p-0 m-0"> | ||
<FormattedMessage | ||
id="enterprise.microlearning.videoBanner.title" | ||
defaultMessage="Videos Now Available with Your Subscription" | ||
description="Title for the video banner on the video page." | ||
/> | ||
</h3> | ||
<BetaBadge /> | ||
</span> | ||
<p className="d-flex justify-content-center"> | ||
<FormattedMessage | ||
id="enterprise.microlearning.videoBanner.description" | ||
defaultMessage="Transform your potential into success." | ||
description="Description for the video banner on the video page." | ||
/> | ||
</p> | ||
</Card.Section> | ||
<Card.Footer className="col-3 justify-content-end"> | ||
<Button | ||
as={Link} | ||
to="#videos-section" | ||
variant="outline-primary" | ||
onClick={sendPushEvent} | ||
> | ||
<FormattedMessage | ||
id="enterprise.microlearning.videoBanner.exploreVideos" | ||
defaultMessage="Explore Videos" | ||
description="Explore Videos button text for the video banner on the video page." | ||
/> | ||
</Button> | ||
</Card.Footer> | ||
</Card> | ||
</div> | ||
); | ||
}; | ||
|
||
export default VideoBanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { AppContext } from '@edx/frontend-platform/react'; | ||
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils'; | ||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { useEnterpriseCustomer } from '../../app/data'; | ||
import VideoBanner from '../VideoBanner'; | ||
import { renderWithRouter } from '../../../utils/tests'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
jest.mock('../../app/data', () => ({ | ||
useEnterpriseCustomer: jest.fn(), | ||
})); | ||
jest.mock('@edx/frontend-enterprise-utils', () => ({ | ||
sendEnterpriseTrackEvent: jest.fn(), | ||
})); | ||
|
||
describe('VideoBanner', () => { | ||
const mockEnterpriseCustomer = { | ||
uuid: 'mock-uuid', | ||
}; | ||
|
||
const mockAuthenticatedUser = { | ||
userId: 'test-user-id', | ||
}; | ||
const VideoBannerWrapper = () => ( | ||
<IntlProvider locale="en"> | ||
<AppContext.Provider value={{ authenticatedUser: mockAuthenticatedUser }}> | ||
<VideoBanner /> | ||
</AppContext.Provider> | ||
</IntlProvider> | ||
); | ||
|
||
beforeEach(() => { | ||
useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer }); | ||
}); | ||
|
||
it('renders the video banner with correct title and description', () => { | ||
renderWithRouter(<VideoBannerWrapper />); | ||
|
||
expect(screen.getByText('New!')).toBeInTheDocument(); | ||
expect(screen.getByText('Videos Now Available with Your Subscription')).toBeInTheDocument(); | ||
expect(screen.getByText('Transform your potential into success.')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the explore videos button', () => { | ||
renderWithRouter(<VideoBannerWrapper />); | ||
|
||
expect(screen.getByText('Explore Videos')).toBeInTheDocument(); | ||
}); | ||
|
||
it('calls sendEnterpriseTrackEvent when explore videos button is clicked', () => { | ||
renderWithRouter(<VideoBannerWrapper />); | ||
|
||
const exploreVideosButton = screen.getByText('Explore Videos'); | ||
exploreVideosButton.click(); | ||
|
||
expect(sendEnterpriseTrackEvent).toHaveBeenCalledWith( | ||
mockEnterpriseCustomer.uuid, | ||
'edx.ui.enterprise.learner_portal.video_banner.explore_videos_clicked', | ||
{ | ||
userId: mockAuthenticatedUser.userId, | ||
}, | ||
); | ||
}); | ||
it('hover on Beta badge', async () => { | ||
renderWithRouter(<VideoBannerWrapper />); | ||
userEvent.hover(screen.getByText('Beta')); | ||
await waitFor(() => { | ||
expect(screen.getByText('Beta version of the Videos.')).toBeVisible(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.