MM-55468 Ensure custom status emojis exist (#25501)

* MM-55468 Ensure custom status emojis exist

* Fix plugin API unit test

* Print underlying error as detailed error message

* Convert CustomStatusModal tests to React Testing Library and improve a11y

* Don't suggest custom statuses with non-existent emojis

* Silence test error by providing fake translation strings
Этот коммит содержится в:
Harrison Healey
2023-12-08 10:35:15 -05:00
коммит произвёл GitHub
родитель 109f4643c6
Коммит b1e745894b
14 изменённых файлов: 320 добавлений и 115 удалений

Просмотреть файл

@@ -13,6 +13,8 @@ import {get} from 'mattermost-redux/selectors/entities/preferences';
import {getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone';
import {getCurrentUser, getUser} from 'mattermost-redux/selectors/entities/users';
import {getEmojiMap} from 'selectors/emojis';
import {getCurrentMomentForTimezone} from 'utils/timezone';
import {isDateWithinDaysRange, TimeInformation} from 'utils/utils';
@@ -44,11 +46,23 @@ export function isCustomStatusExpired(state: GlobalState, customStatus?: UserCus
return currentTime.isSameOrAfter(expiryTime);
}
export const getRecentCustomStatuses = createSelector(
/**
* getRecentCustomStatuses returns an array of the current user's recent custom statuses with any statuses using
* non-loaded or non-existent emojis filtered out.
*/
export const getRecentCustomStatuses: (state: GlobalState) => UserCustomStatus[] = createSelector(
'getRecentCustomStatuses',
(state: GlobalState) => get(state, Preferences.CATEGORY_CUSTOM_STATUS, Preferences.NAME_RECENT_CUSTOM_STATUSES),
(value) => {
return value ? JSON.parse(value) : [];
getEmojiMap,
(value, emojiMap) => {
if (!value) {
return [];
}
let recentCustomStatuses: UserCustomStatus[] = JSON.parse(value);
recentCustomStatuses = recentCustomStatuses.filter((customStatus) => emojiMap.has(customStatus.emoji));
return recentCustomStatuses;
},
);