mattermost/e2e-tests/playwright/support/server/channel.ts
Saturnino Abril 8fdbbf3d5b
E2E/Playwright: MM-T5424 Find channel limit to 50 results (#23248)
* fix aria-label of Find Channels modal

* add components

* add test for MM-T5424

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2023-05-05 06:20:23 +08:00

35 lines
1,008 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getRandomId} from '@e2e-support/util';
import {Channel, ChannelType} from '@mattermost/types/channels';
type ChannelInput = {
teamId: string;
name: string;
displayName: string;
type?: ChannelType;
purpose?: string;
header?: string;
unique?: boolean;
};
export function createRandomChannel(channelInput: ChannelInput): Channel {
const channel = {
team_id: channelInput.teamId,
name: channelInput.name,
display_name: channelInput.displayName,
type: channelInput.type || 'O',
purpose: channelInput.type || '',
header: channelInput.type || '',
};
if (channelInput.unique) {
const randomSuffix = getRandomId();
channel.name = `${channelInput.name}-${randomSuffix}`;
channel.display_name = `${channelInput.displayName} ${randomSuffix}`;
}
return channel as Channel;
}