diff --git a/webapp/src/components/messages/cloudMessage.test.tsx b/webapp/src/components/messages/cloudMessage.test.tsx index 77f4f065c..5a5ae54de 100644 --- a/webapp/src/components/messages/cloudMessage.test.tsx +++ b/webapp/src/components/messages/cloudMessage.test.tsx @@ -4,7 +4,6 @@ import React from 'react' import {Provider as ReduxProvider} from 'react-redux' - import {render, screen} from '@testing-library/react' import {mocked} from 'jest-mock' import userEvent from '@testing-library/user-event' @@ -30,29 +29,27 @@ describe('components/messages/CloudMessage', () => { jest.clearAllMocks() }) - console.log("Cloud message test") const mockedUtils = mocked(Utils, true) const mockStore = configureStore([]) test('plugin mode, no display', () => { - console.log("Cloud message test - no display") mockedUtils.isFocalboardPlugin.mockReturnValue(true) - const me: IUser = { + const me: IUser = { id: 'user-id-1', username: 'username_1', email: '', props: {}, create_at: 0, update_at: 0, - is_bot: false + is_bot: false, } const state = { users: { me, }, } - + const store = mockStore(state) const component = wrapIntl( @@ -66,18 +63,16 @@ describe('components/messages/CloudMessage', () => { }) test('not plugin mode, close message', () => { - console.log("Cloud message test - property set") - - const me: IUser = { + const me: IUser = { id: 'user-id-1', username: 'username_1', email: '', props: { - focalboard_cloudMessageCanceled: 'true' + focalboard_cloudMessageCanceled: 'true', }, create_at: 0, update_at: 0, - is_bot: false + is_bot: false, } const state = { users: { @@ -98,16 +93,14 @@ describe('components/messages/CloudMessage', () => { }) test('not plugin mode, show message, close message', () => { - console.log("Cloud message test - propertynot set") - - const me: IUser = { + const me: IUser = { id: 'user-id-1', username: 'username_1', email: '', props: {}, create_at: 0, update_at: 0, - is_bot: false + is_bot: false, } const state = { users: { @@ -130,7 +123,7 @@ describe('components/messages/CloudMessage', () => { userEvent.click(buttonElement) expect(mockedOctoClient.patchUserConfig).toBeCalledWith('user-id-1', { updatedFields: { - 'focalboard_cloudMessageCanceled': 'true', + focalboard_cloudMessageCanceled: 'true', }, }) }) diff --git a/webapp/src/components/messages/cloudMessage.tsx b/webapp/src/components/messages/cloudMessage.tsx index 4fbbc3113..d850686ed 100644 --- a/webapp/src/components/messages/cloudMessage.tsx +++ b/webapp/src/components/messages/cloudMessage.tsx @@ -4,18 +4,16 @@ import React from 'react' import {useIntl, FormattedMessage} from 'react-intl' -import {getCloudMessageCanceled} from '../../store/users' import {Utils} from '../../utils' import IconButton from '../../widgets/buttons/iconButton' import Button from '../../widgets/buttons/button' import CloseIcon from '../../widgets/icons/close' - import {useAppSelector, useAppDispatch} from '../../store/hooks' import octoClient from '../../octoClient' import {IUser, UserConfigPatch} from '../../user' -import {getMe, patchProps} from '../../store/users' +import {getMe, patchProps, getCloudMessageCanceled} from '../../store/users' import CompassIcon from '../../widgets/icons/compassIcon' import TelemetryClient, {TelemetryCategory, TelemetryActions} from '../../telemetry/telemetryClient' @@ -24,7 +22,6 @@ import './cloudMessage.scss' const signupURL = 'http://mattermost.com/pricing' const displayAfter = (1000 * 60 * 60 * 24) //24 hours - const CloudMessage = React.memo(() => { const intl = useIntl() const dispatch = useAppDispatch() @@ -36,7 +33,7 @@ const CloudMessage = React.memo(() => { defaultMessage: 'Close dialog', }) - const onClose = async() => { + const onClose = async () => { if (me) { const patch: UserConfigPatch = { updatedFields: { @@ -51,11 +48,11 @@ const CloudMessage = React.memo(() => { } } - if(me){ + if (me) { const installTime = Date.now() - me.create_at - if(Utils.isFocalboardPlugin() || cloudMessageCanceled || installTime < displayAfter){ + if (Utils.isFocalboardPlugin() || cloudMessageCanceled || installTime < displayAfter) { return null - } + } } return ( @@ -67,7 +64,7 @@ const CloudMessage = React.memo(() => { />