[FIX] Teams tests (#3196)

* Make team_main not optional and fix tests

* Undo isOptional and fix query

* Comment
This commit is contained in:
Diego Mello 2021-06-07 17:20:07 -03:00 committed by GitHub
parent dfe9e4fccb
commit 267dfc547e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View File

@ -59,7 +59,7 @@ export default appSchema({
{ name: 'e2e_key_id', type: 'string', isOptional: true },
{ name: 'avatar_etag', type: 'string', isOptional: true },
{ name: 'team_id', type: 'string', isIndexed: true },
{ name: 'team_main', type: 'boolean', isOptional: true }
{ name: 'team_main', type: 'boolean', isOptional: true } // Use `Q.notEq(true)` to get false or null
]
}),
tableSchema({

View File

@ -72,6 +72,8 @@ const handleLeaveRoom = function* handleLeaveRoom({ room, roomType, selected })
logEvent(events.RA_LEAVE_F);
if (e.data && e.data.errorType === 'error-you-are-last-owner') {
Alert.alert(I18n.t('Oops'), I18n.t(e.data.errorType));
} else if (e?.data?.error === 'last-owner-can-not-be-removed') {
Alert.alert(I18n.t('Oops'), I18n.t(e.data.error));
} else {
Alert.alert(I18n.t('Oops'), I18n.t('There_was_an_error_while_action', { action: I18n.t('leaving_room') }));
}

View File

@ -515,7 +515,7 @@ class RoomActionsView extends React.Component {
const db = database.active;
const subCollection = db.get('subscriptions');
const teamRooms = await subCollection.query(
Q.where('team_main', Q.notEq(null))
Q.where('team_main', true)
);
if (teamRooms.length) {
@ -558,7 +558,7 @@ class RoomActionsView extends React.Component {
const teams = await db.collections
.get('subscriptions')
.query(
Q.where('team_main', Q.notEq(null)),
Q.where('team_main', true),
Q.where('name', Q.like(`%${ onChangeText }%`)),
Q.experimentalTake(QUERY_SIZE),
Q.experimentalSortBy('room_updated_at', Q.desc)

View File

@ -326,7 +326,7 @@ class RoomInfoEditView extends React.Component {
const subCollection = db.get('subscriptions');
const teamChannels = await subCollection.query(
Q.where('team_id', room.teamId),
Q.where('team_main', null)
Q.where('team_main', Q.notEq(true))
);
if (teamChannels.length) {

View File

@ -286,9 +286,7 @@ describe('Team', () => {
await element(by.text('OK')).tap();
await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);
await element(by.id('select-list-view-submit')).tap();
await waitFor(element(by.text(`You were removed from ${ team }`))).toExist().withTimeout(8000);
await element(by.text('OK')).tap();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(5000);
await waitFor(element(by.id(`rooms-list-view-item-${ team }`))).toBeNotVisible().withTimeout(60000);
});
});
});