Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Eliminate yarn test spam #1024

Merged
merged 13 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/profile_popover/profile_popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class ProfilePopover extends React.Component {
delete popoverProps.hasMention;
delete popoverProps.dispatch;
delete popoverProps.enableWebrtc;
delete popoverProps.showEmailAddress;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Injected by the connector but wasn't removed, like enableWebrtc, and ended up incorrectly as a DOM property.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are not using showEmailAddress at all, so, the solution would be remove that from the connect function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, I like that better -- somehow, I thought this was being passed in via a plugin, but you're right that it's only part of the pluggable unit tests.


let webrtc;
const userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
Expand Down
4 changes: 2 additions & 2 deletions components/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export default class Sidebar extends React.PureComponent {
/**
* Current team object
*/
currentTeam: PropTypes.object.isRequired,
currentTeam: PropTypes.object,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code handles these not being present.


/**
* Current user object
*/
currentUser: PropTypes.object.isRequired,
currentUser: PropTypes.object,

/**
* Number of unread mentions/messages
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"image-webpack-loader": "3.6.0",
"imports-loader": "0.7.1",
"jest": "22.1.4",
"jest-canvas-mock": "1.0.2",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the doughtnut chart doesn't throw errors about getContext not being defined.

"jest-cli": "22.1.4",
"jquery-deferred": "0.3.1",
"json-loader": "0.5.7",
Expand Down Expand Up @@ -141,6 +142,7 @@
"transformIgnorePatterns": [
"node_modules/(?!react-native|react-router)"
],
"setupFiles": ["jest-canvas-mock"],
"setupTestFrameworkScriptFile": "<rootDir>/tests/setup.js",
"testURL": "http:https://localhost:8065"
},
Expand Down
7 changes: 6 additions & 1 deletion store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function configureStore(initialState) {
const storage = localforage;
const KEY_PREFIX = 'reduxPersist:';

localforage.ready(() => {
localforage.ready().then(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See localForage/localForage#722 for more details.

const persistor = persistStore(store, {storage, keyPrefix: KEY_PREFIX, ...options}, () => {
store.dispatch({
type: General.STORE_REHYDRATION_COMPLETE,
Expand Down Expand Up @@ -135,6 +135,11 @@ export default function configureStore(initialState) {
});
}
});
}).catch((error) => {
store.dispatch({
type: General.STORE_REHYDRATION_FAILED,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a pending PR to add this constant to mattermost-redux... if we think we need it. No one is going to handle it right now. Feedback requested!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I prefer simply a log message for now. Anyway, I think it must be in the webapp redux flow, not in the mattermost-redux one. Because all the storage thing is handle independently from RN app and webapp.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move the constant locally -- the log message would defeat the point of this change, at present ;P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha, you are completely right, I'm an idiot :)

error,
});
});
},
persistOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ exports[`components/channel_notifications_modal/ChannelNotificationsModal should
/>
<NotificationSection
expand={false}
memberNotificationLevel="all"
onChange={[Function]}
onSubmit={[Function]}
onUpdateSection={[Function]}
Expand Down
4 changes: 2 additions & 2 deletions tests/components/analytics/doughnut_chart.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('components/analytics/doughnut_chart.jsx', () => {
/>
);

expect(Chart).toBeCalledWith(null, {data, options: {}, type: 'doughnut'});
expect(Chart).toBeCalledWith(expect.anything(), {data, options: {}, type: 'doughnut'});
expect(wrapper).toMatchSnapshot();
});

Expand All @@ -51,7 +51,7 @@ describe('components/analytics/doughnut_chart.jsx', () => {
data={data}
/>
);
expect(Chart).toBeCalledWith(null, {data, options: {}, type: 'doughnut'});
expect(Chart).toBeCalledWith(expect.anything(), {data, options: {}, type: 'doughnut'});
expect(wrapper).toMatchSnapshot();
});

Expand Down
60 changes: 52 additions & 8 deletions tests/components/channel_notifications_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
show: true,
onHide: () => {}, //eslint-disable-line no-empty-function
channel: {id: 'channel_id', display_name: 'channel_display_name'},
channelMember: {notify_props: {desktop: NotificationLevels.ALL}},
currentUser: {id: 'current_user_id', notify_props: {desktop: NotificationLevels.ALL}},
channelMember: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required props.

notify_props: {
desktop: NotificationLevels.ALL,
mark_unread: NotificationLevels.ALL,
},
},
currentUser: {
id: 'current_user_id',
notify_props: {
desktop: NotificationLevels.ALL,
},
},
sendPushNotifications: true,
actions: {
updateChannelNotifyProps: () => {}, //eslint-disable-line no-empty-function
Expand Down Expand Up @@ -99,7 +109,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleSubmitMarkUnreadLevel', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -120,7 +135,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdateMarkUnreadLevel', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -132,7 +152,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdateMarkUnreadSection', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -154,7 +179,13 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleSubmitPushNotificationLevel', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -175,7 +206,13 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdatePushNotificationLevel', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -187,7 +224,14 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdatePushSection', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};

const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand Down
1 change: 1 addition & 0 deletions tests/components/create_comment/create_comment.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('components/CreateComment', () => {
const baseProps = {
channelId,
rootId,
rootDeleted: false,
channelMembersCount: 3,
draft: {
message: 'Test message',
Expand Down
3 changes: 3 additions & 0 deletions tests/components/dot_menu/dot_menu_empty.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand All @@ -52,6 +53,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand All @@ -72,6 +74,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand Down
1 change: 1 addition & 0 deletions tests/components/dot_menu/dot_menu_mobile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('components/dot_menu/DotMenu on mobile view', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand Down
5 changes: 5 additions & 0 deletions tests/components/navbar/navbar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ describe('components/navbar/Navbar', () => {
isPinnedPosts: true,
actions: {
showEditChannelHeaderModal: jest.fn(),
toggleLhs: jest.fn(),
closeLhs: jest.fn(),
closeRhs: jest.fn(),
toggleRhsMenu: jest.fn(),
closeRhsMenu: jest.fn(),
},
isLicensed: true,
enableWebrtc: true,
Expand Down
2 changes: 2 additions & 0 deletions tests/components/sidebar/sidebar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
EnableXToLeaveChannelsFromLHS: 'false',
SiteName: 'Test site',
},
isOpen: false,
showUnreadSection: false,
publicChannelIds: ['c1', 'c2'],
privateChannelIds: ['c3', 'c4'],
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
},
actions: {
goToChannelById: jest.fn(),
close: jest.fn(),
},
};

Expand Down
1 change: 1 addition & 0 deletions tests/components/sidebar/sidebar_channel.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
offTopicDisplayName: 'Off-Topic',
membersCount: 8,
showUnreadForMsgs: true,
shouldHideChannel: false,
actions: {
savePreferences: jest.fn(),
leaveChannel: jest.fn(),
Expand Down
2 changes: 0 additions & 2 deletions tests/plugins/__snapshots__/pluggable.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ exports[`plugins/Pluggable should match snapshot with no overridden component 1`
bsClass="popover"
id="user-profile-popover"
placement="right"
showEmailAddress={true}
theme={Object {}}
title="@undefined"
>
<div
className="popover right"
id="user-profile-popover"
role="tooltip"
showEmailAddress={true}
style={
Object {
"display": "block",
Expand Down
2 changes: 0 additions & 2 deletions tests/redux/reducers/views/rhs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ describe('Reducers.RHS', () => {

const nextState2 = rhsReducer(
{
state: RHSStates.PIN,
},
{
type: ActionTypes.SELECT_POST,
Expand All @@ -194,7 +193,6 @@ describe('Reducers.RHS', () => {

const nextState3 = rhsReducer(
{
state: RHSStates.FLAG,
previousRhsState: RHSStates.SEARCH,
},
{
Expand Down
12 changes: 12 additions & 0 deletions tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ Object.defineProperty(document, 'queryCommandSupported', {
Object.defineProperty(document, 'execCommand', {
value: (cmd) => supportedCommands.includes(cmd),
});

beforeEach(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't let this regress in the future.

console.log = jest.fn((error) => {
throw new Error('Unexpected console log: ' + error);
});
console.warn = jest.fn((error) => {
throw new Error('Unexpected console warning: ' + error);
});
console.error = jest.fn((error) => {
throw new Error('Unexpected console error: ' + error);
});
});
1 change: 0 additions & 1 deletion utils/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const MIN_NETWORK_RETRY_TIME = 3000; // 3 sec
const MAX_NETWORK_RETRY_TIME = 300000; // 5 mins

function handle(callback, online) {
console.log('Network status set to ' + online); //eslint-disable-line no-console
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked with author: no longer needed.

if (window.requestAnimationFrame) {
window.requestAnimationFrame(() => callback(online));
} else {
Expand Down
2 changes: 0 additions & 2 deletions utils/storage_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export function getPrefix(state) {
}
}

console.warn('Storage tried to operate without user present'); //eslint-disable-line no-console
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked with author: no longer needed.


return 'unknown_';
}

4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4978,6 +4978,10 @@ [email protected]:
version "3.1.3"
resolved "https://registry.yarnpkg.com/jasny-bootstrap/-/jasny-bootstrap-3.1.3.tgz#b072a681d50c649762c9543c7a6093d9baa2f87b"

[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/jest-canvas-mock/-/jest-canvas-mock-1.0.2.tgz#05373f8f87fa764ca25fb4c5d6d9e34954a05550"

jest-changed-files@^22.1.4:
version "22.1.4"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-22.1.4.tgz#1f7844bcb739dec07e5899a633c0cb6d5069834e"
Expand Down