MM-49862 - remove no longer needed webapp calls to action and pulsating dots (#22699)
* MM-49862 - remove no longer needed webapp calls to action and pulsating dots * fix snapshots * improve function logic based on pr comments * fix unit tests --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9736304633
Коммит
6919761122
@@ -11,6 +11,7 @@ import {makeGetCustomStatus, getRecentCustomStatuses, isCustomStatusEnabled, sho
|
||||
|
||||
import {TestHelper} from 'utils/test_helper';
|
||||
import {CustomStatusDuration} from '@mattermost/types/users';
|
||||
import {addTimeToTimestamp, TimeInformation} from 'utils/utils';
|
||||
|
||||
jest.mock('mattermost-redux/selectors/entities/users');
|
||||
jest.mock('mattermost-redux/selectors/entities/general');
|
||||
@@ -86,6 +87,7 @@ describe('isCustomStatusEnabled', () => {
|
||||
});
|
||||
|
||||
describe('showStatusDropdownPulsatingDot and showPostHeaderUpdateStatusButton', () => {
|
||||
const user = TestHelper.getUserMock();
|
||||
const preference = {
|
||||
myPreference: {
|
||||
value: '',
|
||||
@@ -104,4 +106,31 @@ describe('showStatusDropdownPulsatingDot and showPostHeaderUpdateStatusButton',
|
||||
(PreferenceSelectors.get as jest.Mock).mockReturnValue(preference.myPreference.value);
|
||||
expect(showPostHeaderUpdateStatusButton(store.getState())).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false if user was created less than seven days before from today', async () => {
|
||||
const store = await configureStore();
|
||||
(PreferenceSelectors.get as jest.Mock).mockReturnValue(preference.myPreference.value);
|
||||
const todayTimestamp = new Date().getTime();
|
||||
|
||||
// set the user create date to 6 days in the past from today
|
||||
const todayMinusSixDays = addTimeToTimestamp(todayTimestamp, TimeInformation.DAYS, 6, TimeInformation.PAST);
|
||||
const newUser = {...user, create_at: todayMinusSixDays};
|
||||
newUser.props.customStatus = JSON.stringify(customStatus);
|
||||
(UserSelectors.getCurrentUser as jest.Mock).mockReturnValue(newUser);
|
||||
expect(showStatusDropdownPulsatingDot(store.getState())).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return true if user was created more than seven days before from today', async () => {
|
||||
const store = await configureStore();
|
||||
preference.myPreference.value = JSON.stringify({[Preferences.CUSTOM_STATUS_MODAL_VIEWED]: false});
|
||||
(PreferenceSelectors.get as jest.Mock).mockReturnValue(preference.myPreference.value);
|
||||
const todayTimestamp = new Date().getTime();
|
||||
|
||||
// set the user create date to 8 days in the past from today
|
||||
const todayMinusEightDays = addTimeToTimestamp(todayTimestamp, TimeInformation.DAYS, 8, TimeInformation.PAST);
|
||||
const newUser = {...user, create_at: todayMinusEightDays};
|
||||
newUser.props.customStatus = JSON.stringify(customStatus);
|
||||
(UserSelectors.getCurrentUser as jest.Mock).mockReturnValue(newUser);
|
||||
expect(showStatusDropdownPulsatingDot(store.getState())).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,8 @@ import {get} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {Preferences} from 'mattermost-redux/constants';
|
||||
import {CustomStatusDuration, UserCustomStatus} from '@mattermost/types/users';
|
||||
|
||||
import {isDateWithinDaysRange, TimeInformation} from 'utils/utils';
|
||||
|
||||
import {GlobalState} from 'types/store';
|
||||
import {getCurrentUserTimezone} from 'selectors/general';
|
||||
import {getCurrentMomentForTimezone} from 'utils/timezone';
|
||||
@@ -56,9 +58,12 @@ export function isCustomStatusEnabled(state: GlobalState) {
|
||||
}
|
||||
|
||||
function showCustomStatusPulsatingDotAndPostHeader(state: GlobalState) {
|
||||
// only show this for users after the first seven days
|
||||
const currentUser = getCurrentUser(state);
|
||||
const hasUserCreationMoreThanSevenDays = isDateWithinDaysRange(currentUser?.create_at, 7, TimeInformation.FUTURE);
|
||||
const customStatusTutorialState = get(state, Preferences.CATEGORY_CUSTOM_STATUS, Preferences.NAME_CUSTOM_STATUS_TUTORIAL_STATE);
|
||||
const modalAlreadyViewed = customStatusTutorialState && JSON.parse(customStatusTutorialState)[Preferences.CUSTOM_STATUS_MODAL_VIEWED];
|
||||
return !modalAlreadyViewed;
|
||||
return !modalAlreadyViewed && hasUserCreationMoreThanSevenDays;
|
||||
}
|
||||
|
||||
export function showStatusDropdownPulsatingDot(state: GlobalState) {
|
||||
|
||||
Ссылка в новой задаче
Block a user