* Network metrics * update network-client ref * fix unit tests * missing catch error parsing * Replace API's to fetch all teams and channels for a user Update groupLabel to use a type definition Include effective Latency and Average Speed in the metrics Include parallel and sequential request counts * update network library and fix tests * feat(MM-61865): send network request telemetry data to the server (#8436) * feat(MM-61865): send network info telemetry data * unit testing * fix latency vs effectiveLatency * cleanup test * fix failing tests * fix spelling error * fix failing test * more cleanup * fix: improve parallel requests calculation (#8439) * fix: improve parallel requests calculation * fix test issue * multiple parallelGroups testing * calculateAverageSpeedWithCategories test * categorizedRequests in it's own describe * clean up duplicate tests * check for when groupLabel is non-existent * a case when groupLabel is non-existent * more testing with effective latency. * resolveAndFlattenModels with a capital F * add try..catch within resolveAndFlattenModels * update groupLabel to fix failing lint * fix linting issue due to unknown group label * forgot to push changes * fix the indentation problem again * add env var option for COLLECT_NETWORK_METRICS --------- Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com> Co-authored-by: Mattermost Build <build@mattermost.com>
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import TestHelper from '@test/test_helper';
|
|
|
|
import type ClientBase from './base';
|
|
import type {ClientPreferencesMix} from './preferences';
|
|
|
|
describe('ClientPreferences', () => {
|
|
let client: ClientPreferencesMix & ClientBase;
|
|
|
|
beforeAll(() => {
|
|
client = TestHelper.createClient();
|
|
client.doFetch = jest.fn();
|
|
});
|
|
|
|
test('savePreferences', async () => {
|
|
const userId = 'user_id';
|
|
const preferences = [{category: 'category1', name: 'name1', value: 'value1'}] as PreferenceType[];
|
|
const groupLabel = 'Server Switch';
|
|
const expectedUrl = client.getPreferencesRoute(userId);
|
|
const expectedOptions = {
|
|
method: 'put',
|
|
body: preferences,
|
|
groupLabel,
|
|
};
|
|
|
|
await client.savePreferences(userId, preferences, groupLabel);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(expectedUrl, expectedOptions);
|
|
});
|
|
|
|
test('getMyPreferences', async () => {
|
|
const groupLabel = 'Server Switch';
|
|
const expectedUrl = client.getPreferencesRoute('me');
|
|
const expectedOptions = {
|
|
method: 'get',
|
|
groupLabel,
|
|
};
|
|
|
|
await client.getMyPreferences(groupLabel);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(expectedUrl, expectedOptions);
|
|
});
|
|
|
|
test('deletePreferences', async () => {
|
|
const userId = 'user_id';
|
|
const preferences = [{category: 'category1', name: 'name1', value: 'value1'}] as PreferenceType[];
|
|
const expectedUrl = `${client.getPreferencesRoute(userId)}/delete`;
|
|
const expectedOptions = {
|
|
method: 'post',
|
|
body: preferences,
|
|
};
|
|
|
|
await client.deletePreferences(userId, preferences);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(expectedUrl, expectedOptions);
|
|
});
|
|
});
|