Skip to content

Commit 652bfff

Browse files
author
Ahtesham Quraish
committed
fix: merge with main branch
2 parents cced750 + 8326257 commit 652bfff

File tree

247 files changed

+3986
-4378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+3986
-4378
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
"@edx/typescript-config": "^1.0.1",
108108
"@testing-library/jest-dom": "^6.6.3",
109109
"@testing-library/react": "^16.2.0",
110-
"@testing-library/user-event": "^13.2.1",
110+
"@testing-library/user-event": "^14.6.1",
111111
"@types/lodash": "^4.17.17",
112112
"@types/react": "^18",
113113
"@types/react-dom": "^18",
114-
"axios-mock-adapter": "1.22.0",
114+
"axios-mock-adapter": "2.1.0",
115115
"eslint-import-resolver-webpack": "^0.13.8",
116116
"fetch-mock-jest": "^1.5.1",
117117
"jest-canvas-mock": "^2.5.2",

plugins/course-apps/live/BbbSettings.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ describe('BBB Settings', () => {
124124
);
125125

126126
test('free plans message is visible when free plan is selected', async () => {
127+
const user = userEvent.setup();
127128
await mockStore({ emailSharing: true, isFreeTier: true });
128129
renderComponent();
129130
const spinner = getByRole(container, 'status');
130131
await waitForElementToBeRemoved(spinner);
131132
const dropDown = container.querySelector('select[name="tierType"]');
132-
userEvent.selectOptions(
133+
await user.selectOptions(
133134
dropDown,
134135
getByRole(dropDown, 'option', { name: 'Free' }),
135136
);

src/accessibility-page/AccessibilityBody/AccessibilityBody.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import { injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
3+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
44
import { Hyperlink, MailtoLink, Stack } from '@openedx/paragon';
55

66
import messages from './messages';
@@ -95,4 +95,4 @@ AccessibilityBody.propTypes = {
9595
email: PropTypes.string.isRequired,
9696
};
9797

98-
export default injectIntl(AccessibilityBody);
98+
export default AccessibilityBody;

src/accessibility-page/AccessibilityForm/AccessibilityForm.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
injectIntl, FormattedMessage, intlShape, FormattedDate, FormattedTime,
4+
FormattedMessage, FormattedDate, FormattedTime, useIntl,
55
} from '@edx/frontend-platform/i18n';
66
import {
77
ActionRow, Alert, Form, Stack, StatefulButton,
@@ -15,9 +15,8 @@ import messages from './messages';
1515

1616
const AccessibilityForm = ({
1717
accessibilityEmail,
18-
// injected
19-
intl,
2018
}) => {
19+
const intl = useIntl();
2120
const {
2221
errors,
2322
values,
@@ -139,8 +138,6 @@ const AccessibilityForm = ({
139138

140139
AccessibilityForm.propTypes = {
141140
accessibilityEmail: PropTypes.string.isRequired,
142-
// injected
143-
intl: intlShape.isRequired,
144141
};
145142

146-
export default injectIntl(AccessibilityForm);
143+
export default AccessibilityForm;

src/accessibility-page/AccessibilityForm/AccessibilityForm.test.jsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
render,
3-
act,
43
screen,
54
} from '@testing-library/react';
65
import userEvent from '@testing-library/user-event';
@@ -74,22 +73,24 @@ describe('<AccessibilityPolicyForm />', () => {
7473
describe('statusAlert', () => {
7574
let formSections;
7675
let submitButton;
76+
let user;
7777
beforeEach(async () => {
78+
user = userEvent.setup();
7879
renderComponent();
7980
formSections = screen.getAllByRole('textbox');
80-
await act(async () => {
81-
userEvent.type(formSections[0], '[email protected]');
82-
userEvent.type(formSections[1], 'test name');
83-
userEvent.type(formSections[2], 'feedback message');
84-
});
81+
82+
await user.type(formSections[0], '[email protected]');
83+
await user.type(formSections[1], 'test name');
84+
await user.type(formSections[2], 'feedback message');
85+
8586
submitButton = screen.getByText(messages.accessibilityPolicyFormSubmitLabel.defaultMessage);
8687
});
8788

8889
it('shows correct success message', async () => {
8990
axiosMock.onPost(getZendeskrUrl()).reply(200);
90-
await act(async () => {
91-
userEvent.click(submitButton);
92-
});
91+
92+
await user.click(submitButton);
93+
9394
const { savingStatus } = store.getState().accessibilityPage;
9495
expect(savingStatus).toEqual(RequestStatus.SUCCESSFUL);
9596

@@ -104,9 +105,9 @@ describe('<AccessibilityPolicyForm />', () => {
104105

105106
it('shows correct rate limiting message', async () => {
106107
axiosMock.onPost(getZendeskrUrl()).reply(429);
107-
await act(async () => {
108-
userEvent.click(submitButton);
109-
});
108+
109+
await user.click(submitButton);
110+
110111
const { savingStatus } = store.getState().accessibilityPage;
111112
expect(savingStatus).toEqual(RequestStatus.FAILED);
112113

@@ -123,23 +124,24 @@ describe('<AccessibilityPolicyForm />', () => {
123124
describe('input validation', () => {
124125
let formSections;
125126
let submitButton;
127+
let user;
126128
beforeEach(async () => {
129+
user = userEvent.setup();
127130
renderComponent();
128131
formSections = screen.getAllByRole('textbox');
129-
await act(async () => {
130-
userEvent.type(formSections[0], '[email protected]');
131-
userEvent.type(formSections[1], 'test name');
132-
userEvent.type(formSections[2], 'feedback message');
133-
});
132+
133+
await user.type(formSections[0], '[email protected]');
134+
await user.type(formSections[1], 'test name');
135+
await user.type(formSections[2], 'feedback message');
136+
134137
submitButton = screen.getByText(messages.accessibilityPolicyFormSubmitLabel.defaultMessage);
135138
});
136139

137140
it('adds validation checking on each input field', async () => {
138-
await act(async () => {
139-
userEvent.clear(formSections[0]);
140-
userEvent.clear(formSections[1]);
141-
userEvent.clear(formSections[2]);
142-
});
141+
await user.clear(formSections[0]);
142+
await user.clear(formSections[1]);
143+
await user.clear(formSections[2]);
144+
143145
const emailError = screen.getByTestId('error-feedback-email');
144146
expect(emailError).toBeVisible();
145147

@@ -151,12 +153,10 @@ describe('<AccessibilityPolicyForm />', () => {
151153
});
152154

153155
it('sumbit button is disabled when trying to submit with all empty fields', async () => {
154-
await act(async () => {
155-
userEvent.clear(formSections[0]);
156-
userEvent.clear(formSections[1]);
157-
userEvent.clear(formSections[2]);
158-
userEvent.click(submitButton);
159-
});
156+
await user.clear(formSections[0]);
157+
await user.clear(formSections[1]);
158+
await user.clear(formSections[2]);
159+
await user.click(submitButton);
160160

161161
expect(submitButton.closest('button')).toBeDisabled();
162162
});
Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
2+
import { useIntl } from '@edx/frontend-platform/i18n';
33
import { Helmet } from 'react-helmet';
44
import { Container } from '@openedx/paragon';
55
import { StudioFooterSlot } from '@edx/frontend-component-footer';
@@ -11,32 +11,29 @@ import AccessibilityForm from './AccessibilityForm';
1111

1212
import { COMMUNITY_ACCESSIBILITY_LINK, ACCESSIBILITY_EMAIL } from './constants';
1313

14-
const AccessibilityPage = ({
15-
// injected
16-
intl,
17-
}) => (
18-
<>
19-
<Helmet>
20-
<title>
21-
{intl.formatMessage(messages.pageTitle, {
22-
siteName: process.env.SITE_NAME,
23-
})}
24-
</title>
25-
</Helmet>
26-
<Header isHiddenMainMenu />
27-
<Container size="xl" classNamae="px-4">
28-
<AccessibilityBody
29-
{...{ email: ACCESSIBILITY_EMAIL, communityAccessibilityLink: COMMUNITY_ACCESSIBILITY_LINK }}
30-
/>
31-
<AccessibilityForm accessibilityEmail={ACCESSIBILITY_EMAIL} />
32-
</Container>
33-
<StudioFooterSlot />
34-
</>
35-
);
36-
37-
AccessibilityPage.propTypes = {
38-
// injected
39-
intl: intlShape.isRequired,
14+
const AccessibilityPage = () => {
15+
const intl = useIntl();
16+
return (
17+
<>
18+
<Helmet>
19+
<title>
20+
{intl.formatMessage(messages.pageTitle, {
21+
siteName: process.env.SITE_NAME,
22+
})}
23+
</title>
24+
</Helmet>
25+
<Header isHiddenMainMenu />
26+
<Container size="xl" classNamae="px-4">
27+
<AccessibilityBody
28+
{...{ email: ACCESSIBILITY_EMAIL, communityAccessibilityLink: COMMUNITY_ACCESSIBILITY_LINK }}
29+
/>
30+
<AccessibilityForm accessibilityEmail={ACCESSIBILITY_EMAIL} />
31+
</Container>
32+
<StudioFooterSlot />
33+
</>
34+
);
4035
};
4136

42-
export default injectIntl(AccessibilityPage);
37+
AccessibilityPage.propTypes = {};
38+
39+
export default AccessibilityPage;

src/accessibility-page/data/thunks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ function submitAccessibilityForm({ email, name, message }) {
1010
await postAccessibilityForm({ email, name, message });
1111
dispatch(updateSavingStatus({ status: RequestStatus.SUCCESSFUL }));
1212
} catch (error) {
13+
/* istanbul ignore else */
1314
if (error.response && error.response.status === 429) {
1415
dispatch(updateSavingStatus({ status: RequestStatus.FAILED }));
1516
} else {
17+
/* istanbul ignore next */
1618
dispatch(updateSavingStatus({ status: RequestStatus.SUCCESSFUL }));
1719
}
1820
}
Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,57 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { ActionRow, AlertModal, Button } from '@openedx/paragon';
4-
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
4+
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
55

66
import ModalErrorListItem from './ModalErrorListItem';
77
import messages from './messages';
88

99
const ModalError = ({
10-
intl, isError, handleUndoChanges, showErrorModal, errorList, settingsData,
11-
}) => (
12-
<AlertModal
13-
title={intl.formatMessage(messages.modalErrorTitle)}
14-
isOpen={isError}
15-
variant="danger"
16-
footerNode={(
17-
<ActionRow>
18-
<Button
19-
variant="tertiary"
20-
onClick={() => showErrorModal(!isError)}
21-
>
22-
{intl.formatMessage(messages.modalErrorButtonChangeManually)}
23-
</Button>
24-
<Button onClick={handleUndoChanges}>
25-
{intl.formatMessage(messages.modalErrorButtonUndoChanges)}
26-
</Button>
27-
</ActionRow>
10+
isError, handleUndoChanges, showErrorModal, errorList, settingsData,
11+
}) => {
12+
const intl = useIntl();
13+
return (
14+
<AlertModal
15+
title={intl.formatMessage(messages.modalErrorTitle)}
16+
isOpen={isError}
17+
variant="danger"
18+
footerNode={(
19+
<ActionRow>
20+
<Button
21+
variant="tertiary"
22+
onClick={() => showErrorModal(!isError)}
23+
>
24+
{intl.formatMessage(messages.modalErrorButtonChangeManually)}
25+
</Button>
26+
<Button onClick={handleUndoChanges}>
27+
{intl.formatMessage(messages.modalErrorButtonUndoChanges)}
28+
</Button>
29+
</ActionRow>
2830
)}
29-
>
30-
<p>
31-
<FormattedMessage
32-
id="course-authoring.advanced-settings.modal.error.description"
33-
defaultMessage="There was {errorCounter} while trying to save the course settings in the database.
31+
>
32+
<p>
33+
<FormattedMessage
34+
id="course-authoring.advanced-settings.modal.error.description"
35+
defaultMessage="There was {errorCounter} while trying to save the course settings in the database.
3436
Please check the following validation feedbacks and reflect them in your course settings:"
35-
values={{ errorCounter: <strong>{errorList.length} validation error </strong> }}
36-
/>
37-
</p>
38-
<hr />
39-
<ul className="p-0">
40-
{errorList.map((settingName) => (
41-
<ModalErrorListItem
42-
key={settingName.key}
43-
settingName={settingName}
44-
settingsData={settingsData}
37+
values={{ errorCounter: <strong>{errorList.length} validation error </strong> }}
4538
/>
46-
))}
47-
</ul>
48-
</AlertModal>
49-
);
39+
</p>
40+
<hr />
41+
<ul className="p-0">
42+
{errorList.map((settingName) => (
43+
<ModalErrorListItem
44+
key={settingName.key}
45+
settingName={settingName}
46+
settingsData={settingsData}
47+
/>
48+
))}
49+
</ul>
50+
</AlertModal>
51+
);
52+
};
5053

5154
ModalError.propTypes = {
52-
intl: intlShape.isRequired,
5355
isError: PropTypes.bool.isRequired,
5456
handleUndoChanges: PropTypes.func.isRequired,
5557
showErrorModal: PropTypes.func.isRequired,
@@ -60,4 +62,4 @@ ModalError.propTypes = {
6062
settingsData: PropTypes.shape({}).isRequired,
6163
};
6264

63-
export default injectIntl(ModalError);
65+
export default ModalError;

src/advanced-settings/setting-card/SettingCard.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { InfoOutline, Warning } from '@openedx/paragon/icons';
1212
import PropTypes from 'prop-types';
1313
import { capitalize } from 'lodash';
14-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
14+
import { useIntl } from '@edx/frontend-platform/i18n';
1515
import TextareaAutosize from 'react-textarea-autosize';
1616

1717
import messages from './messages';
@@ -25,9 +25,8 @@ const SettingCard = ({
2525
saveSettingsPrompt,
2626
isEditableState,
2727
setIsEditableState,
28-
// injected
29-
intl,
3028
}) => {
29+
const intl = useIntl();
3130
const { deprecated, help, displayName } = settingData;
3231
const initialValue = JSON.stringify(settingData.value, null, 4);
3332
const [isOpen, open, close] = useToggle(false);
@@ -115,7 +114,6 @@ const SettingCard = ({
115114
};
116115

117116
SettingCard.propTypes = {
118-
intl: intlShape.isRequired,
119117
settingData: PropTypes.shape({
120118
deprecated: PropTypes.bool,
121119
help: PropTypes.string,
@@ -137,4 +135,4 @@ SettingCard.propTypes = {
137135
setIsEditableState: PropTypes.func.isRequired,
138136
};
139137

140-
export default injectIntl(SettingCard);
138+
export default SettingCard;

0 commit comments

Comments
 (0)