* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import assert from 'assert';
|
|
import nock from 'nock';
|
|
|
|
import {logError} from '@mm-redux/actions/errors';
|
|
import {Client4} from '@mm-redux/client';
|
|
|
|
import TestHelper from 'test/test_helper';
|
|
import configureStore from 'test/test_store';
|
|
|
|
describe('Actions.Errors', () => {
|
|
let store;
|
|
beforeAll(async () => {
|
|
await TestHelper.initBasic(Client4);
|
|
Client4.setEnableLogging(true);
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
store = await configureStore();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await TestHelper.tearDown();
|
|
Client4.setEnableLogging(false);
|
|
});
|
|
|
|
it('logError should hit /logs endpoint, unless server error', async () => {
|
|
let count = 0;
|
|
|
|
nock(Client4.getBaseRoute()).
|
|
post('/logs').
|
|
reply(200, () => {
|
|
count++;
|
|
return '{}';
|
|
}).
|
|
post('/logs').
|
|
reply(200, () => {
|
|
count++;
|
|
return '{}';
|
|
}).
|
|
post('/logs').
|
|
reply(200, () => {
|
|
count++;
|
|
return '{}';
|
|
});
|
|
|
|
await store.dispatch(logError({message: 'error'}));
|
|
await store.dispatch(logError({message: 'error', server_error_id: 'error_id'}));
|
|
await store.dispatch(logError({message: 'error'}));
|
|
|
|
if (count > 2) {
|
|
assert.fail(`should not hit /logs endpoint, called ${count} times`);
|
|
}
|
|
|
|
await store.dispatch(logError({message: 'error', server_error_id: 'api.context.session_expired.app_error'}));
|
|
|
|
if (count > 2) {
|
|
assert.fail('should not add session expired errors to the reducer');
|
|
}
|
|
});
|
|
});
|