@@ -210,11 +196,22 @@ const OutlineTab = ({ intl }) => {
)}
-
+
diff --git a/src/course-home/outline-tab/OutlineTab.test.jsx b/src/course-home/outline-tab/OutlineTab.test.jsx
index 5395da4506..7bb8544d96 100644
--- a/src/course-home/outline-tab/OutlineTab.test.jsx
+++ b/src/course-home/outline-tab/OutlineTab.test.jsx
@@ -132,19 +132,14 @@ describe('Outline Tab', () => {
expect(expandedSectionNode).toHaveAttribute('aria-expanded', 'true');
});
- it('renders the Notification wrapper', async () => {
+ it('includes outline_tab_notifications_plugin slot', async () => {
const { courseBlocks } = await buildMinimalCourseBlocks(courseId, 'Title', { resumeBlock: true });
setTabData({
course_blocks: { blocks: courseBlocks.blocks },
});
await fetchAndRender();
- const pluginSlot = screen.getByTestId('outline-tab-slot');
- expect(pluginSlot).toBeInTheDocument();
-
- // The Upgrade Notification should be inside the PluginSlot.
- const UpgradeNotification = pluginSlot.querySelector('.upgrade-notification');
- expect(UpgradeNotification).toBeInTheDocument();
+ expect(screen.getByTestId('outline_tab_notifications_plugin')).toBeInTheDocument();
});
it('handles expand/collapse all button click', async () => {
diff --git a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
index d7e6b5e064..c926c1468d 100644
--- a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
+++ b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
@@ -59,6 +59,10 @@ const NotificationsWidget = () => {
verification_status: verificationStatus,
};
+ const onToggleSidebar = () => {
+ toggleSidebar(currentSidebar, WIDGETS.NOTIFICATIONS);
+ };
+
// After three seconds, update notificationSeen (to hide red dot)
useEffect(() => {
setTimeout(onNotificationSeen, 3000);
@@ -67,31 +71,33 @@ const NotificationsWidget = () => {
if (hideNotificationbar || !isNotificationbarAvailable) { return null; }
- const upgradeNotificationProps = {
- offer,
- verifiedMode,
- accessExpiration,
- contentTypeGatingEnabled,
- marketingUrl,
- upsellPageName: 'in_course',
- userTimezone,
- timeOffsetMillis,
- courseId,
- org,
- upgradeNotificationCurrentState,
- setupgradeNotificationCurrentState: setUpgradeNotificationCurrentState, // TODO: Check typo in component?
- shouldDisplayBorder: false,
- toggleSidebar: () => toggleSidebar(currentSidebar, WIDGETS.NOTIFICATIONS),
- };
-
return (
);
diff --git a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.test.jsx b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.test.jsx
index b72b4f90b1..cc19bb64c4 100644
--- a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.test.jsx
+++ b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.test.jsx
@@ -80,7 +80,7 @@ describe('NotificationsWidget', () => {
});
});
- it('renders upgrade card', async () => {
+ it('includes notification_widget_plugin slot', async () => {
await fetchAndRender(
{
,
);
+ expect(screen.getByTestId('notification_widget_plugin')).toBeInTheDocument();
+ });
- const pluginSlot = screen.getByTestId('notification-widget-slot');
- expect(pluginSlot).toBeInTheDocument();
+ it('renders upgrade card', async () => {
+ await fetchAndRender(
+
+
+ ,
+ );
// The Upgrade Notification should be inside the PluginSlot.
- const UpgradeNotification = pluginSlot.querySelector('.upgrade-notification');
+ const UpgradeNotification = document.querySelector('.upgrade-notification');
expect(UpgradeNotification).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Upgrade for $149' })).toBeInTheDocument();
diff --git a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
index 5c133bc60b..4cda479759 100644
--- a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
+++ b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
@@ -66,22 +66,6 @@ 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 3e353fbfb2..2e1815f7be 100644
--- a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx
+++ b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.test.jsx
@@ -81,7 +81,7 @@ describe('NotificationTray', () => {
.toBeInTheDocument();
});
- it('renders upgrade card', async () => {
+ it('includes notification_tray_plugin slot', async () => {
await fetchAndRender(
{
,
);
+ expect(screen.getByTestId('notification_tray_plugin')).toBeInTheDocument();
+ });
- const pluginSlot = screen.getByTestId('notification-tray-slot');
- expect(pluginSlot).toBeInTheDocument();
+ it('renders upgrade card', async () => {
+ await fetchAndRender(
+
+
+ ,
+ );
- // The Upgrade Notification should be inside the PluginSlot.
- const UpgradeNotification = pluginSlot.querySelector('.upgrade-notification');
- expect(UpgradeNotification).toBeInTheDocument();
+ expect(document.querySelector('.upgrade-notification')).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Upgrade for $149' }))
.toBeInTheDocument();
diff --git a/src/tests/MockedPluginSlot.jsx b/src/tests/MockedPluginSlot.jsx
index e1409ca88b..e86952ee0b 100644
--- a/src/tests/MockedPluginSlot.jsx
+++ b/src/tests/MockedPluginSlot.jsx
@@ -1,11 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
-const MockedPluginSlot = ({ children, testId }) => {
- if (!testId) { return children ?? 'PluginSlot'; } // Return its content if PluginSlot slot is wrapping any.
-
- return
{children}
;
-};
+const MockedPluginSlot = ({ children, id }) => (
+
+ PluginSlot_{id}
+ { children &&
{children}
}
+
+);
MockedPluginSlot.displayName = 'PluginSlot';
@@ -14,12 +15,12 @@ MockedPluginSlot.propTypes = {
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
- testId: PropTypes.string,
+ id: PropTypes.string,
};
MockedPluginSlot.defaultProps = {
children: undefined,
- testId: undefined,
+ id: undefined,
};
export default MockedPluginSlot;
diff --git a/src/tests/MockedPluginSlot.test.jsx b/src/tests/MockedPluginSlot.test.jsx
index cc492a0d11..b830b68fbf 100644
--- a/src/tests/MockedPluginSlot.test.jsx
+++ b/src/tests/MockedPluginSlot.test.jsx
@@ -3,14 +3,14 @@ import { render, screen } from '@testing-library/react';
import MockedPluginSlot from './MockedPluginSlot';
describe('MockedPluginSlot', () => {
- it('renders as plain "PluginSlot" text node if no clildren nor testId is', () => {
- render(
);
+ it('renders mock plugin with "PluginSlot" text', () => {
+ render(
);
- const component = screen.getByText('PluginSlot');
+ const component = screen.getByText('PluginSlot_test_plugin');
expect(component).toBeInTheDocument();
});
- it('renders as the slot children directly if there is content within and no testId', () => {
+ it('renders as the slot children directly if there is content within', () => {
render(
@@ -27,9 +27,9 @@ describe('MockedPluginSlot', () => {
expect(quote.getAttribute('role')).toBe('note');
});
- it('renders a div when a testId is provided ', () => {
+ it('renders mock plugin with a data-testid ', () => {
render(
-
+
I am selling these fine leather jackets.
,
);
From af3eaf6271c718eb1bd8cb68527c331281c3c826 Mon Sep 17 00:00:00 2001
From: Zacharis278
Date: Tue, 7 May 2024 14:36:50 -0400
Subject: [PATCH 6/7] style: fix extra space from merge
---
.../course/sidebar/sidebars/notifications/NotificationTray.jsx | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
index 0b78c0210e..9fe8d1ad21 100644
--- a/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
+++ b/src/courseware/course/sidebar/sidebars/notifications/NotificationTray.jsx
@@ -6,7 +6,6 @@ import { PluginSlot } from '@openedx/frontend-plugin-framework';
import { useModel } from '../../../../../generic/model-store';
import UpgradeNotification from '../../../../../generic/upgrade-notification/UpgradeNotification';
-
import messages from '../../../messages';
import SidebarBase from '../../common/SidebarBase';
import SidebarContext from '../../SidebarContext';
From 71a23d28d89833cc16dd73d74b801b81396aff6a Mon Sep 17 00:00:00 2001
From: Zacharis278
Date: Mon, 13 May 2024 16:25:32 -0400
Subject: [PATCH 7/7] feat: rename plugin slots
---
.../notifications/NotificationsWidget.jsx | 2 +-
.../notifications/NotificationsWidget.test.jsx | 4 ++--
src/courseware/course/sequence/Unit/UnitSuspense.jsx | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
index c926c1468d..7e7087ac5b 100644
--- a/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
+++ b/src/courseware/course/new-sidebar/sidebars/discussions-notifications/notifications/NotificationsWidget.jsx
@@ -74,7 +74,7 @@ const NotificationsWidget = () => {
return (
{
});
});
- it('includes notification_widget_plugin slot', async () => {
+ it('includes notification_widget_slot', async () => {
await fetchAndRender(
{
,
);
- expect(screen.getByTestId('notification_widget_plugin')).toBeInTheDocument();
+ expect(screen.getByTestId('notification_widget_slot')).toBeInTheDocument();
});
it('renders upgrade card', async () => {
diff --git a/src/courseware/course/sequence/Unit/UnitSuspense.jsx b/src/courseware/course/sequence/Unit/UnitSuspense.jsx
index 0e1871ec68..09843a7164 100644
--- a/src/courseware/course/sequence/Unit/UnitSuspense.jsx
+++ b/src/courseware/course/sequence/Unit/UnitSuspense.jsx
@@ -30,7 +30,7 @@ const UnitSuspense = ({
{shouldDisplayContentGating && (
}>