Skip to content

Commit 08f550b

Browse files
committed
Merge branch 'master' into rpenido/fal-4068/add-unit-collections-support
2 parents a1bc214 + 6818542 commit 08f550b

38 files changed

+374
-157
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"@openedx-plugins/course-app-wiki": "file:plugins/course-apps/wiki",
6161
"@openedx-plugins/course-app-xpert_unit_summary": "file:plugins/course-apps/xpert_unit_summary",
6262
"@openedx/frontend-build": "^14.3.3",
63-
"@openedx/frontend-slot-footer": "^1.2.0",
6463
"@openedx/frontend-plugin-framework": "^1.6.0",
64+
"@openedx/frontend-slot-footer": "^1.2.0",
6565
"@openedx/paragon": "^22.16.0",
6666
"@redux-devtools/extension": "^3.3.0",
6767
"@reduxjs/toolkit": "1.9.7",

src/course-outline/CourseOutline.test.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ const courseId = '123';
6868

6969
window.HTMLElement.prototype.scrollIntoView = jest.fn();
7070

71-
const clipboardBroadcastChannelMock = {
72-
postMessage: jest.fn(),
73-
close: jest.fn(),
74-
};
75-
76-
global.BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
77-
7871
jest.mock('react-router-dom', () => ({
7972
...jest.requireActual('react-router-dom'),
8073
useLocation: jest.fn(),

src/course-outline/subsection-card/SubsectionCard.test.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ jest.mock('react-router-dom', () => ({
2121
}),
2222
}));
2323

24-
const clipboardBroadcastChannelMock = {
25-
postMessage: jest.fn(),
26-
close: jest.fn(),
27-
};
28-
29-
global.BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
30-
3124
const unit = {
3225
id: 'unit-1',
3326
};

src/course-outline/unit-card/UnitCard.test.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ const unit = {
4747

4848
const queryClient = new QueryClient();
4949

50-
const clipboardBroadcastChannelMock = {
51-
postMessage: jest.fn(),
52-
close: jest.fn(),
53-
};
54-
55-
global.BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
56-
5750
const renderComponent = (props) => render(
5851
<AppProvider store={store}>
5952
<QueryClientProvider client={queryClient}>

src/course-unit/CourseUnit.test.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ jest.mock('react-router-dom', () => ({
9393
useNavigate: () => mockedUsedNavigate,
9494
}));
9595

96-
const clipboardBroadcastChannelMock = {
97-
postMessage: jest.fn(),
98-
close: jest.fn(),
99-
};
100-
101-
global.BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
102-
10396
/**
10497
* Simulates receiving a post message event for testing purposes.
10598
* This can be used to mimic events like deletion or other actions

src/course-unit/sidebar/components/sidebar-footer/ActionButtons.test.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ let axiosMock;
2222
let queryClient;
2323
const courseId = '123';
2424

25-
const clipboardBroadcastChannelMock = {
26-
postMessage: jest.fn(),
27-
close: jest.fn(),
28-
};
29-
30-
global.BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
31-
3225
const renderComponent = (props = {}) => render(
3326
<AppProvider store={store}>
3427
<IntlProvider locale="en">

src/course-unit/xblock-container-iframe/hooks/tests/hooks.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { IntlProvider } from '@edx/frontend-platform/i18n';
66
import { Provider } from 'react-redux';
77

88
import { messageTypes } from '../../../constants';
9-
import { mockBroadcastChannel } from '../../../../generic/data/api.mock';
109
import initializeStore from '../../../../store';
1110
import { useMessageHandlers } from '..';
1211

@@ -20,8 +19,6 @@ jest.mock('@edx/frontend-platform/logging', () => ({
2019
logError: jest.fn(),
2120
}));
2221

23-
mockBroadcastChannel();
24-
2522
describe('useMessageHandlers', () => {
2623
let handlers;
2724
let result;

src/editors/containers/EditorContainer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { useEditorContext } from '../../EditorContext';
1818
import TitleHeader from './components/TitleHeader';
1919
import * as hooks from './hooks';
2020
import messages from './messages';
21-
import { parseErrorMsg } from '../../../library-authoring/add-content/AddContentContainer';
21+
import { parseErrorMsg } from '../../../library-authoring/add-content/AddContent';
2222
import libraryMessages from '../../../library-authoring/add-content/messages';
2323

2424
import './index.scss';

src/generic/clipboard/hooks/useClipboard.test.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../../../__mocks__';
88
import { initializeMocks, makeWrapper } from '../../../testUtils';
99
import { getClipboardUrl } from '../../data/api';
10-
import useClipboard from './useClipboard';
10+
import useClipboard, { _testingOverrideBroadcastChannel } from './useClipboard';
1111

1212
initializeMocks();
1313

@@ -16,13 +16,14 @@ let mockShowToast: jest.Mock;
1616

1717
const unitId = 'block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_0270f6de40fc';
1818
const xblockId = 'block-v1:edX+DemoX+Demo_Course+type@html+block@030e35c4756a4ddc8d40b95fbbfff4d4';
19+
20+
let broadcastMockListener: (x: unknown) => void | undefined;
1921
const clipboardBroadcastChannelMock = {
20-
postMessage: jest.fn(),
21-
close: jest.fn(),
22-
onmessage: jest.fn(),
22+
postMessage: (message: unknown) => { broadcastMockListener(message); },
23+
addEventListener: (_eventName: string, handler: typeof broadcastMockListener) => { broadcastMockListener = handler; },
24+
removeEventListener: jest.fn(),
2325
};
24-
25-
(global as any).BroadcastChannel = jest.fn(() => clipboardBroadcastChannelMock);
26+
_testingOverrideBroadcastChannel(clipboardBroadcastChannelMock as any);
2627

2728
describe('useClipboard', () => {
2829
beforeEach(async () => {
@@ -88,14 +89,14 @@ describe('useClipboard', () => {
8889
describe('broadcast channel message handling', () => {
8990
it('updates states correctly on receiving a broadcast message', async () => {
9091
const { result, rerender } = renderHook(() => useClipboard(true), { wrapper: makeWrapper() });
91-
clipboardBroadcastChannelMock.onmessage({ data: clipboardUnit });
92+
clipboardBroadcastChannelMock.postMessage({ data: clipboardUnit });
9293

9394
rerender();
9495

9596
expect(result.current.showPasteUnit).toBe(true);
9697
expect(result.current.showPasteXBlock).toBe(false);
9798

98-
clipboardBroadcastChannelMock.onmessage({ data: clipboardXBlock });
99+
clipboardBroadcastChannelMock.postMessage({ data: clipboardXBlock });
99100
rerender();
100101

101102
expect(result.current.showPasteUnit).toBe(false);

0 commit comments

Comments
 (0)