fix: conversion of public channel into team (#5099)
This commit is contained in:
parent
a6eb514761
commit
1ee2aa889b
|
@ -52,7 +52,9 @@ export type ChannelsEndpoints = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'channels.convertToTeam': {
|
'channels.convertToTeam': {
|
||||||
POST: (params: { channelId: string; channelName: string }) => { team: ITeam };
|
POST: (params: { channelId: string } | { channelName: string } | { channelId: string; channelName: string }) => {
|
||||||
|
team: ITeam;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
'channels.info': {
|
'channels.info': {
|
||||||
GET: (params: { roomId: string }) => { channel: IServerRoom };
|
GET: (params: { roomId: string }) => { channel: IServerRoom };
|
||||||
|
|
|
@ -230,17 +230,23 @@ export const teamListRoomsOfUser = ({ teamId, userId }: { teamId: string; userId
|
||||||
sdk.get('teams.listRoomsOfUser', { teamId, userId });
|
sdk.get('teams.listRoomsOfUser', { teamId, userId });
|
||||||
|
|
||||||
export const convertChannelToTeam = ({ rid, name, type }: { rid: string; name: string; type: 'c' | 'p' }) => {
|
export const convertChannelToTeam = ({ rid, name, type }: { rid: string; name: string; type: 'c' | 'p' }) => {
|
||||||
const params = {
|
const serverVersion = reduxStore.getState().server.version;
|
||||||
...(type === 'c'
|
let params;
|
||||||
? {
|
if (type === 'c') {
|
||||||
|
// https://github.com/RocketChat/Rocket.Chat/pull/25279
|
||||||
|
params = compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '4.8.0')
|
||||||
|
? { channelId: rid }
|
||||||
|
: {
|
||||||
channelId: rid,
|
channelId: rid,
|
||||||
channelName: name
|
channelName: name
|
||||||
}
|
};
|
||||||
: {
|
} else {
|
||||||
roomId: rid,
|
params = {
|
||||||
roomName: name
|
roomId: rid,
|
||||||
})
|
roomName: name
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return sdk.post(type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', params);
|
return sdk.post(type === 'c' ? 'channels.convertToTeam' : 'groups.convertToTeam', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,9 @@ import random from '../../helpers/random';
|
||||||
|
|
||||||
const toBeConverted = `to-be-converted-${random()}`;
|
const toBeConverted = `to-be-converted-${random()}`;
|
||||||
const toBeMoved = `to-be-moved-${random()}`;
|
const toBeMoved = `to-be-moved-${random()}`;
|
||||||
|
const publicChannelToBeConverted = `channel-public-to-be-converted-${random()}`;
|
||||||
|
|
||||||
const createChannel = async (room: string) => {
|
const createChannel = async (room: string, publicChannel?: boolean) => {
|
||||||
await waitFor(element(by.id('rooms-list-view-create-channel')))
|
await waitFor(element(by.id('rooms-list-view-create-channel')))
|
||||||
.toBeVisible()
|
.toBeVisible()
|
||||||
.withTimeout(5000);
|
.withTimeout(5000);
|
||||||
|
@ -28,6 +29,9 @@ const createChannel = async (room: string) => {
|
||||||
.withTimeout(10000);
|
.withTimeout(10000);
|
||||||
await element(by.id('create-channel-name')).replaceText(room);
|
await element(by.id('create-channel-name')).replaceText(room);
|
||||||
await element(by.id('create-channel-name')).tapReturnKey();
|
await element(by.id('create-channel-name')).tapReturnKey();
|
||||||
|
if (publicChannel) {
|
||||||
|
await element(by.id('create-channel-type')).tap();
|
||||||
|
}
|
||||||
await waitFor(element(by.id('create-channel-submit')))
|
await waitFor(element(by.id('create-channel-submit')))
|
||||||
.toExist()
|
.toExist()
|
||||||
.withTimeout(10000);
|
.withTimeout(10000);
|
||||||
|
@ -68,11 +72,28 @@ describe('Move/Convert Team', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Convert', () => {
|
describe('Convert', () => {
|
||||||
beforeAll(async () => {
|
it('should convert public channel to a team', async () => {
|
||||||
await createChannel(toBeConverted);
|
await createChannel(publicChannelToBeConverted, true);
|
||||||
|
await navigateToRoomActions(publicChannelToBeConverted);
|
||||||
|
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
|
||||||
|
await waitFor(element(by.id('room-actions-convert-to-team')))
|
||||||
|
.toBeVisible()
|
||||||
|
.withTimeout(2000);
|
||||||
|
await element(by.id('room-actions-convert-to-team')).tap();
|
||||||
|
await waitFor(element(by[textMatcher]('You are converting this Channel to a Team. All Members will be kept.')))
|
||||||
|
.toExist()
|
||||||
|
.withTimeout(2000);
|
||||||
|
await element(by[textMatcher]('Convert').and(by.type(alertButtonType))).tap();
|
||||||
|
await waitFor(element(by.id('room-view')))
|
||||||
|
.toExist()
|
||||||
|
.withTimeout(20000);
|
||||||
|
await waitFor(element(by.id(`room-view-title-${publicChannelToBeConverted}`)))
|
||||||
|
.toExist()
|
||||||
|
.withTimeout(6000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should convert channel to a team', async () => {
|
it('should convert private channel to a team', async () => {
|
||||||
|
await createChannel(toBeConverted);
|
||||||
await navigateToRoomActions(toBeConverted);
|
await navigateToRoomActions(toBeConverted);
|
||||||
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
|
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
|
||||||
await waitFor(element(by.id('room-actions-convert-to-team')))
|
await waitFor(element(by.id('room-actions-convert-to-team')))
|
||||||
|
@ -91,7 +112,7 @@ describe('Move/Convert Team', () => {
|
||||||
.withTimeout(6000);
|
.withTimeout(6000);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterEach(async () => {
|
||||||
await tapBack();
|
await tapBack();
|
||||||
await waitFor(element(by.id('rooms-list-view')))
|
await waitFor(element(by.id('rooms-list-view')))
|
||||||
.toExist()
|
.toExist()
|
||||||
|
|
Loading…
Reference in New Issue