* 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>
103 lines
3.2 KiB
TypeScript
103 lines
3.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import TestHelper from '@test/test_helper';
|
|
import {buildQueryString} from '@utils/helpers';
|
|
|
|
import {PER_PAGE_DEFAULT} from './constants';
|
|
|
|
import type ClientBase from './base';
|
|
import type {ClientGroupsMix} from './groups';
|
|
|
|
describe('ClientGroups', () => {
|
|
let client: ClientGroupsMix & ClientBase;
|
|
|
|
beforeAll(() => {
|
|
client = TestHelper.createClient();
|
|
client.doFetch = jest.fn();
|
|
});
|
|
|
|
test('getGroups', async () => {
|
|
const params = {
|
|
query: 'test',
|
|
filterAllowReference: true,
|
|
page: 1,
|
|
perPage: 10,
|
|
since: 0,
|
|
includeMemberCount: true,
|
|
};
|
|
|
|
await client.getGroups(params);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
`${client.urlVersion}/groups${buildQueryString({
|
|
q: params.query,
|
|
filter_allow_reference: params.filterAllowReference,
|
|
page: params.page,
|
|
per_page: params.perPage,
|
|
since: params.since,
|
|
include_member_count: params.includeMemberCount,
|
|
})}`,
|
|
{method: 'get'},
|
|
);
|
|
|
|
// Test with default values
|
|
await client.getGroups({});
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
`${client.urlVersion}/groups${buildQueryString({
|
|
q: '',
|
|
filter_allow_reference: true,
|
|
page: 0,
|
|
per_page: PER_PAGE_DEFAULT,
|
|
since: 0,
|
|
include_member_count: false,
|
|
})}`,
|
|
{method: 'get'},
|
|
);
|
|
});
|
|
|
|
test('getAllGroupsAssociatedToChannel', async () => {
|
|
const channelId = 'channel1';
|
|
const groupLabel = 'WebSocket Reconnect';
|
|
|
|
await client.getAllGroupsAssociatedToChannel(channelId, undefined, groupLabel);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
`${client.urlVersion}/channels/${channelId}/groups${buildQueryString({
|
|
paginate: false,
|
|
filter_allow_reference: false,
|
|
include_member_count: true,
|
|
})}`,
|
|
{method: 'get', groupLabel},
|
|
);
|
|
});
|
|
|
|
test('getAllGroupsAssociatedToTeam', async () => {
|
|
const teamId = 'team1';
|
|
|
|
await client.getAllGroupsAssociatedToTeam(teamId);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
`${client.urlVersion}/teams/${teamId}/groups${buildQueryString({
|
|
paginate: false,
|
|
filter_allow_reference: false,
|
|
})}`,
|
|
{method: 'get'},
|
|
);
|
|
});
|
|
|
|
test('getAllGroupsAssociatedToMembership', async () => {
|
|
const userId = 'user1';
|
|
const groupLabel = 'WebSocket Reconnect';
|
|
|
|
await client.getAllGroupsAssociatedToMembership(userId, undefined, groupLabel);
|
|
|
|
expect(client.doFetch).toHaveBeenCalledWith(
|
|
`${client.urlVersion}/users/${userId}/groups${buildQueryString({
|
|
paginate: false,
|
|
filter_allow_reference: false,
|
|
})}`,
|
|
{method: 'get', groupLabel},
|
|
);
|
|
});
|
|
});
|