From 0750b8416dabe469071a59c0e74081cdbb72a128 Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Wed, 30 Apr 2025 15:25:07 -0400 Subject: [PATCH 1/4] test: reproduce issue --- .../PagesAndResources.test.jsx | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/pages-and-resources/PagesAndResources.test.jsx b/src/pages-and-resources/PagesAndResources.test.jsx index 180c3f8674..e5c46cc343 100644 --- a/src/pages-and-resources/PagesAndResources.test.jsx +++ b/src/pages-and-resources/PagesAndResources.test.jsx @@ -2,15 +2,39 @@ import { screen, waitFor } from '@testing-library/react'; import { PagesAndResources } from '.'; import { render } from './utils.test'; +import { getConfig, setConfig } from '@edx/frontend-platform'; +import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework'; + +const mockPlugin = (identifier) => ({ + plugins: [ + { + op: PLUGIN_OPERATIONS.Insert, + widget: { + id: "mock-plugin-1", + type: DIRECT_PLUGIN, + priority: 1, + RenderWidget: () =>
HELLO
, + }, + }, + ], + }) const courseId = 'course-v1:edX+TestX+Test_Course'; describe('PagesAndResources', () => { beforeEach(() => { jest.clearAllMocks(); + setConfig({ + ...getConfig(), + pluginSlots: { + 'org.openedx.frontend.authoring.additional_course_plugin.v1': mockPlugin('additional_course_plugin'), + 'org.openedx.frontend.authoring.additional_course_content_plugin.v1': mockPlugin('additional_course_content_plugin'), + }, + }); }); + - it('doesn\'t show content permissions section if relevant apps are not enabled', () => { + it('doesn\'t show content permissions section if relevant apps are not enabled', async () => { const initialState = { models: { courseApps: {}, @@ -25,8 +49,11 @@ describe('PagesAndResources', () => { { preloadedState: initialState }, ); - expect(screen.queryByRole('heading', { name: 'Content permissions' })).not.toBeInTheDocument(); + await waitFor(() => expect(screen.queryByRole('heading', { name: 'Content permissions' })).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); }); + it('show content permissions section if Learning Assistant app is enabled', async () => { const initialState = { models: { @@ -56,6 +83,9 @@ describe('PagesAndResources', () => { await waitFor(() => expect(screen.getByRole('heading', { name: 'Content permissions' })).toBeInTheDocument()); await waitFor(() => expect(screen.getByText('Learning Assistant')).toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); + }); it('show content permissions section if Xpert learning summaries app is enabled', async () => { @@ -89,5 +119,7 @@ describe('PagesAndResources', () => { await waitFor(() => expect(screen.getByRole('heading', { name: 'Content permissions' })).toBeInTheDocument()); await waitFor(() => expect(screen.getByText('Xpert unit summaries')).toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); }); }); From c767becd0aa17fa0fecf00080aeb9b64c5d7e931 Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Wed, 30 Apr 2025 15:41:54 -0400 Subject: [PATCH 2/4] fixup! test: reproduce issue --- .../PagesAndResources.test.jsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/pages-and-resources/PagesAndResources.test.jsx b/src/pages-and-resources/PagesAndResources.test.jsx index e5c46cc343..a2fd374cf1 100644 --- a/src/pages-and-resources/PagesAndResources.test.jsx +++ b/src/pages-and-resources/PagesAndResources.test.jsx @@ -1,23 +1,23 @@ import { screen, waitFor } from '@testing-library/react'; -import { PagesAndResources } from '.'; -import { render } from './utils.test'; import { getConfig, setConfig } from '@edx/frontend-platform'; import { PLUGIN_OPERATIONS, DIRECT_PLUGIN } from '@openedx/frontend-plugin-framework'; +import { PagesAndResources } from '.'; +import { render } from './utils.test'; const mockPlugin = (identifier) => ({ - plugins: [ - { - op: PLUGIN_OPERATIONS.Insert, - widget: { - id: "mock-plugin-1", - type: DIRECT_PLUGIN, - priority: 1, - RenderWidget: () =>
HELLO
, - }, + plugins: [ + { + op: PLUGIN_OPERATIONS.Insert, + widget: { + id: 'mock-plugin-1', + type: DIRECT_PLUGIN, + priority: 1, + RenderWidget: () =>
HELLO
, }, - ], - }) + }, + ], +}); const courseId = 'course-v1:edX+TestX+Test_Course'; @@ -32,7 +32,6 @@ describe('PagesAndResources', () => { }, }); }); - it('doesn\'t show content permissions section if relevant apps are not enabled', async () => { const initialState = { @@ -85,7 +84,6 @@ describe('PagesAndResources', () => { await waitFor(() => expect(screen.getByText('Learning Assistant')).toBeInTheDocument()); await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); - }); it('show content permissions section if Xpert learning summaries app is enabled', async () => { From 461bbb67fc7a20e50d6a6f4699b491f8081341fc Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Wed, 30 Apr 2025 15:46:31 -0400 Subject: [PATCH 3/4] fix: pages and resources plugins not rendered --- src/pages-and-resources/PagesAndResources.jsx | 4 ++-- src/pages-and-resources/PagesAndResources.test.jsx | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages-and-resources/PagesAndResources.jsx b/src/pages-and-resources/PagesAndResources.jsx index 2382be67a5..56ba8a63a7 100644 --- a/src/pages-and-resources/PagesAndResources.jsx +++ b/src/pages-and-resources/PagesAndResources.jsx @@ -92,7 +92,7 @@ const PagesAndResources = ({ courseId }) => { } /> - + } courseId={courseId} /> { (contentPermissionsPages.length > 0 || hasAdditionalCoursePlugin) && ( @@ -100,7 +100,7 @@ const PagesAndResources = ({ courseId }) => {

{intl.formatMessage(messages.contentPermissions)}

- + } /> ) } diff --git a/src/pages-and-resources/PagesAndResources.test.jsx b/src/pages-and-resources/PagesAndResources.test.jsx index a2fd374cf1..0e662e3f86 100644 --- a/src/pages-and-resources/PagesAndResources.test.jsx +++ b/src/pages-and-resources/PagesAndResources.test.jsx @@ -49,7 +49,7 @@ describe('PagesAndResources', () => { ); await waitFor(() => expect(screen.queryByRole('heading', { name: 'Content permissions' })).not.toBeInTheDocument()); - await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).toBeInTheDocument()); await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); }); @@ -82,8 +82,8 @@ describe('PagesAndResources', () => { await waitFor(() => expect(screen.getByRole('heading', { name: 'Content permissions' })).toBeInTheDocument()); await waitFor(() => expect(screen.getByText('Learning Assistant')).toBeInTheDocument()); - await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); - await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).toBeInTheDocument()); }); it('show content permissions section if Xpert learning summaries app is enabled', async () => { @@ -117,7 +117,7 @@ describe('PagesAndResources', () => { await waitFor(() => expect(screen.getByRole('heading', { name: 'Content permissions' })).toBeInTheDocument()); await waitFor(() => expect(screen.getByText('Xpert unit summaries')).toBeInTheDocument()); - await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).not.toBeInTheDocument()); - await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).not.toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_plugin')).toBeInTheDocument()); + await waitFor(() => expect(screen.queryByTestId('additional_course_content_plugin')).toBeInTheDocument()); }); }); From c2b13ede1c9a185885560819ad77654ee4793520 Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Wed, 30 Apr 2025 15:47:03 -0400 Subject: [PATCH 4/4] style: remove unused import --- src/plugin-slots/AdditionalCourseContentPluginSlot/index.tsx | 1 - src/plugin-slots/AdditionalCoursePluginSlot/index.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/plugin-slots/AdditionalCourseContentPluginSlot/index.tsx b/src/plugin-slots/AdditionalCourseContentPluginSlot/index.tsx index 74a6f55b5a..c98ba0c725 100644 --- a/src/plugin-slots/AdditionalCourseContentPluginSlot/index.tsx +++ b/src/plugin-slots/AdditionalCourseContentPluginSlot/index.tsx @@ -1,5 +1,4 @@ import { PluginSlot } from '@openedx/frontend-plugin-framework/dist'; -import React from 'react'; export const AdditionalCourseContentPluginSlot = () => ( (