regression: add teams to action screen (#4942)

* add teams to action screen

* keep it the old way

* fix test id

* back to old one rule

* fix team tests

* fix moveconvert test

* remove skip from room.spec

* fix shared config doc

* remove skip from broadcast.spec
This commit is contained in:
Gleidson Daniel Silva 2023-04-10 17:54:02 -03:00 committed by GitHub
parent cf14ebea78
commit 337e9e155d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 75 deletions

View File

@ -768,7 +768,7 @@
"Convert_to_Team_Warning": "You are converting this Channel to a Team. All Members will be kept.",
"Move_to_Team": "Move to Team",
"Move_Channel_Paragraph": "Moving a channel inside a team means that this channel will be added in the teams context, however, all channels members, which are not members of the respective team, will still have access to this channel, but will not be added as teams members. \n\nAll channels management will still be made by the owners of this channel.\n\nTeams members and even teams owners, if not a member of this channel, can not have access to the channels content. \n\nPlease notice that the Teams owner will be able remove members from the Channel.",
"Move_to_Team_Warning": "After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?",
"Move_to_Team_Warning": "After reading the previous instructions about this behavior, do you still want to move this channel to the selected team?",
"Load_More": "Load More",
"Load_Newer": "Load Newer",
"Load_Older": "Load Older",

View File

@ -1,12 +1,10 @@
import React, { useEffect, useState } from 'react';
import { Q } from '@nozbe/watermelondb';
import { useActionSheet } from '../../containers/ActionSheet';
import StartACallActionSheet from '../../containers/UIKit/VideoConferenceBlock/components/StartACallActionSheet';
import { ISubscription, SubscriptionType, TSubscriptionModel } from '../../definitions';
import { ISubscription, SubscriptionType } from '../../definitions';
import i18n from '../../i18n';
import { getUserSelector } from '../../selectors/login';
import database from '../database';
import { getSubscriptionByRoomId } from '../database/services/Subscription';
import { callJitsi } from '../methods';
import { compareServerVersion, showErrorAlert } from '../methods/helpers';
@ -40,14 +38,18 @@ export const useVideoConf = (rid: string): { showInitCallActionSheet: () => Prom
const { showActionSheet } = useActionSheet();
const snaps = useSnaps([1250]);
const handleShowCallOption = (room: TSubscriptionModel) => {
const handleShowCallOption = async () => {
if (isServer5OrNewer) return setShowCallOption(true);
const isJitsiDisabledForTeams = room.teamMain && !jitsiEnableTeams;
const isJitsiDisabledForChannels = !room.teamMain && (room.t === 'p' || room.t === 'c') && !jitsiEnableChannels;
const room = await getSubscriptionByRoomId(rid);
if (room.t === SubscriptionType.DIRECT) return setShowCallOption(!!jitsiEnabled);
if (room.t === SubscriptionType.CHANNEL) return setShowCallOption(!isJitsiDisabledForChannels);
if (room.t === SubscriptionType.GROUP) return setShowCallOption(!isJitsiDisabledForTeams);
if (room) {
const isJitsiDisabledForTeams = room.teamMain && !jitsiEnableTeams;
const isJitsiDisabledForChannels = !room.teamMain && (room.t === 'p' || room.t === 'c') && !jitsiEnableChannels;
if (room.t === SubscriptionType.DIRECT) return setShowCallOption(!!jitsiEnabled);
if (room.t === SubscriptionType.CHANNEL) return setShowCallOption(!isJitsiDisabledForChannels);
if (room.t === SubscriptionType.GROUP) return setShowCallOption(!isJitsiDisabledForTeams);
}
return setShowCallOption(false);
};
@ -90,23 +92,8 @@ export const useVideoConf = (rid: string): { showInitCallActionSheet: () => Prom
}
};
const initSubscription = () => {
try {
const db = database.active;
const observeSubCollection = db.get('subscriptions').query(Q.where('rid', rid)).observe();
const subObserveQuery = observeSubCollection.subscribe(data => {
if (data[0]) {
handleShowCallOption(data[0]);
subObserveQuery.unsubscribe();
}
});
} catch (e) {
console.log("observeSubscriptions: Can't find subscription to observe");
}
};
useEffect(() => {
initSubscription();
handleShowCallOption();
}, []);
return { showInitCallActionSheet, showCallOption };

View File

@ -41,7 +41,8 @@ import {
getUidDirectMessage,
hasPermission,
isGroupChat,
compareServerVersion
compareServerVersion,
isTeamRoom
} from '../../lib/methods/helpers';
import { Services } from '../../lib/services';
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
@ -1033,7 +1034,8 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
render() {
const { room, membersCount, canViewMembers, joined, canAutoTranslate } = this.state;
const { rid, t, prid } = room;
const { isMasterDetail, navigation } = this.props;
const { rid, t, prid, teamId } = room;
const isGroupChatHandler = isGroupChat(room);
return (
@ -1081,7 +1083,32 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
<List.Separator />
</>
) : null}
{teamId && isTeamRoom({ teamId, joined }) ? (
<>
<List.Item
title='Teams'
onPress={() => {
logEvent(events.ROOM_GO_TEAM_CHANNELS);
if (isMasterDetail) {
// @ts-ignore TODO: find a way to make this work - OLD Diego :)
navigation.navigate('ModalStackNavigator', {
screen: 'TeamChannelsView',
params: { teamId, joined }
});
} else {
navigation.navigate('TeamChannelsView', {
teamId,
joined
});
}
}}
testID='room-actions-teams'
left={() => <List.Icon name='channel-public' />}
showActionIndicator
/>
<List.Separator />
</>
) : null}
{['l'].includes(t) && !this.isOmnichannelPreview && this.omnichannelPermissions?.canViewCannedResponse ? (
<>
<List.Item

View File

@ -153,23 +153,6 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
});
};
goTeamChannels = () => {
logEvent(events.ROOM_GO_TEAM_CHANNELS);
const { navigation, isMasterDetail, teamId, joined } = this.props;
if (!teamId) {
return;
}
if (isMasterDetail) {
// @ts-ignore TODO: find a way to make this work
navigation.navigate('ModalStackNavigator', {
screen: 'TeamChannelsView',
params: { teamId, joined }
});
} else {
navigation.navigate('TeamChannelsView', { teamId, joined });
}
};
goThreadsView = () => {
logEvent(events.ROOM_GO_THREADS);
const { rid, t, navigation, isMasterDetail } = this.props;

View File

@ -16,7 +16,7 @@ import {
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
import random from '../../helpers/random';
describe.skip('Broadcast room', () => {
describe('Broadcast room', () => {
let textMatcher: TTextMatcher;
let user: ITestUser;
let otherUser: ITestUser;

View File

@ -485,7 +485,7 @@ describe('Room screen', () => {
await tapBack();
});
it.skip('should reply in DM to another user', async () => {
it('should reply in DM to another user', async () => {
const replyUser = await createRandomUser();
const { name: replyRoom } = await createRandomRoom(replyUser, 'c');
const originalMessage = 'Message to reply in DM';

View File

@ -26,7 +26,7 @@ async function openActionSheet(username: string) {
async function navigateToRoomActions() {
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(2000);
.withTimeout(5000);
await element(by.id('room-header')).atIndex(0).tap();
await waitFor(element(by.id('room-actions-view')))
.toExist()
@ -92,14 +92,14 @@ describe('Team', () => {
await navigateToRoom(team);
});
describe.skip('Team Room', () => {
describe('Team Room', () => {
describe('Team Header', () => {
it('should have actions button ', async () => {
await expect(element(by.id('room-header'))).toExist();
});
it('should have team channels button ', async () => {
await expect(element(by.id('room-view-header-team-channels'))).toExist();
it('should have call button ', async () => {
await expect(element(by.id('room-view-header-call'))).toExist();
});
it('should have threads button ', async () => {
@ -111,9 +111,10 @@ describe('Team', () => {
});
});
describe('Team Header Usage', () => {
describe('Team Action Usage', () => {
it('should navigate to team channels view', async () => {
await element(by.id('room-view-header-team-channels')).tap();
await element(by.id('room-header')).tap();
await element(by.id('room-actions-teams')).tap();
await waitFor(element(by.id('team-channels-view')))
.toExist()
.withTimeout(5000);
@ -183,8 +184,9 @@ describe('Team', () => {
.toExist()
.withTimeout(20000);
await expect(element(by.id('room-view'))).toExist();
await expect(element(by.id('room-view-header-team-channels'))).toExist();
await element(by.id('room-view-header-team-channels')).tap();
await element(by.id('room-header')).tap();
await expect(element(by.id('room-actions-teams'))).toExist();
await element(by.id('room-actions-teams')).tap();
await waitFor(element(by.id('team-channels-view')))
.toExist()
@ -198,7 +200,7 @@ describe('Team', () => {
.toExist()
.withTimeout(60000);
await expect(element(by.id(`room-view-title-${room}`))).toExist();
await expect(element(by.id('room-view-header-team-channels')).atIndex(0)).toExist();
await expect(element(by.id('room-view-header-call')).atIndex(0)).toExist();
await expect(element(by.id('room-view-header-threads')).atIndex(0)).toExist();
await expect(element(by.id('room-view-search')).atIndex(0)).toExist();
await tapBack();
@ -206,10 +208,9 @@ describe('Team', () => {
it('should add existing channel to team', async () => {
await navigateToRoom(team);
await waitFor(element(by.id('room-view-header-team-channels')))
.toExist()
.withTimeout(5000);
await element(by.id('room-view-header-team-channels')).tap();
await element(by.id('room-header')).tap();
await expect(element(by.id('room-actions-teams'))).toExist();
await element(by.id('room-actions-teams')).tap();
await waitFor(element(by.id('team-channels-view')))
.toExist()
.withTimeout(5000);
@ -229,11 +230,9 @@ describe('Team', () => {
.withTimeout(6000);
await element(by.id('add-existing-channel-view-submit')).tap();
await checkRoomTitle(team);
await waitFor(element(by.id('room-view-header-team-channels')))
.toBeVisible()
.withTimeout(2000);
await element(by.id('room-view-header-team-channels')).tap();
await element(by.id('room-header')).tap();
await expect(element(by.id('room-actions-teams'))).toExist();
await element(by.id('room-actions-teams')).tap();
await waitFor(element(by.id(`rooms-list-view-item-${existingRoom}`)).atIndex(0))
.toExist()
.withTimeout(10000);
@ -276,6 +275,7 @@ describe('Team', () => {
await waitFor(element(by.id(`rooms-list-view-item-${existingRoom}`)).atIndex(0))
.toExist()
.withTimeout(6000);
await tapBack();
});
});
@ -383,10 +383,6 @@ describe('Team', () => {
describe('Room Members', () => {
beforeAll(async () => {
await tapAndWaitFor(element(by.id('room-actions-members')), element(by.id('room-members-view')), 2000);
// await element(by.id('room-actions-members')).tap();
// await waitFor(element(by.id('room-members-view')))
// .toBeVisible()
// .withTimeout(2000);
});
it('should show all users', async () => {

View File

@ -55,7 +55,7 @@ async function navigateToRoomActions(room: string) {
.withTimeout(5000);
}
describe.skip('Move/Convert Team', () => {
describe('Move/Convert Team', () => {
let alertButtonType: string;
let textMatcher: TTextMatcher;
let user: ITestUser;
@ -124,16 +124,19 @@ describe.skip('Move/Convert Team', () => {
await waitFor(
element(
by[textMatcher](
'After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?'
'After reading the previous instructions about this behavior, do you still want to move this channel to the selected team?'
)
)
)
.toBeVisible()
.withTimeout(2000);
await element(by[textMatcher]('Yes, move it!').and(by.type(alertButtonType))).tap();
await waitFor(element(by.id('room-view-header-team-channels')))
.toBeVisible()
.withTimeout(10000);
await sleep(300); // wait for animation
await element(by.id('room-header')).tap();
await waitFor(element(by.id(`room-actions-teams`)))
.toExist()
.withTimeout(6000);
await tapBack();
});
afterAll(async () => {