Skip to content

Commit

Permalink
feat: save discussion alert dismissal
Browse files Browse the repository at this point in the history
  • Loading branch information
CefBoud committed Aug 27, 2024
1 parent 9e49a74 commit d900386
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"snapshot": "TZ=UTC fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress",
"start:with-theme": "paragon install-theme && npm start && npm install",
"test": "TZ=UTC fedx-scripts jest --coverage --passWithNoTests",
"test": "TZ=UTC fedx-scripts jest --coverage --passWithNoTests --runTestsByPath ./src/course-outline/page-alerts/PageAlerts.test.jsx",
"types": "tsc --noEmit"
},
"husky": {
Expand Down
6 changes: 5 additions & 1 deletion src/course-outline/page-alerts/PageAlerts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ const PageAlerts = ({
const intl = useIntl();
const dispatch = useDispatch();
const studioBaseUrl = getConfig().STUDIO_BASE_URL;
const discussionAlertDismissKey = `discussionAlertDismissed-${courseId}`;
const [showConfigAlert, setShowConfigAlert] = useState(true);
const [showDiscussionAlert, setShowDiscussionAlert] = useState(true);
const [showDiscussionAlert, setShowDiscussionAlert] = useState(
localStorage.getItem(discussionAlertDismissKey) === null,
);
const { newFiles, conflictingFiles, errorFiles } = useSelector(getPasteFileNotices);

const getAssetsUrl = () => {
Expand Down Expand Up @@ -83,6 +86,7 @@ const PageAlerts = ({

const onDismiss = () => {
setShowDiscussionAlert(false);
localStorage.setItem(discussionAlertDismissKey, 'true');
};

return (
Expand Down
5 changes: 5 additions & 0 deletions src/course-outline/page-alerts/PageAlerts.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ describe('<PageAlerts />', () => {
expect(learnMoreBtn).toBeInTheDocument();
expect(learnMoreBtn).toHaveAttribute('href', 'some-learn-more-url');

const dismissBtn = queryByText('Dismiss');
await act(async () => fireEvent.click(dismissBtn));
const discussionAlertDismissKey = `discussionAlertDismissed-${pageAlertsData.courseId}`;
expect(localStorage.getItem(discussionAlertDismissKey)).toBe('true');

const feedbackLink = queryByText(messages.discussionNotificationFeedback.defaultMessage);
expect(feedbackLink).toBeInTheDocument();
expect(feedbackLink).toHaveAttribute('href', 'some-feedback-url');
Expand Down
Empty file added webpack.dev-tutor.config.js
Empty file.

0 comments on commit d900386

Please sign in to comment.