Fix new server view

This commit is contained in:
Reinaldo Neto 2021-09-15 13:44:53 -03:00
parent 6008b9cacb
commit 1a63e80861
8 changed files with 50 additions and 59 deletions

View File

@ -772,5 +772,6 @@
"Converting_Team_To_Channel": "Converting Team to Channel", "Converting_Team_To_Channel": "Converting Team to Channel",
"Select_Team_Channels_To_Delete": "Select the Teams Channels you would like to delete, the ones you do not select will be moved to the Workspace. \n\nNotice that public Channels will be public and visible to everyone.", "Select_Team_Channels_To_Delete": "Select the Teams Channels you would like to delete, the ones you do not select will be moved to the Workspace. \n\nNotice that public Channels will be public and visible to everyone.",
"You_are_converting_the_team": "You are converting this Team to a Channel", "You_are_converting_the_team": "You are converting this Team to a Channel",
"creating_discussion": "creating discussion" "creating_discussion": "creating discussion",
"Rocket_Chat": "Rocket.Chat"
} }

View File

@ -1,7 +1,6 @@
import React from 'react'; import React from 'react';
import { createStackNavigator } from '@react-navigation/stack'; import { createStackNavigator } from '@react-navigation/stack';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { ThemeContext } from '../theme'; import { ThemeContext } from '../theme';
import { import {
@ -9,7 +8,6 @@ import {
} from '../utils/navigation'; } from '../utils/navigation';
// Outside Stack // Outside Stack
import OnboardingView from '../views/OnboardingView';
import NewServerView from '../views/NewServerView'; import NewServerView from '../views/NewServerView';
import WorkspaceView from '../views/WorkspaceView'; import WorkspaceView from '../views/WorkspaceView';
import LoginView from '../views/LoginView'; import LoginView from '../views/LoginView';
@ -17,22 +15,14 @@ import ForgotPasswordView from '../views/ForgotPasswordView';
import RegisterView from '../views/RegisterView'; import RegisterView from '../views/RegisterView';
import LegalView from '../views/LegalView'; import LegalView from '../views/LegalView';
import AuthenticationWebView from '../views/AuthenticationWebView'; import AuthenticationWebView from '../views/AuthenticationWebView';
import { ROOT_OUTSIDE } from '../actions/app';
// Outside // Outside
const Outside = createStackNavigator(); const Outside = createStackNavigator();
const _OutsideStack = ({ root }) => { const _OutsideStack = () => {
const { theme } = React.useContext(ThemeContext); const { theme } = React.useContext(ThemeContext);
return ( return (
<Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}> <Outside.Navigator screenOptions={{ ...defaultHeader, ...themedHeader(theme), ...StackAnimation }}>
{root === ROOT_OUTSIDE ? (
<Outside.Screen
name='OnboardingView'
component={OnboardingView}
options={OnboardingView.navigationOptions}
/>
) : null}
<Outside.Screen <Outside.Screen
name='NewServerView' name='NewServerView'
component={NewServerView} component={NewServerView}
@ -71,10 +61,6 @@ const mapStateToProps = state => ({
root: state.app.root root: state.app.root
}); });
_OutsideStack.propTypes = {
root: PropTypes.string
};
const OutsideStack = connect(mapStateToProps)(_OutsideStack); const OutsideStack = connect(mapStateToProps)(_OutsideStack);
// OutsideStackModal // OutsideStackModal

View File

@ -11,7 +11,6 @@ import I18n from '../../../i18n';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
zIndex: 1, zIndex: 1,
marginTop: 24,
marginBottom: 32 marginBottom: 32
}, },
inputContainer: { inputContainer: {

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { import {
Text, Keyboard, StyleSheet, View, BackHandler Text, Keyboard, StyleSheet, View, BackHandler, Image
} from 'react-native'; } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -30,11 +30,30 @@ import ServerInput from './ServerInput';
import { sanitizeLikeString } from '../../lib/database/utils'; import { sanitizeLikeString } from '../../lib/database/utils';
import SSLPinning from '../../utils/sslPinning'; import SSLPinning from '../../utils/sslPinning';
import RocketChat from '../../lib/rocketchat'; import RocketChat from '../../lib/rocketchat';
import { isTablet } from '../../utils/deviceInfo';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
onboarding: {
alignSelf: 'center',
marginTop: isTablet ? 0 : 96,
marginBottom: 25,
maxHeight: 150,
width: 100,
height: 100
},
title: { title: {
...sharedStyles.textBold, ...sharedStyles.textBold,
fontSize: 22 letterSpacing: 0,
fontSize: 22,
alignSelf: 'center',
marginBottom: 8,
lineHeight: 32
},
subtitle: {
...sharedStyles.textRegular,
fontSize: 16,
alignSelf: 'center',
marginBottom: 41
}, },
certificatePicker: { certificatePicker: {
marginBottom: 32, marginBottom: 32,
@ -52,7 +71,7 @@ const styles = StyleSheet.create({
description: { description: {
...sharedStyles.textRegular, ...sharedStyles.textRegular,
fontSize: 14, fontSize: 14,
textAlign: 'left', textAlign: 'center',
marginBottom: 24 marginBottom: 24
}, },
connectButton: { connectButton: {
@ -61,9 +80,9 @@ const styles = StyleSheet.create({
}); });
class NewServerView extends React.Component { class NewServerView extends React.Component {
static navigationOptions = () => ({ static navigationOptions = {
title: I18n.t('Workspaces') headerShown: false
}) };
static propTypes = { static propTypes = {
navigation: PropTypes.object, navigation: PropTypes.object,
@ -321,7 +340,9 @@ class NewServerView extends React.Component {
keyboardShouldPersistTaps='never' keyboardShouldPersistTaps='never'
> >
<FormContainerInner> <FormContainerInner>
<Text style={[styles.title, { color: themes[theme].titleText }]}>{I18n.t('Join_your_workspace')}</Text> <Image style={styles.onboarding} source={require('../../static/images/logo.png')} fadeDuration={0} resizeMode='stretch' />
<Text style={[styles.title, { color: themes[theme].titleText }]}>{I18n.t('Rocket_Chat')}</Text>
<Text style={[styles.subtitle, { color: themes[theme].controlText }]}>{I18n.t('Onboarding_subtitle')}</Text>
<ServerInput <ServerInput
text={text} text={text}
theme={theme} theme={theme}

View File

@ -1,8 +1,6 @@
const data = require('../data'); const data = require('../data');
async function navigateToWorkspace(server = data.server) { async function navigateToWorkspace(server = data.server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${ server }\n`); await element(by.id('new-server-view-input')).typeText(`${ server }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
@ -10,7 +8,6 @@ async function navigateToWorkspace(server = data.server) {
} }
async function navigateToLogin(server) { async function navigateToLogin(server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
await navigateToWorkspace(server); await navigateToWorkspace(server);
await element(by.id('workspace-view-login')).tap(); await element(by.id('workspace-view-login')).tap();
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
@ -18,7 +15,6 @@ async function navigateToLogin(server) {
} }
async function navigateToRegister(server) { async function navigateToRegister(server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
await navigateToWorkspace(server); await navigateToWorkspace(server);
await element(by.id('workspace-view-register')).tap(); await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
@ -44,8 +40,8 @@ async function logout() {
await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000); await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000);
await expect(element(by.text(logoutAlertMessage)).atIndex(0)).toExist(); await expect(element(by.text(logoutAlertMessage)).atIndex(0)).toExist();
await element(by.text('Logout')).tap(); await element(by.text('Logout')).tap();
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(10000);
await expect(element(by.id('onboarding-view'))).toBeVisible(); await expect(element(by.id('new-server-view'))).toBeVisible();
} }
async function mockMessage(message, isThread = false) { async function mockMessage(message, isThread = false) {

View File

@ -3,7 +3,7 @@ const { navigateToLogin, login, checkServer } = require('../../helpers/app');
const reopenAndCheckServer = async(server) => { const reopenAndCheckServer = async(server) => {
await device.launchApp({ permissions: { notifications: 'YES' } }); await device.launchApp({ permissions: { notifications: 'YES' } });
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(6000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkServer(server); await checkServer(server);
}; };
@ -15,11 +15,15 @@ describe('Change server', () => {
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
}); });
it('should login to server, add new server, close the app, open the app and show previous logged server', async() => { it('should open the dropdown button, have the server add button and create workspace button', async() => {
await element(by.id('rooms-list-header-server-dropdown-button')).tap(); await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await element(by.id('rooms-list-header-server-add')).tap(); await waitFor(element(by.id('rooms-list-header-server-add'))).toBeVisible().withTimeout(5000);
await waitFor(element(by.id('rooms-list-header-create-workspace-button'))).toBeVisible().withTimeout(5000);
});
it('should login to server, add new server, close the app, open the app and show previous logged server', async() => {
await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(6000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(6000);
await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`); await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);

View File

@ -28,9 +28,8 @@ describe('i18n', () => {
}, },
delete: true delete: true
}); });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(20000);
await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible(); await expect(element(by.id('new-server-view-open').and(by.label('Join our open workspace')))).toBeVisible();
await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible();
}); });
it('OS set to unavailable language and fallback to \'en\'', async() => { it('OS set to unavailable language and fallback to \'en\'', async() => {
@ -41,9 +40,8 @@ describe('i18n', () => {
locale: 'es-MX' locale: 'es-MX'
} }
}); });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(20000);
await expect(element(by.id('join-workspace').and(by.label('Join a workspace')))).toBeVisible(); await expect(element(by.id('new-server-view-open').and(by.label('Join our open workspace')))).toBeVisible();
await expect(element(by.id('create-workspace-button').and(by.label('Create a new workspace')))).toBeVisible();
}); });
/** /**
@ -58,9 +56,6 @@ describe('i18n', () => {
// locale: "nl" // locale: "nl"
// } // }
// }); // });
// await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000);
// await expect(element(by.id('join-workspace').and(by.label('Word lid van een werkruimte')))).toBeVisible();
// await expect(element(by.id('create-workspace-button').and(by.label('Een nieuwe werkruimte aanmaken')))).toBeVisible();
// }); // });
}); });

View File

@ -3,20 +3,16 @@ const data = require('../../data');
describe('Onboarding', () => { describe('Onboarding', () => {
before(async() => { before(async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true }); await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(20000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(20000);
}); });
describe('Render', () => { describe('Render', () => {
it('should have onboarding screen', async() => { it('should have onboarding screen as New Server View', async() => {
await expect(element(by.id('onboarding-view'))).toBeVisible(); await expect(element(by.id('new-server-view'))).toBeVisible();
}); });
it('should have "Join a workspace"', async() => { it('should have "Join our open workspace"', async() => {
await expect(element(by.id('join-workspace'))).toBeVisible(); await expect(element(by.id('new-server-view-open'))).toBeVisible();
});
it('should have "Create a new workspace"', async() => {
await expect(element(by.id('create-workspace-button'))).toBeVisible();
}); });
}); });
@ -25,11 +21,6 @@ describe('Onboarding', () => {
// // webviews are not supported by detox: https://github.com/wix/detox/issues/136#issuecomment-306591554 // // webviews are not supported by detox: https://github.com/wix/detox/issues/136#issuecomment-306591554
// }); // });
it('should navigate to join a workspace', async() => {
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
});
it('should enter an invalid server and get error', async() => { it('should enter an invalid server and get error', async() => {
await element(by.id('new-server-view-input')).typeText('invalidtest\n'); await element(by.id('new-server-view-input')).typeText('invalidtest\n');
const errorText = 'Oops!'; const errorText = 'Oops!';
@ -44,9 +35,7 @@ describe('Onboarding', () => {
it('should enter a valid server without login services and navigate to login', async() => { it('should enter a valid server without login services and navigate to login', async() => {
await device.launchApp({ newInstance: true }); await device.launchApp({ newInstance: true });
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(5000);
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${ data.server }\n`); await element(by.id('new-server-view-input')).typeText(`${ data.server }\n`);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
}); });