diff options
author | George Goldberg <george@gberg.me> | 2017-03-23 18:05:36 +0000 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-03-23 14:05:36 -0400 |
commit | 7d449e05562c76bb430efc1c36bd715675a84152 (patch) | |
tree | b6d5bbd143fbd31483c9c931b5031aec280ace2d /webapp/tests/client | |
parent | c6ded1dbfd69a1da69add8d2b554f4b7dd0341b3 (diff) | |
download | chat-7d449e05562c76bb430efc1c36bd715675a84152.tar.gz chat-7d449e05562c76bb430efc1c36bd715675a84152.tar.bz2 chat-7d449e05562c76bb430efc1c36bd715675a84152.zip |
PLT-5755: Infrastructure for Component Testing. (#5814)
This migrates the existing webapp tests to using Jest and Enzyme. The
infrastructure is put in place for React component testing, and a few
simple example component tests are implemented.
This also adds snapshot testing of components, coverage checking for the
webapp (although that is not yet integrated to Coveralls), and the
ability to run npm run test:watch to automatically re-run affected tests
when working on the webapp codebase.
Diffstat (limited to 'webapp/tests/client')
-rw-r--r-- | webapp/tests/client/client_admin.test.jsx | 291 | ||||
-rw-r--r-- | webapp/tests/client/client_channel.test.jsx | 488 | ||||
-rw-r--r-- | webapp/tests/client/client_command.test.jsx | 142 | ||||
-rw-r--r-- | webapp/tests/client/client_emoji.test.jsx | 102 | ||||
-rw-r--r-- | webapp/tests/client/client_file.test.jsx | 248 | ||||
-rw-r--r-- | webapp/tests/client/client_general.test.jsx | 44 | ||||
-rw-r--r-- | webapp/tests/client/client_hooks.test.jsx | 173 | ||||
-rw-r--r-- | webapp/tests/client/client_oauth.test.jsx | 50 | ||||
-rw-r--r-- | webapp/tests/client/client_post.test.jsx | 233 | ||||
-rw-r--r-- | webapp/tests/client/client_preferences.test.jsx | 62 | ||||
-rw-r--r-- | webapp/tests/client/client_reaction.test.jsx | 79 | ||||
-rw-r--r-- | webapp/tests/client/client_team.test.jsx | 309 | ||||
-rw-r--r-- | webapp/tests/client/client_user.test.jsx | 718 | ||||
-rw-r--r-- | webapp/tests/client/client_websocket.test.jsx | 46 |
14 files changed, 2985 insertions, 0 deletions
diff --git a/webapp/tests/client/client_admin.test.jsx b/webapp/tests/client/client_admin.test.jsx new file mode 100644 index 000000000..36feac8cc --- /dev/null +++ b/webapp/tests/client/client_admin.test.jsx @@ -0,0 +1,291 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Admin', function() { + test('Admin.reloadConfig', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().reloadConfig( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.recycleDatabaseConnection', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().recycleDatabaseConnection( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getComplianceReports', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getComplianceReports( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.saveComplianceReports', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var job = {}; + job.desc = 'desc'; + job.emails = ''; + job.keywords = 'test'; + job.start_at = new Date(); + job.end_at = new Date(); + + TestHelper.basicClient().saveComplianceReports( + job, + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getLogs', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getLogs( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getServerAudits', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getServerAudits( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getConfig', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getConfig( + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getAnalytics', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getAnalytics( + 'standard', + null, + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.getTeamAnalytics', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().getTeamAnalytics( + TestHelper.basicTeam().id, + 'standard', + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.saveConfig', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var config = {}; + config.site_name = 'test'; + + TestHelper.basicClient().saveConfig( + config, + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.testEmail', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var config = {}; + config.site_name = 'test'; + + TestHelper.basicClient().testEmail( + config, + function() { + done.fail(new Error('should need system admin permissions')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.adminResetMfa', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + TestHelper.basicClient().adminResetMfa( + TestHelper.basicUser().id, + function() { + done.fail(new Error('should need a license')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.adminResetPassword', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var user = TestHelper.basicUser(); + + TestHelper.basicClient().resetPassword( + user.id, + 'new_password', + function() { + throw Error('shouldnt work'); + }, + function(err) { + // this should fail since you're not a system admin + expect(err.id).toBe('api.context.invalid_param.app_error'); + done(); + } + ); + }); + }); + + test('License.getClientLicenceConfig', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getClientLicenceConfig( + function(data) { + expect(data.IsLicensed).toBe('false'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('License.removeLicenseFile', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().removeLicenseFile( + function() { + done.fail(new Error('not enabled')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); + + test('Admin.ldapSyncNow', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + TestHelper.basicClient().ldapSyncNow( + function() { + throw Error('shouldnt work'); + }, + function() { + // this should fail since you're not a system admin + done(); + } + ); + }); + }); + + test.skip('License.uploadLicenseFile', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().uploadLicenseFile( + 'form data', + function() { + done.fail(new Error('not enabled')); + }, + function(err) { + expect(err.id).toBe('api.context.permissions.app_error'); + done(); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_channel.test.jsx b/webapp/tests/client/client_channel.test.jsx new file mode 100644 index 000000000..dae70bca2 --- /dev/null +++ b/webapp/tests/client/client_channel.test.jsx @@ -0,0 +1,488 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Channels', function() { + test('createChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.fakeChannel(); + channel.team_id = TestHelper.basicTeam().id; + TestHelper.basicClient().createChannel( + channel, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.name).toBe(channel.name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('createDirectChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().createUser( + TestHelper.fakeUser(), + function(user2) { + TestHelper.basicClient().createDirectChannel( + user2.id, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('createGroupChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().createUser( + TestHelper.fakeUser(), + (user1) => { + TestHelper.basicClient().createUser( + TestHelper.fakeUser(), + function(user2) { + TestHelper.basicClient().createGroupChannel( + [user2.id, user1.id], + function(data) { + expect(data.id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + channel.display_name = 'changed'; + TestHelper.basicClient().updateChannel( + channel, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.display_name).toEqual('changed'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateChannelHeader', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + channel.display_name = 'changed'; + TestHelper.basicClient().updateChannelHeader( + channel.id, + 'new header', + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.header).toBe('new header'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateChannelPurpose', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + channel.display_name = 'changed'; + TestHelper.basicClient().updateChannelPurpose( + channel.id, + 'new purpose', + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.purpose).toEqual('new purpose'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateChannelNotifyProps', function(done) { + TestHelper.initBasic(done, () => { + var props = {}; + props.channel_id = TestHelper.basicChannel().id; + props.user_id = TestHelper.basicUser().id; + props.desktop = 'all'; + TestHelper.basicClient().updateChannelNotifyProps( + props, + function(data) { + expect(data.desktop).toEqual('all'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('leaveChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().leaveChannel( + channel.id, + function(data) { + expect(data.id).toEqual(channel.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('joinChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().leaveChannel( + channel.id, + function() { + TestHelper.basicClient().joinChannel( + channel.id, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('joinChannelByName', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().leaveChannel( + channel.id, + function() { + TestHelper.basicClient().joinChannelByName( + channel.name, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('deleteChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().deleteChannel( + channel.id, + function(data) { + expect(data.id).toEqual(channel.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('viewChannel', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().viewChannel( + channel.id, + '', + 0, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateLastViewedAt', function(done) { + TestHelper.initBasic(done, () => { + var channel = TestHelper.basicChannel(); + TestHelper.basicClient().updateLastViewedAt( + channel.id, + true, + function(data) { + expect(data.id).toEqual(channel.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannels', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannels( + function(data) { + expect(data.length).toBe(3); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannel( + TestHelper.basicChannel().id, + function(data) { + expect(TestHelper.basicChannel().id).toEqual(data.channel.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMoreChannels', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMoreChannels( + function(data) { + expect(data.length).toBe(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMoreChannelsPage', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMoreChannelsPage( + 0, + 100, + function(data) { + expect(data.length).toBe(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('searchMoreChannels', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().searchMoreChannels( + 'blargh', + function(data) { + expect(data.length).toBe(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('autocompleteChannels', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().autocompleteChannels( + TestHelper.basicChannel().name, + function(data) { + expect(data).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannelCounts', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannelCounts( + function(data) { + expect(data.counts[TestHelper.basicChannel().id]).toBe(1); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMyChannelMembers', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMyChannelMembers( + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMyChannelMembersForTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMyChannelMembersForTeam( + TestHelper.basicTeam().id, + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannelStats', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannelStats( + TestHelper.basicChannel().id, + function(data) { + expect(data.member_count).toBe(1); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannelMember', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannelMember( + TestHelper.basicChannel().id, + TestHelper.basicUser().id, + function(data) { + expect(data.channel_id).toEqual(TestHelper.basicChannel().id); + expect(data.user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('addChannelMember', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().createUserWithInvite( + TestHelper.fakeUser(), + null, + null, + TestHelper.basicTeam().invite_id, + function(user2) { + TestHelper.basicClient().addChannelMember( + TestHelper.basicChannel().id, + user2.id, + function(data) { + expect(data.channel_id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('removeChannelMember', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().removeChannelMember( + TestHelper.basicChannel().id, + TestHelper.basicUser().id, + function(data) { + expect(data.channel_id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getChannelByName', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getChannelByName( + TestHelper.basicChannel().name, + function(data) { + expect(data.name).toEqual(TestHelper.basicChannel().name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_command.test.jsx b/webapp/tests/client/client_command.test.jsx new file mode 100644 index 000000000..0b5f4bbb2 --- /dev/null +++ b/webapp/tests/client/client_command.test.jsx @@ -0,0 +1,142 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Commands', function() { + test('listCommands', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().listCommands( + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('listTeamCommands', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().listTeamCommands( + function() { + done.fail(new Error('cmds not enabled')); + }, + function(err) { + expect(err.id).toEqual('api.command.disabled.app_error'); + done(); + } + ); + }); + }); + + test('executeCommand', function(done) { + TestHelper.initBasic(done, () => { + const args = {}; + args.channel_id = TestHelper.basicChannel().id; + TestHelper.basicClient().executeCommand( + '/shrug', + args, + function(data) { + expect(data.response_type).toEqual('in_channel'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('addCommand', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var cmd = {}; + cmd.url = 'http://www.gonowhere.com'; + cmd.trigger = '/hello'; + cmd.method = 'P'; + cmd.username = ''; + cmd.icon_url = ''; + cmd.auto_complete = false; + cmd.auto_complete_desc = ''; + cmd.auto_complete_hint = ''; + cmd.display_name = 'Unit Test'; + + TestHelper.basicClient().addCommand( + cmd, + function() { + done.fail(new Error('cmds not enabled')); + }, + function(err) { + expect(err.id).toEqual('api.command.disabled.app_error'); + done(); + } + ); + }); + }); + + test('editCommand', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var cmd = {}; + cmd.url = 'http://www.gonowhere.com'; + cmd.trigger = '/hello'; + cmd.method = 'P'; + cmd.username = ''; + cmd.icon_url = ''; + cmd.auto_complete = false; + cmd.auto_complete_desc = ''; + cmd.auto_complete_hint = ''; + cmd.display_name = 'Unit Test'; + + TestHelper.basicClient().editCommand( + cmd, + function() { + done.fail(new Error('cmds not enabled')); + }, + function(err) { + expect(err.id).toEqual('api.command.disabled.app_error'); + done(); + } + ); + }); + }); + + test('deleteCommand', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().deleteCommand( + TestHelper.generateId(), + function() { + done.fail(new Error('cmds not enabled')); + }, + function(err) { + expect(err.id).toEqual('api.command.disabled.app_error'); + done(); + } + ); + }); + }); + + test('regenCommandToken', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().regenCommandToken( + TestHelper.generateId(), + function() { + done.fail(new Error('cmds not enabled')); + }, + function(err) { + expect(err.id).toEqual('api.command.disabled.app_error'); + done(); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_emoji.test.jsx b/webapp/tests/client/client_emoji.test.jsx new file mode 100644 index 000000000..da7fab711 --- /dev/null +++ b/webapp/tests/client/client_emoji.test.jsx @@ -0,0 +1,102 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +const fs = require('fs'); + +describe('Client.Emoji', function() { + const testGifFileName = 'testEmoji.gif'; + + beforeAll(function() { + // write a temporary file so that we have something to upload for testing + const buffer = new Buffer('R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=', 'base64'); + const testGif = fs.openSync(testGifFileName, 'w+'); + fs.writeFileSync(testGif, buffer); + }); + + afterAll(function() { + fs.unlinkSync(testGifFileName); + }); + + test('addEmoji', function(done) { + TestHelper.initBasic(done, () => { + const name = TestHelper.generateId(); + + TestHelper.basicClient().addEmoji( + {creator_id: TestHelper.basicUser().id, name}, + fs.createReadStream(testGifFileName), + function(data) { + expect(data.name).toEqual(name); + expect(data.id).not.toBeNull(); + + //TestHelper.basicClient().deleteEmoji(data.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('deleteEmoji', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().addEmoji( + {creator_id: TestHelper.basicUser().id, name: TestHelper.generateId()}, + fs.createReadStream(testGifFileName), + function(data) { + TestHelper.basicClient().deleteEmoji( + data.id, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('listEmoji', function(done) { + TestHelper.initBasic(done, () => { + const name = TestHelper.generateId(); + TestHelper.basicClient().addEmoji( + {creator_id: TestHelper.basicUser().id, name}, + fs.createReadStream(testGifFileName), + function() { + TestHelper.basicClient().listEmoji( + function(data) { + expect(data.length).toBeGreaterThan(0); + + let found = false; + for (const emoji of data) { + if (emoji.name === name) { + found = true; + break; + } + } + + if (found) { + done(); + } else { + done.fail(new Error('test emoji wasn\'t returned')); + } + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); diff --git a/webapp/tests/client/client_file.test.jsx b/webapp/tests/client/client_file.test.jsx new file mode 100644 index 000000000..aa0704b5a --- /dev/null +++ b/webapp/tests/client/client_file.test.jsx @@ -0,0 +1,248 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +const fs = require('fs'); + +describe('Client.File', function() { + const testGifFileName = 'testFile.gif'; + + beforeAll(function() { + // write a temporary file so that we have something to upload for testing + const buffer = new Buffer('R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=', 'base64'); + + const testGif = fs.openSync(testGifFileName, 'w+'); + fs.writeFileSync(testGif, buffer); + }); + + afterAll(function() { + fs.unlinkSync(testGifFileName); + }); + + test('uploadFile', function(done) { + TestHelper.initBasic(done, () => { + const clientId = TestHelper.generateId(); + + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + clientId, + function(resp) { + expect(resp.file_infos.length).toBe(1); + expect(resp.client_ids.length).toBe(1); + expect(resp.client_ids[0]).toEqual(clientId); + + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFile', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + TestHelper.basicClient().getFile( + resp.file_infos[0].id, + function() { + done(); + }, + function(err2) { + done.fail(new Error(err2.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFileThumbnail', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + TestHelper.basicClient().getFileThumbnail( + resp.file_infos[0].id, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFilePreview', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + TestHelper.basicClient().getFilePreview( + resp.file_infos[0].id, + function() { + done(); + }, + function(err2) { + done.fail(new Error(err2.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFileInfo', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + const fileId = resp.file_infos[0].id; + + TestHelper.basicClient().getFileInfo( + fileId, + function(info) { + expect(info.id).toEqual(fileId); + expect(info.name).toEqual(testGifFileName); + + done(); + }, + function(err2) { + done.fail(new Error(err2.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPublicLink', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + const post = TestHelper.fakePost(); + post.channel_id = TestHelper.basicChannel().id; + post.file_ids = resp.file_infos.map((info) => info.id); + + TestHelper.basicClient().createPost( + post, + function(data) { + expect(data.file_ids).toEqual(post.file_ids); + + TestHelper.basicClient().getPublicLink( + post.file_ids[0], + function() { + done.fail(new Error('public links should be disabled by default')); + + // request. + // get(link). + // end(TestHelper.basicChannel().handleResponse.bind( + // this, + // 'getPublicLink', + // function() { + // done(); + // }, + // function(err4) { + // done.fail(new Error(err4.message)); + // } + // )); + }, + function() { + done(); + + // done.fail(new Error(err3.message)); + } + ); + }, + function(err2) { + done.fail(new Error(err2.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFileInfosForPost', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().uploadFile( + fs.createReadStream(testGifFileName), + testGifFileName, + TestHelper.basicChannel().id, + '', + function(resp) { + const post = TestHelper.fakePost(); + post.channel_id = TestHelper.basicChannel().id; + post.file_ids = resp.file_infos.map((info) => info.id); + + TestHelper.basicClient().createPost( + post, + function(data) { + expect(data.file_ids).toEqual(post.file_ids); + + TestHelper.basicClient().getFileInfosForPost( + post.channel_id, + data.id, + function(files) { + expect(files.length).toBe(1); + expect(files[0].id).toEqual(resp.file_infos[0].id); + + done(); + }, + function(err3) { + done.fail(new Error(err3.message)); + } + ); + }, + function(err2) { + done.fail(new Error(err2.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); diff --git a/webapp/tests/client/client_general.test.jsx b/webapp/tests/client/client_general.test.jsx new file mode 100644 index 000000000..ddfb9d4ca --- /dev/null +++ b/webapp/tests/client/client_general.test.jsx @@ -0,0 +1,44 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.General', function() { + test('General.getClientConfig', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getClientConfig( + function(data) { + expect(data.SiteName).toEqual('Mattermost'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('General.getPing', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPing( + function(data) { + expect(data.version.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('General.logClientError', function(done) { + TestHelper.initBasic(done, () => { + var config = {}; + config.site_name = 'test'; + TestHelper.basicClient().logClientError('this is a test'); + done(); + }); + }); +}); + diff --git a/webapp/tests/client/client_hooks.test.jsx b/webapp/tests/client/client_hooks.test.jsx new file mode 100644 index 000000000..79aa0b53d --- /dev/null +++ b/webapp/tests/client/client_hooks.test.jsx @@ -0,0 +1,173 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Hooks', function() { + test('addIncomingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var hook = {}; + hook.channel_id = TestHelper.basicChannel().id; + hook.description = 'desc'; + hook.display_name = 'Unit Test'; + + TestHelper.basicClient().addIncomingHook( + hook, + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.incoming_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('updateIncomingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var hook = {}; + hook.channel_id = TestHelper.basicChannel().id; + hook.description = 'desc'; + hook.display_name = 'Unit Test'; + + TestHelper.basicClient().updateIncomingHook( + hook, + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.incoming_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('deleteIncomingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().deleteIncomingHook( + TestHelper.generateId(), + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.incoming_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('listIncomingHooks', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().listIncomingHooks( + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.incoming_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('addOutgoingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var hook = {}; + hook.channel_id = TestHelper.basicChannel().id; + hook.description = 'desc'; + hook.display_name = 'Unit Test'; + + TestHelper.basicClient().addOutgoingHook( + hook, + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.outgoing_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('deleteOutgoingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().deleteOutgoingHook( + TestHelper.generateId(), + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.outgoing_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('listOutgoingHooks', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().listOutgoingHooks( + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.outgoing_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('regenOutgoingHookToken', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().regenOutgoingHookToken( + TestHelper.generateId(), + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.outgoing_webhook.disabled.app_error'); + done(); + } + ); + }); + }); + + test('updateOutgoingHook', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var hook = {}; + hook.channel_id = TestHelper.basicChannel().id; + hook.description = 'desc'; + hook.display_name = 'Unit Test'; + + TestHelper.basicClient().updateOutgoingHook( + hook, + function() { + done.fail(new Error('hooks not enabled')); + }, + function(err) { + expect(err.id).toBe('api.outgoing_webhook.disabled.app_error'); + done(); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_oauth.test.jsx b/webapp/tests/client/client_oauth.test.jsx new file mode 100644 index 000000000..555b38438 --- /dev/null +++ b/webapp/tests/client/client_oauth.test.jsx @@ -0,0 +1,50 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.OAuth', function() { + test('registerOAuthApp', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + var app = {}; + app.name = 'test'; + app.homepage = 'homepage'; + app.description = 'desc'; + app.callback_urls = ''; + + TestHelper.basicClient().registerOAuthApp( + app, + function() { + done.fail(new Error('not enabled')); + }, + function(err) { + expect(err.id).toBe('api.oauth.register_oauth_app.turn_off.app_error'); + done(); + } + ); + }); + }); + + test('allowOAuth2', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + TestHelper.basicClient().allowOAuth2( + 'GET', + '123456', + 'http://nowhere.com', + 'state', + 'scope', + function() { + done.fail(new Error('not enabled')); + }, + function(err) { + expect(err.id).toBe('api.oauth.allow_oauth.turn_off.app_error'); + done(); + } + ); + }); + }); +}); diff --git a/webapp/tests/client/client_post.test.jsx b/webapp/tests/client/client_post.test.jsx new file mode 100644 index 000000000..bad72c8b0 --- /dev/null +++ b/webapp/tests/client/client_post.test.jsx @@ -0,0 +1,233 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Posts', function() { + test('createPost', function(done) { + TestHelper.initBasic(done, () => { + var post = TestHelper.fakePost(); + post.channel_id = TestHelper.basicChannel().id; + + TestHelper.basicClient().createPost( + post, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPostById', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPostById( + TestHelper.basicPost().id, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPost', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPost( + TestHelper.basicChannel().id, + TestHelper.basicPost().id, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updatePost', function(done) { + TestHelper.initBasic(done, () => { + var post = TestHelper.basicPost(); + post.message = 'new message'; + post.channel_id = TestHelper.basicChannel().id; + + TestHelper.basicClient().updatePost( + post, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('deletePost', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().deletePost( + TestHelper.basicChannel().id, + TestHelper.basicPost().id, + function(data) { + expect(data.id).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('searchPost', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().search( + 'unit test', + false, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPostsPage', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPostsPage( + TestHelper.basicChannel().id, + 0, + 10, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPosts', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPosts( + TestHelper.basicChannel().id, + 0, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPostsBefore', function(done) { + TestHelper.initBasic(done, () => { + var post = TestHelper.fakePost(); + post.channel_id = TestHelper.basicChannel().id; + + TestHelper.basicClient().createPost( + post, + function(rpost) { + TestHelper.basicClient().getPostsBefore( + TestHelper.basicChannel().id, + rpost.id, + 0, + 10, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPostsAfter', function(done) { + TestHelper.initBasic(done, () => { + var post = TestHelper.fakePost(); + post.channel_id = TestHelper.basicChannel().id; + + TestHelper.basicClient().createPost( + post, + function(rpost) { + TestHelper.basicClient().getPostsAfter( + TestHelper.basicChannel().id, + TestHelper.basicPost().id, + 0, + 10, + function(data) { + expect(data.order[0]).toEqual(rpost.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getFlaggedPosts', function(done) { + TestHelper.initBasic(done, () => { + var pref = {}; + pref.user_id = TestHelper.basicUser().id; + pref.category = 'flagged_post'; + pref.name = TestHelper.basicPost().id; + pref.value = 'true'; + + var prefs = []; + prefs.push(pref); + + TestHelper.basicClient().savePreferences( + prefs, + function() { + TestHelper.basicClient().getFlaggedPosts( + 0, + 2, + function(data) { + expect(data.order[0]).toEqual(TestHelper.basicPost().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + // getFileInfosForPost is tested in client_files.test.jsx +}); + diff --git a/webapp/tests/client/client_preferences.test.jsx b/webapp/tests/client/client_preferences.test.jsx new file mode 100644 index 000000000..9a8f75b95 --- /dev/null +++ b/webapp/tests/client/client_preferences.test.jsx @@ -0,0 +1,62 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Preferences', function() { + test('getAllPreferences', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getAllPreferences( + function(data) { + expect(data[0].category).toBe('tutorial_step'); + expect(data[0].user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('savePreferences', function(done) { + TestHelper.initBasic(done, () => { + var perf = {}; + perf.user_id = TestHelper.basicUser().id; + perf.category = 'test'; + perf.name = 'name'; + perf.value = 'value'; + + var perfs = []; + perfs.push(perf); + + TestHelper.basicClient().savePreferences( + perfs, + function(data) { + expect(data).toBe(true); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getPreferenceCategory', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getPreferenceCategory( + 'tutorial_step', + function(data) { + expect(data[0].category).toBe('tutorial_step'); + expect(data[0].user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_reaction.test.jsx b/webapp/tests/client/client_reaction.test.jsx new file mode 100644 index 000000000..a7b1f3389 --- /dev/null +++ b/webapp/tests/client/client_reaction.test.jsx @@ -0,0 +1,79 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Reaction', function() { + test('saveListReaction', function(done) { + TestHelper.initBasic(done, () => { + const channelId = TestHelper.basicChannel().id; + const postId = TestHelper.basicPost().id; + + const reaction = { + post_id: postId, + user_id: TestHelper.basicUser().id, + emoji_name: 'upside_down_face' + }; + + TestHelper.basicClient().saveReaction( + channelId, + reaction, + function() { + TestHelper.basicClient().listReactions( + channelId, + postId, + function(reactions) { + if (reactions.length === 1 && + reactions[0].post_id === reaction.post_id && + reactions[0].user_id === reaction.user_id && + reactions[0].emoji_name === reaction.emoji_name) { + done(); + } else { + done.fail(new Error('test reaction wasn\'t returned')); + } + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('deleteReaction', function(done) { + TestHelper.initBasic(done, () => { + const channelId = TestHelper.basicChannel().id; + const postId = TestHelper.basicPost().id; + + const reaction = { + post_id: postId, + user_id: TestHelper.basicUser().id, + emoji_name: 'upside_down_face' + }; + + TestHelper.basicClient().saveReaction( + channelId, + reaction, + function() { + TestHelper.basicClient().deleteReaction( + channelId, + reaction, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); diff --git a/webapp/tests/client/client_team.test.jsx b/webapp/tests/client/client_team.test.jsx new file mode 100644 index 000000000..76bdd2776 --- /dev/null +++ b/webapp/tests/client/client_team.test.jsx @@ -0,0 +1,309 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.Team', function() { + test('findTeamByName', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().findTeamByName( + TestHelper.basicTeam().name, + function(data) { + expect(data).toBe(true); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('createTeam', function(done) { + var team = TestHelper.fakeTeam(); + TestHelper.initBasic(done, () => { + TestHelper.basicClient().createTeam( + team, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.name).toEqual(team.name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getAllTeams', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getAllTeams( + function(data) { + expect(data[TestHelper.basicTeam().id].name).toEqual(TestHelper.basicTeam().name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getAllTeamListings', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getAllTeamListings( + function(data) { + expect(data).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMyTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMyTeam( + function(data) { + expect(data.name).toEqual(TestHelper.basicTeam().name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getMyTeamMembers', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMyTeamMembers( + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getTeamMembers', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getTeamMembers( + TestHelper.basicTeam().id, + 0, + 100, + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getTeamMember', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getTeamMember( + TestHelper.basicTeam().id, + TestHelper.basicUser().id, + function(data) { + expect(data.user_id).toEqual(TestHelper.basicUser().id); + expect(data.team_id).toEqual(TestHelper.basicTeam().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getTeamStats', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getTeamStats( + TestHelper.basicTeam().id, + function(data) { + expect(data.total_member_count).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getTeamMembersByIds', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getTeamMembersByIds( + TestHelper.basicTeam().id, + [TestHelper.basicUser().id], + function(data) { + expect(data[0].user_id).toEqual(TestHelper.basicUser().id); + expect(data[0].team_id).toEqual(TestHelper.basicTeam().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('inviteMembers', function(done) { + TestHelper.initBasic(done, () => { + var data = {}; + data.invites = []; + var invite = {}; + invite.email = TestHelper.fakeEmail(); + invite.firstName = 'first'; + invite.lastName = 'last'; + data.invites.push(invite); + + TestHelper.basicClient().inviteMembers( + data, + function(dataBack) { + expect(dataBack.invites.length).toBe(1); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateTeam', function(done) { + TestHelper.initBasic(done, () => { + var team = TestHelper.basicTeam(); + team.display_name = 'test_updated'; + + TestHelper.basicClient().updateTeam( + team, + function(data) { + expect(data.display_name).toBe('test_updated'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateTeamDescription', function(done) { + TestHelper.initBasic(done, () => { + var team = TestHelper.basicTeam(); + team.description = 'test_updated'; + + TestHelper.basicClient().updateTeam( + team, + function(data) { + expect(data.description).toBe('test_updated'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('addUserToTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().createUser( + TestHelper.fakeUser(), + function(user2) { + TestHelper.basicClient().addUserToTeam( + '', + user2.id, + function(data) { + expect(data.user_id).toEqual(user2.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('removeUserFromTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().removeUserFromTeam( + '', + TestHelper.basicUser().id, + function(data) { + expect(data.user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getInviteInfo', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getInviteInfo( + TestHelper.basicTeam().invite_id, + function(data) { + expect(data.display_name.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateTeamMemberRoles', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + var team = TestHelper.basicTeam(); + + TestHelper.basicClient().updateTeamMemberRoles( + team.id, + user.id, + '', + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getTeamByName', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getTeamByName( + TestHelper.basicTeam().name, + function(data) { + expect(data.name).toEqual(TestHelper.basicTeam().name); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); +}); + diff --git a/webapp/tests/client/client_user.test.jsx b/webapp/tests/client/client_user.test.jsx new file mode 100644 index 000000000..5f299670d --- /dev/null +++ b/webapp/tests/client/client_user.test.jsx @@ -0,0 +1,718 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe('Client.User', function() { + test('getMe', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getMe( + function(data) { + expect(data.id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getUser', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getUser( + TestHelper.basicUser().id, + function(data) { + expect(data.id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getByUsername', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getByUsername( + TestHelper.basicUser().username, + function(data) { + expect(data.username).toEqual(TestHelper.basicUser().username); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getByEmail', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getByEmail( + TestHelper.basicUser().email, + function(data) { + expect(data.email).toEqual(TestHelper.basicUser().email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getInitialLoad', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getInitialLoad( + function(data) { + expect(data.user.id.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('createUser', function(done) { + var client = TestHelper.createClient(); + var user = TestHelper.fakeUser(); + client.createUser( + user, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.email).toEqual(user.email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + + test('loginByEmail', function(done) { + var client = TestHelper.createClient(); + var user = TestHelper.fakeUser(); + client.createUser( + user, + function() { + client.login( + user.email, + user.password, + null, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.email).toEqual(user.email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + + test('loginById', function(done) { + var client = TestHelper.createClient(); + var user = TestHelper.fakeUser(); + client.createUser( + user, + function(newUser) { + expect(user.email).toEqual(newUser.email); + client.loginById( + newUser.id, + user.password, + null, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.email).toEqual(user.email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + + test('loginByUsername', function(done) { + var client = TestHelper.createClient(); + var user = TestHelper.fakeUser(); + client.createUser( + user, + function() { + client.login( + user.username, + user.password, + null, + function(data) { + expect(data.id.length).toBeGreaterThan(0); + expect(data.email).toEqual(user.email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + + test('updateUser', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + user.nickname = 'updated'; + + TestHelper.basicClient().updateUser( + user, null, + function(data) { + expect(data.nickname).toBe('updated'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updatePassword', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + + TestHelper.basicClient().updatePassword( + user.id, + user.password, + 'update_password', + function(data) { + expect(data.user_id).toEqual(user.id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateUserNotifyProps', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + + var notifyProps = { + all: 'true', + channel: 'true', + desktop: 'all', + desktop_sound: 'true', + email: 'false', + first_name: 'false', + mention_keys: '', + comments: 'any', + user_id: user.id + }; + + TestHelper.basicClient().updateUserNotifyProps( + notifyProps, + function(data) { + expect(data.notify_props.email).toBe('false'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateUserRoles', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var user = TestHelper.basicUser(); + + TestHelper.basicClient().updateUserRoles( + user.id, + '', + function() { + done.fail(new Error('Not supposed to work')); + }, + function() { + done(); + } + ); + }); + }); + + test('updateActive', function(done) { + TestHelper.initBasic(done, () => { + const user = TestHelper.basicUser(); + + TestHelper.basicClient().updateActive( + user.id, + false, + function(data) { + expect(data.delete_at).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('sendPasswordReset', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + + TestHelper.basicClient().sendPasswordReset( + user.email, + function(data) { + expect(data.email).toEqual(user.email); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('resetPassword', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + + TestHelper.basicClient().resetPassword( + '', + 'new_password', + function() { + throw Error('shouldnt work'); + }, + function(err) { + // this should fail since you're not a system admin + expect(err.id).toBe('api.context.invalid_param.app_error'); + done(); + } + ); + }); + }); + + test('emailToOAuth', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var user = TestHelper.basicUser(); + + TestHelper.basicClient().emailToOAuth( + user.email, + 'new_password', + '', + 'gitlab', + function() { + throw Error('shouldnt work'); + }, + function(err) { + // this should fail since you're not a system admin + expect(err.id).toBe('api.user.check_user_password.invalid.app_error'); + done(); + } + ); + }); + }); + + test('oauthToEmail', function(done) { + TestHelper.initBasic(done, () => { + var user = TestHelper.basicUser(); + + TestHelper.basicClient().oauthToEmail( + user.email, + 'new_password', + function(data) { + expect(data.follow_link.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('emailToLdap', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var user = TestHelper.basicUser(); + + TestHelper.basicClient().emailToLdap( + user.email, + user.password, + '', + 'unknown_id', + 'unknown_pwd', + function() { + throw Error('shouldnt work'); + }, + function() { + done(); + } + ); + }); + }); + + test('ldapToEmail', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + var user = TestHelper.basicUser(); + + TestHelper.basicClient().ldapToEmail( + user.email, + 'new_password', + '', + 'new_password', + function() { + throw Error('shouldnt work'); + }, + function(err) { + expect(err.id).toBe('api.user.ldap_to_email.not_ldap_account.app_error'); + done(); + } + ); + }); + }); + + test('logout', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().logout( + function(data) { + expect(data.user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('checkMfa', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().checkMfa( + TestHelper.generateId(), + function(data) { + expect(data.mfa_required).toBe('false'); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('generateMfaSecret', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().generateMfaSecret( + function() { + done.fail(new Error('not enabled')); + }, + function() { + done(); + } + ); + }); + }); + + test('getSessions', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getSessions( + TestHelper.basicUser().id, + function(data) { + expect(data[0].user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('revokeSession', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getSessions( + TestHelper.basicUser().id, + function(sessions) { + TestHelper.basicClient().revokeSession( + sessions[0].id, + function(data) { + expect(data.id).toEqual(sessions[0].id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getAudits', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getAudits( + TestHelper.basicUser().id, + function(data) { + expect(data[0].user_id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getProfiles', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getProfiles( + 0, + 100, + function(data) { + expect(Object.keys(data).length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getProfilesInTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getProfilesInTeam( + TestHelper.basicTeam().id, + 0, + 100, + function(data) { + expect(data[TestHelper.basicUser().id].id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getProfilesByIds', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getProfilesByIds( + [TestHelper.basicUser().id], + function(data) { + expect(data[TestHelper.basicUser().id].id).toEqual(TestHelper.basicUser().id); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getProfilesInChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getProfilesInChannel( + TestHelper.basicChannel().id, + 0, + 100, + function(data) { + expect(Object.keys(data).length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getProfilesNotInChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().getProfilesNotInChannel( + TestHelper.basicChannel().id, + 0, + 100, + function(data) { + expect(Object.keys(data).length).not.toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('searchUsers', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().searchUsers( + 'uid', + TestHelper.basicTeam().id, + {}, + function(data) { + expect(data.length).toBeGreaterThan(0); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('autocompleteUsersInChannel', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().autocompleteUsersInChannel( + 'uid', + TestHelper.basicChannel().id, + function(data) { + expect(data).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('autocompleteUsersInTeam', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().autocompleteUsersInTeam( + 'uid', + function(data) { + expect(data).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('autocompleteUsers', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().autocompleteUsers( + 'uid', + function(data) { + expect(data).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('getStatusesByIds', function(done) { + TestHelper.initBasic(done, () => { + var ids = []; + ids.push(TestHelper.basicUser().id); + + TestHelper.basicClient().getStatusesByIds( + ids, + function(data) { + expect(data[TestHelper.basicUser().id]).not.toBeNull(); + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('setActiveChannel', function(done) { + TestHelper.initBasic(done, () => { + var ids = []; + ids.push(TestHelper.basicUser().id); + + TestHelper.basicClient().setActiveChannel( + TestHelper.basicChannel().id, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('verifyEmail', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().verifyEmail( + 'junk', + 'junk', + function() { + done.fail(new Error('should be invalid')); + }, + function(err) { + expect(err.id).toBe('api.context.invalid_param.app_error'); + done(); + } + ); + }); + }); + + test('resendVerification', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().resendVerification( + TestHelper.basicUser().email, + function() { + done(); + }, + function(err) { + done.fail(new Error(err.message)); + } + ); + }); + }); + + test('updateMfa', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicClient().enableLogErrorsToConsole(false); // Disabling since this unit test causes an error + TestHelper.basicClient().updateMfa( + 'junk', + true, + function() { + done.fail(new Error('not enabled')); + }, + function() { + done(); + } + ); + }); + }); +}); diff --git a/webapp/tests/client/client_websocket.test.jsx b/webapp/tests/client/client_websocket.test.jsx new file mode 100644 index 000000000..9a754c345 --- /dev/null +++ b/webapp/tests/client/client_websocket.test.jsx @@ -0,0 +1,46 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import TestHelper from 'tests/helpers/client-test-helper.jsx'; + +describe.skip('Client.WebSocket', function() { + test('WebSocket.getStatusesByIds', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicWebSocketClient().getStatusesByIds( + [TestHelper.basicUser().id], + function(resp) { + TestHelper.basicWebSocketClient().close(); + expect(resp.data[TestHelper.basicUser().id]).toBe('online'); + done(); + } + ); + }, true); + }); + + test('WebSocket.getStatuses', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicWebSocketClient().getStatuses( + function(resp) { + TestHelper.basicWebSocketClient().close(); + expect(resp.data).not.toBe(null); + done(); + } + ); + }, true); + }); + + test('WebSocket.userTyping', function(done) { + TestHelper.initBasic(done, () => { + TestHelper.basicWebSocketClient().userTyping( + TestHelper.basicChannel().id, + '', + function(resp) { + TestHelper.basicWebSocketClient().close(); + expect(resp.status).toBe('OK'); + done(); + } + ); + }, true); + }); +}); + |