From 8a6b9fce07a2758c37349261242e0eb0cafb2138 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 22 Apr 2024 14:56:04 -0300 Subject: [PATCH] feat: Added Plugin Slot wrapping UpgradeNotification in NotificationTray --- .../notifications/NotificationTray.jsx | 39 ++++++++++++------- .../notifications/NotificationTray.test.jsx | 10 +++-- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx index 76f1e38f94..6adb7b3e32 100644 --- a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx +++ b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx @@ -2,6 +2,7 @@ import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; import classNames from 'classnames'; import React, { useContext, useEffect, useMemo } from 'react'; import { sendTrackEvent } from '@edx/frontend-platform/analytics'; +import { PluginSlot } from '@openedx/frontend-plugin-framework'; import { useModel } from '../../../../../generic/model-store'; import UpgradeNotification from '../../../../../generic/upgrade-notification/UpgradeNotification'; @@ -65,6 +66,22 @@ const NotificationTray = ({ intl }) => { sendTrackEvent('edx.ui.course.upgrade.old_sidebar.notifications', notificationTrayEventProperties); }, []); + const upgradeNotificationProps = { + offer, + verifiedMode, + accessExpiration, + contentTypeGatingEnabled, + marketingUrl, + upsellPageName: 'in_course', + userTimezone, + shouldDisplayBorder: false, + timeOffsetMillis, + courseId, + org, + upgradeNotificationCurrentState, + setupgradeNotificationCurrentState: setUpgradeNotificationCurrentState, // TODO: Check typo in component? + }; + return ( { >
{verifiedMode ? ( - + + + ) : (

{intl.formatMessage(messages.noNotificationsMessage)}

)} diff --git a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx index 666874d75c..3e353fbfb2 100644 --- a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx +++ b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx @@ -91,10 +91,14 @@ describe('NotificationTray', () => { , ); - const UpgradeNotification = document.querySelector('.upgrade-notification'); - expect(UpgradeNotification) - .toBeInTheDocument(); + const pluginSlot = screen.getByTestId('notification-tray-slot'); + expect(pluginSlot).toBeInTheDocument(); + + // The Upgrade Notification should be inside the PluginSlot. + const UpgradeNotification = pluginSlot.querySelector('.upgrade-notification'); + expect(UpgradeNotification).toBeInTheDocument(); + expect(screen.getByRole('link', { name: 'Upgrade for $149' })) .toBeInTheDocument(); expect(screen.queryByText('You have no new notifications at this time.'))