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/client_admin.test.jsx | |
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/client_admin.test.jsx')
-rw-r--r-- | webapp/tests/client/client_admin.test.jsx | 291 |
1 files changed, 291 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(); + } + ); + }); + }); +}); + |