Compare commits

...

5 Commits

Author SHA1 Message Date
Asad Ali
1999f406fe fix: convert notification banner to text if accounts url is not set (#362) (#385)
* fix: convert banner to text if ACCOUNT_SETTINGS_URL is not set

* refactor: refactoring

* refactor: rename notificationsBannerLinkMessage to notificationsBannerPreferencesCenterMessage

* refactor: remove lodash usage

* refactor: remove lodash usage
2024-12-10 10:10:37 -05:00
ihor-romaniuk
36c9763587 fix: incorrect message for locking 2024-12-07 12:41:24 +03:30
Adolfo R. Brandes
641a5e27e2 chore: remove extraneous file
Remove a file that was previously added by mistake.
2024-12-06 11:27:49 -03:00
Adolfo R. Brandes
5a9078499e fix: broken download tests
Declaring `browserslist` in package.json exposed a bug in the
download.js tests that wasn't causing failures before (but arguably,
should): one can't use arrow functions to mock constructors because
calling `new` on them doesn't work.  See the NOTE under:

https://jestjs.io/docs/es6-class-mocks#-module-factory-function-must-return-a-function
2024-12-06 11:27:49 -03:00
Adolfo R. Brandes
7ec442bc04 fix: Use browserslist-config
We were installing browserslist-config but not declaring it.  This had
the effect that webpack - and likely others - were not using it.
2024-12-06 11:27:49 -03:00
10 changed files with 80 additions and 27 deletions

11
package-lock.json generated
View File

@@ -57,7 +57,7 @@
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
"@edx/browserslist-config": "^1.2.0",
"@edx/browserslist-config": "^1.3.0",
"@edx/react-unit-test-utils": "3.0.0",
"@edx/reactifex": "^2.1.1",
"@openedx/frontend-build": "14.0.3",
@@ -2048,10 +2048,11 @@
"integrity": "sha512-Dn9CtpC8fovh++Xi4NF5NJoeR9yU2yXZnV9IujxIyGd/dn0Phq5t6dzJVfupwq09mpDnzJv7egA8Znz/3ljO+w=="
},
"node_modules/@edx/browserslist-config": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@edx/browserslist-config/-/browserslist-config-1.2.0.tgz",
"integrity": "sha512-T1+6P52Yx7SMkmoIr4O0Q3m/DyRdrLTJbv1xVijdRLFEq1hqdafEs+Ln1423U5LSkTePb9AOkEtL1G0RZLFl1w==",
"dev": true
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@edx/browserslist-config/-/browserslist-config-1.3.0.tgz",
"integrity": "sha512-qf4BHyjdsx/bVMQmfj1y/MwTZwI5+9DAOul+PJnyO+YhWSwdxtdvXqkOw1wLxqmDtqOPc5bYgDQf8zZfe+aDFA==",
"dev": true,
"license": "AGPL-3.0"
},
"node_modules/@edx/eslint-config": {
"version": "4.0.0",

View File

@@ -6,6 +6,9 @@
"type": "git",
"url": "git+https://github.com/edx/frontend-app-ora-grading.git"
},
"browserslist": [
"extends @edx/browserslist-config"
],
"scripts": {
"build": "fedx-scripts webpack",
"i18n_extract": "fedx-scripts formatjs extract",
@@ -72,7 +75,7 @@
"whatwg-fetch": "^3.6.2"
},
"devDependencies": {
"@edx/browserslist-config": "^1.2.0",
"@edx/browserslist-config": "^1.3.0",
"@edx/react-unit-test-utils": "3.0.0",
"@edx/reactifex": "^2.1.1",
"@openedx/frontend-build": "14.0.3",

View File

@@ -1,10 +1,30 @@
import React from 'react';
import { shallow } from '@edx/react-unit-test-utils';
import { getConfig } from '@edx/frontend-platform';
import { NotificationsBanner } from '.';
jest.mock('@edx/frontend-platform', () => ({
getConfig: jest.fn(),
}));
describe('NotificationsBanner component', () => {
test('snapshots', () => {
afterEach(() => {
jest.clearAllMocks();
});
test('snapshots with empty ACCOUNT_SETTINGS_URL', () => {
getConfig.mockReturnValue({
ACCOUNT_SETTINGS_URL: '',
});
const el = shallow(<NotificationsBanner hide />);
expect(el.snapshot).toMatchSnapshot();
});
test('snapshots with ACCOUNT_SETTINGS_URL', () => {
getConfig.mockReturnValue({
ACCOUNT_SETTINGS_URL: 'http://localhost:1997',
});
const el = shallow(<NotificationsBanner hide />);
expect(el.snapshot).toMatchSnapshot();
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`NotificationsBanner component snapshots 1`] = `
exports[`NotificationsBanner component snapshots with ACCOUNT_SETTINGS_URL 1`] = `
<PageBanner
variant="accentB"
>
@@ -27,3 +27,22 @@ exports[`NotificationsBanner component snapshots 1`] = `
</span>
</PageBanner>
`;
exports[`NotificationsBanner component snapshots with empty ACCOUNT_SETTINGS_URL 1`] = `
<PageBanner
variant="accentB"
>
<span>
<FormattedMessage
defaultMessage="You can now enable notifications for ORA assignments that require staff grading, from the "
description="user info message that user can enable notifications for ORA assignments"
id="ora-grading.NotificationsBanner.Message"
/>
<FormattedMessage
defaultMessage="preferences center."
description="placeholder for the preferences center link"
id="ora-grading.NotificationsBanner.linkMessage"
/>
</span>
</PageBanner>
`;

View File

@@ -10,6 +10,14 @@ export const NotificationsBanner = () => (
<PageBanner variant="accentB">
<span>
<FormattedMessage {...messages.infoMessage} />
{
(
getConfig().ACCOUNT_SETTINGS_URL === null
|| getConfig().ACCOUNT_SETTINGS_URL === undefined
|| getConfig().ACCOUNT_SETTINGS_URL.trim().length === 0
) ? (
<FormattedMessage {...messages.notificationsBannerPreferencesCenterMessage} />
) : (
<Hyperlink
isInline
variant="muted"
@@ -18,8 +26,10 @@ export const NotificationsBanner = () => (
rel="noopener noreferrer"
showLaunchIcon={false}
>
<FormattedMessage {...messages.notificationsBannerLinkMessage} />
<FormattedMessage {...messages.notificationsBannerPreferencesCenterMessage} />
</Hyperlink>
)
}
</span>
</PageBanner>
);

View File

@@ -8,7 +8,7 @@ const messages = defineMessages({
defaultMessage: 'You can now enable notifications for ORA assignments that require staff grading, from the ',
description: 'user info message that user can enable notifications for ORA assignments',
},
notificationsBannerLinkMessage: {
notificationsBannerPreferencesCenterMessage: {
id: 'ora-grading.NotificationsBanner.linkMessage',
defaultMessage: 'preferences center.',
description: 'placeholder for the preferences center link',

View File

@@ -16,7 +16,7 @@ import ReviewError from './ReviewError';
*/
export class LockErrors extends React.Component {
get errorProp() {
if (this.props.errorStatus === ErrorStatuses.forbidden) {
if (this.props.errorStatus === ErrorStatuses.conflict) {
return {
heading: messages.errorLockContestedHeading,
message: messages.errorLockContested,

View File

@@ -41,7 +41,7 @@ describe('LockErrors component', () => {
expect(el.snapshot).toMatchSnapshot();
});
test('snapshot: error with conflicted lock', () => {
el = shallow(<LockErrors {...props} errorStatus={ErrorStatuses.forbidden} />);
el = shallow(<LockErrors {...props} errorStatus={ErrorStatuses.conflict} />);
expect(el.snapshot).toMatchSnapshot();
});
});

View File

@@ -6,9 +6,9 @@ import { RequestKeys } from 'data/constants/requests';
import api from 'data/services/lms/api';
import * as download from './download';
const mockBlobWriter = jest.fn().mockName('BlobWriter');
const mockTextReader = jest.fn().mockName('TextReader');
const mockBlobReader = jest.fn().mockName('BlobReader');
const mockBlobWriter = jest.fn();
const mockTextReader = jest.fn();
const mockBlobReader = jest.fn();
const mockZipAdd = jest.fn();
const mockZipClose = jest.fn();
@@ -21,9 +21,9 @@ jest.mock('@zip.js/zip.js', () => {
close: mockZipClose.mockImplementation(() => Promise.resolve(files)),
files,
})),
BlobWriter: () => mockBlobWriter,
TextReader: () => mockTextReader,
BlobReader: () => mockBlobReader,
BlobWriter: function _() { return mockBlobWriter; },
TextReader: function _() { return mockTextReader; },
BlobReader: function _() { return mockBlobReader; },
};
});