Skip to content

Commit

Permalink
feat(integration tests): added sample test that only enter a nickname…
Browse files Browse the repository at this point in the history
… on first launch and click on 'Let's chat' then check if app loaded correctly
  • Loading branch information
aeddi committed Jan 25, 2019
1 parent bec4435 commit bdce062
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 14 deletions.
2 changes: 2 additions & 0 deletions client/react-native/Makefile
Expand Up @@ -302,6 +302,8 @@ fastlane.match.adhoc:
fastlane.match.enterprise:
time bundle exec fastlane run match type:enterprise app_identifier:$(IOS_BUNDLE_ID_HOUSE) team_id:$(MATCH_ENTERPRISE_TEAM_ID)

fastlane.match.all: fastlane.match.development fastlane.match.appstore fastlane.match.adhoc fastlane.match.enterprise

fastlane.pem.development:
time bundle exec fastlane pem --app_identifier $(IOS_BUNDLE_ID_DEBUG) --team_id $(PEM_COMPANY_TEAM_ID) --pem_name $(IOS_BUNDLE_ID_DEBUG)-dev.pem --development

Expand Down
10 changes: 5 additions & 5 deletions client/react-native/common/components/App.js
Expand Up @@ -16,7 +16,7 @@ import { btoa } from 'b64-lite'
export default class App extends PureComponent {
state = {
loading: true,
hide: true,
showAnim: (process.env['ENVIRONMENT'] !== 'integration_test'),
duration: 4000,
progress: new Animated.Value(0),
deepLink: {
Expand All @@ -41,7 +41,7 @@ export default class App extends PureComponent {
}

Linking.addEventListener('url', this._handleOpenURL)
this.startAnimation()
if (this.state.showAnim === true) { this.startAnimation() }
this.setState({ loading: false })
}

Expand Down Expand Up @@ -100,7 +100,7 @@ export default class App extends PureComponent {
easing: Easing.linear,
}).start(({ finished }) => {
if (finished) {
this.setState({ hide: false })
this.setState({ showAnim: false })
}
})
}
Expand All @@ -114,11 +114,11 @@ export default class App extends PureComponent {
}

render () {
const { loading, deepLink, hide, progress } = this.state
const { loading, deepLink, showAnim, progress } = this.state
return (
<I18nextProvider i18n={i18n}>
<SafeAreaView style={{ flex: 1 }} forceInset={{ bottom: 'never' }}>
{ hide && Platform.OS !== 'web'
{ showAnim && Platform.OS !== 'web'
? <Flex.Rows
align='center'
justify='center'
Expand Down
3 changes: 2 additions & 1 deletion client/react-native/common/components/Library/EmptyList.js
Expand Up @@ -18,7 +18,7 @@ export default class EmptyList extends PureComponent {
}

render () {
const { source, text, onPress, icon, btnText } = this.props
const { source, text, onPress, icon, btnText, btnRef } = this.props
const fontSize = this.state.fontWidth * 0.07

return (
Expand Down Expand Up @@ -49,6 +49,7 @@ export default class EmptyList extends PureComponent {
}}
>
<View
ref={btnRef}
style={{
flex: 1,
flexDirection: 'row',
Expand Down
Expand Up @@ -12,6 +12,8 @@ import { colors } from '../../../constants'
import { defaultUsername } from '../../../helpers/contacts'
import { withNamespaces } from 'react-i18next'

import { hook } from 'cavy'

const { CoreModule } = NativeModules

class Auth extends PureComponent {
Expand Down Expand Up @@ -144,16 +146,17 @@ class Auth extends PureComponent {
padding: 10,
}}
placeholder={t('auth.nickname-placeholder')}
ref={nicknameInput => {
ref={this.props.generateTestHook('Auth.TextInput', nicknameInput => {
this.nicknameInput = nicknameInput
}}
})}
textContentType={'name'}
onChangeText={nickname => this.setState({ nickname })}
value={this.state.nickname}
/>
<TouchableOpacity
onPress={() => this.open(this.state.nickname, { firstLaunch: true })}
disabled={this.state.nickname.length === 0}
ref={this.props.generateTestHook('Auth.Button')}
>
<Text
style={{
Expand All @@ -178,4 +181,4 @@ class Auth extends PureComponent {
}
}

export default withNamespaces()(Auth)
export default withNamespaces()(hook(Auth))
7 changes: 6 additions & 1 deletion client/react-native/common/components/Screens/Chats/List.js
Expand Up @@ -11,6 +11,8 @@ import { fragments } from '../../../graphql'
import { parseEmbedded } from '../../../helpers/json'
import { conversation as utils } from '../../../utils'

import { hook } from 'cavy'

const Message = withNamespaces()(({ data, t, ...props }) => {
switch (data.kind) {
case BertyP2pKindInputKind.ConversationNewMessage:
Expand Down Expand Up @@ -112,7 +114,7 @@ const ItemBase = fragments.Conversation(({ data, navigation, t }) => {

const Item = withNamespaces()(ItemBase)

export default class ListScreen extends PureComponent {
class ListScreen extends PureComponent {
static navigationOptions = ({ navigation }) => ({
header: (
<Header
Expand Down Expand Up @@ -160,6 +162,7 @@ export default class ListScreen extends PureComponent {
source={require('../../../static/img/empty-conversation.png')}
text={I18n.t('chats.no-new-messages')}
icon={'edit'}
btnRef={this.props.generateTestHook('ChatList.NewConvButton')}
btnText={I18n.t('chats.new-conversation')}
onPress={() => ListScreen.onPress(navigation)}
/>
Expand All @@ -169,3 +172,5 @@ export default class ListScreen extends PureComponent {
)
}
}

export default hook(ListScreen)
4 changes: 3 additions & 1 deletion client/react-native/common/components/Screens/Main.js
Expand Up @@ -106,7 +106,9 @@ class Picker extends React.Component {
super(props)

this.props.navigation.navigate(
this.props.screenProps.firstLaunch
// TODO: when will find a way to use all our components in Library, implement skip of onboarding in test replace the next line by:
// this.props.screenProps.firstLaunch || process.env['ENVIRONMENT'] === 'integration_test'
this.props.screenProps.firstLaunch && process.env['ENVIRONMENT'] !== 'integration_test'
? 'switch/onboarding'
: 'switch/main'
)
Expand Down
25 changes: 25 additions & 0 deletions client/react-native/common/integration/tests/AppLoading.js
@@ -0,0 +1,25 @@
import { Platform } from 'react-native'

export default function (spec) {
spec.describe('App loading', function () {
spec.it('works', async function () {
const androidLoadingTimeout = 30000
const iosLoadingTimeout = 10000
const webLoadingTimeout = 2000
const loadingTimeout = () => {
switch (Platform.OS) {
case 'web': return webLoadingTimeout
case 'android': return androidLoadingTimeout
case 'ios': return iosLoadingTimeout
default: return 0
}
}

console.info('Wait for app loaded - timeout ' + (loadingTimeout() / 1000) + ' sec')
await spec.pause(loadingTimeout())

console.info('Check if empty conversation list loaded correctly')
await spec.exists('ChatList.NewConvButton')
})
})
}
7 changes: 7 additions & 0 deletions client/react-native/common/integration/tests/Chat.js
@@ -0,0 +1,7 @@
export default function (spec) {
spec.describe('Chat', function () {
spec.it('works', async function () {
console.warn('Chat test is empty')
})
})
}
7 changes: 7 additions & 0 deletions client/react-native/common/integration/tests/Contact.js
@@ -0,0 +1,7 @@
export default function (spec) {
spec.describe('Contact', function () {
spec.it('works', async function () {
console.warn('Contact test is empty')
})
})
}
7 changes: 7 additions & 0 deletions client/react-native/common/integration/tests/DevTools.js
@@ -0,0 +1,7 @@
export default function (spec) {
spec.describe('DevTools', function () {
spec.it('works', async function () {
console.warn('DevTools is empty')
})
})
}
27 changes: 27 additions & 0 deletions client/react-native/common/integration/tests/Onboarding.js
@@ -0,0 +1,27 @@
export default function (spec) {
spec.describe('Onboarding', function () {
spec.it('works', async function () {
let authScreenExists
const nickname = process.env['NICKNAME'] || 'Berty'

try {
await spec.exists('Auth.TextInput')
authScreenExists = true
} catch (error) {
authScreenExists = false
}

if (authScreenExists === true) {
await spec.pause(2400)
console.info('Fill text input with nickname "' + nickname + '"')
await spec.fillIn('Auth.TextInput', nickname)

await spec.pause(2400)
console.info('Press validation button')
await spec.press('Auth.Button')
} else {
console.log('Auth screen skipped')
}
})
})
}
1 change: 0 additions & 1 deletion client/react-native/ios/Berty.xcodeproj/project.pbxproj
Expand Up @@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
Expand Down
4 changes: 2 additions & 2 deletions client/react-native/ios/Berty/Info.plist
Expand Up @@ -32,7 +32,7 @@
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<string/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand All @@ -51,7 +51,7 @@
<key>NSCameraUsageDescription</key>
<string>Berty would like to use your camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<string/>
<key>NSMicrophoneUsageDescription</key>
<string>Berty would like to use your microphone (for videos)</string>
<key>NSPhotoLibraryAddUsageDescription</key>
Expand Down

0 comments on commit bdce062

Please sign in to comment.