Skip to content

Commit b2a4b9c

Browse files
chore(deps): update dependency @edx/frontend-platform to v8.5.6 (openedx#2995)
* chore(deps): update dependency @edx/frontend-platform to v8.5.6 * chore: misc lint fixes to get build passing --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Braden MacDonald <[email protected]>
1 parent a0d5290 commit b2a4b9c

11 files changed

Lines changed: 57 additions & 167 deletions

File tree

jest.config.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { createConfig } = require('@openedx/frontend-build');
22

3-
module.exports = createConfig('jest', {
3+
const mergedConfig = createConfig('jest', {
44
setupFilesAfterEnv: [
55
'jest-expect-message',
66
'<rootDir>/src/setupTest.js',
@@ -16,6 +16,24 @@ module.exports = createConfig('jest', {
1616
// This alias is used for plugins in the plugins/ folder only.
1717
'^CourseAuthoring/(.*)$': '<rootDir>/src/$1',
1818
},
19-
modulePathIgnorePatterns: [
20-
],
19+
modulePathIgnorePatterns: [],
2120
});
21+
22+
// Override ts-jest config: When transforming .ts files to .js for test purposes,
23+
// don't report TypeScript errors for files in `node_modules/` (or any non-test files).
24+
// Without this, we were seeing TypeScript errors from
25+
// node_modules/@edx/frontend-component-header/dist/studio-header/StudioHeader.tsx
26+
// cause the tests to fail, because they are included in `transformIgnorePatterns`.
27+
// -> If you can delete the following lines and the tests still pass, then feel free
28+
// to remove this whole override. It's only necessary now while StudioHeader has some
29+
// typing issues.
30+
mergedConfig.transform['^.+\\.[tj]sx?$'] = [
31+
'ts-jest',
32+
{
33+
diagnostics: {
34+
exclude: ['!**/*.test.*'],
35+
},
36+
},
37+
];
38+
39+
module.exports = mergedConfig;

package-lock.json

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

src/advanced-settings/data/api.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('courseSettings API', () => {
1717

1818
beforeEach(() => {
1919
jest.clearAllMocks();
20+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked. TODO: convert this test to use `initializeMocks()`
2021
getAuthenticatedHttpClient.mockReturnValue(mockHttpClient);
2122
});
2223

src/authz/data/apiHooks.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ const mockInvalidMultiplePermissions = [
6666

6767
describe('useUserPermissions', () => {
6868
beforeEach(() => {
69+
// TODO: convert this test to use `initializeMocks()` / `testUtils.tsx`
6970
jest.clearAllMocks();
7071
});
7172

7273
it('returns allowed true when permission is valid', async () => {
74+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
7375
getAuthenticatedHttpClient.mockReturnValue({
7476
post: jest.fn().mockResolvedValueOnce({ data: mockValidSinglePermission }),
7577
});
@@ -86,6 +88,7 @@ describe('useUserPermissions', () => {
8688
});
8789

8890
it('returns allowed false when permission is invalid', async () => {
91+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
8992
getAuthenticatedHttpClient.mockReturnValue({
9093
post: jest.fn().mockResolvedValue({ data: mockInvalidSinglePermission }),
9194
});
@@ -101,6 +104,7 @@ describe('useUserPermissions', () => {
101104
});
102105

103106
it('returns allowed true when multiple permissions are valid', async () => {
107+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
104108
getAuthenticatedHttpClient.mockReturnValue({
105109
post: jest.fn().mockResolvedValueOnce({ data: mockValidMultiplePermissions }),
106110
});
@@ -118,6 +122,7 @@ describe('useUserPermissions', () => {
118122
});
119123

120124
it('returns allowed false when multiple permissions are invalid', async () => {
125+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
121126
getAuthenticatedHttpClient.mockReturnValue({
122127
post: jest.fn().mockResolvedValue({ data: mockInvalidMultiplePermissions }),
123128
});
@@ -134,6 +139,7 @@ describe('useUserPermissions', () => {
134139
});
135140

136141
it('returns allowed false when the permission is not included in the server response', async () => {
142+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
137143
getAuthenticatedHttpClient.mockReturnValue({
138144
post: jest.fn().mockResolvedValue({ data: mockEmptyPermissions }),
139145
});
@@ -151,6 +157,7 @@ describe('useUserPermissions', () => {
151157
it('handles error when the API call fails', async () => {
152158
const mockError = new Error('API Error');
153159

160+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
154161
getAuthenticatedHttpClient.mockReturnValue({
155162
post: jest.fn().mockRejectedValue(new Error('API Error')),
156163
});

src/course-outline/data/thunk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function syncDiscussionsTopics(courseId: string) {
9090
try {
9191
await createDiscussionsTopics(courseId);
9292
} catch (error) {
93-
logError(error);
93+
logError(error as string | Error);
9494
}
9595
};
9696
}

src/course-outline/status-bar/LegacyStatusBar.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const queryClient = new QueryClient();
5656

5757
const renderComponent = (props?: Partial<LegacyStatusBarProps>) =>
5858
render(
59-
<AppProvider store={store} messages={{}}>
59+
<AppProvider store={store}>
6060
<QueryClientProvider client={queryClient}>
61-
<IntlProvider locale="en">
61+
<IntlProvider locale="en" messages={{}}>
6262
<LegacyStatusBar
6363
courseId={courseId}
6464
isLoading={isLoading}

src/custom-pages/CustomPages.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { useEffect, useContext, useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import {
33
Routes,
44
Route,
55
useNavigate,
66
Link,
77
} from 'react-router-dom';
88
import { useDispatch, useSelector } from 'react-redux';
9-
import { AppContext, PageWrap } from '@edx/frontend-platform/react';
9+
import { getConfig } from '@edx/frontend-platform';
10+
import { PageWrap } from '@edx/frontend-platform/react';
1011
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
1112
import {
1213
ActionRow,
@@ -57,8 +58,7 @@ const CustomPages = () => {
5758

5859
document.title = getPageHeadTitle(courseDetails?.name || '', intl.formatMessage(messages.heading));
5960

60-
// @ts-expect-error - frontend-platform doesn't have type information
61-
const { config } = useContext(AppContext);
61+
const config = getConfig();
6262
const learningCourseURL = `${config.LEARNING_BASE_URL}/course/${courseId}`;
6363

6464
useEffect(() => {

src/editors/containers/ProblemEditor/data/apiHooks.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const createWrapper = () => {
3434
describe('useValidateInputBlock', () => {
3535
beforeEach(() => {
3636
jest.clearAllMocks();
37+
// @ts-ignore
3738
mockedGetConfig.mockReturnValue({
3839
STUDIO_BASE_URL: 'http://studio.local.openedx.io:8001',
3940
});

src/editors/data/services/cms/utils.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('cms service utils', () => {
99
describe('get', () => {
1010
it('forwards arguments to authenticatedHttpClient().get', () => {
1111
const get = jest.fn((...args) => ({ get: args }));
12+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
1213
getAuthenticatedHttpClient.mockReturnValue({ get });
1314
const args = ['url 1', { headers: {} }] as const;
1415
expect(utils.get(...args)).toEqual(get(...args));
@@ -17,6 +18,7 @@ describe('cms service utils', () => {
1718
describe('post', () => {
1819
it('forwards arguments to authenticatedHttpClient().post', () => {
1920
const post = jest.fn((...args) => ({ post: args }));
21+
// @ts-ignore since `getAuthenticatedHttpClient` is mocked.
2022
getAuthenticatedHttpClient.mockReturnValue({ post });
2123
const args = ['url 2', { headers: {} }] as const;
2224
expect(utils.post(...args)).toEqual(post(...args));

0 commit comments

Comments
 (0)