Skip to content

Commit

Permalink
Migrate tests for Login to Testing Library and convert showNotificati…
Browse files Browse the repository at this point in the history
…on to a thunk (#26848)

* Migrate tests for Login to Testing Library

* Convert showNotification to a thunk
  • Loading branch information
hmhealey committed Apr 25, 2024
1 parent 60c15c8 commit 80e67ac
Show file tree
Hide file tree
Showing 7 changed files with 342 additions and 404 deletions.
9 changes: 6 additions & 3 deletions webapp/channels/src/actions/notification_actions.jsx
Expand Up @@ -48,7 +48,7 @@ const getNotificationSoundFromChannelMemberAndUser = (member, user) => {
};

/**
* @returns {import('mattermost-redux/types/actions').ThunkActionFunc<Promise<NotificationResult>, GlobalState>}
* @returns {import('mattermost-redux/types/actions').ThunkActionFunc<Promise<import('utils/notifications').NotificationResult>, GlobalState>}
*/
export function sendDesktopNotification(post, msgProps) {
return async (dispatch, getState) => {
Expand Down Expand Up @@ -325,14 +325,17 @@ export function sendDesktopNotification(post, msgProps) {
};
}

/**
* @returns {import('mattermost-redux/types/actions').ThunkActionFunc<Promise<import('utils/notifications').NotificationResult>, GlobalState>}
*/
export const notifyMe = (title, body, channel, teamId, silent, soundName, url) => async (dispatch) => {
// handle notifications in desktop app
if (isDesktopApp()) {
return DesktopApp.dispatchNotification(title, body, channel.id, teamId, silent, soundName, url);
}

try {
return await showNotification({
return await dispatch(showNotification({
title,
body,
requireInteraction: false,
Expand All @@ -341,7 +344,7 @@ export const notifyMe = (title, body, channel, teamId, silent, soundName, url) =
window.focus();
getHistory().push(url);
},
});
}));
} catch (error) {
dispatch(logError(error));
return {status: 'error', reason: 'notification_api', data: String(error)};
Expand Down
118 changes: 0 additions & 118 deletions webapp/channels/src/components/login/__snapshots__/login.test.tsx.snap

This file was deleted.

0 comments on commit 80e67ac

Please sign in to comment.