Skip to content

Commit

Permalink
fix e2e tests on smaller screens
Browse files Browse the repository at this point in the history
  • Loading branch information
ruddell committed Apr 13, 2020
1 parent 6160812 commit d60ac81
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion boilerplate/app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DebugConfig from './debug-config'

// load font libraries for react-native-vector-icons
import Icon from 'react-native-vector-icons/FontAwesome'
Icon.loadFont();
Icon.loadFont()

if (__DEV__) {
// If ReactNative's yellow box warnings are too much, it is possible to turn
Expand Down
2 changes: 1 addition & 1 deletion boilerplate/app/modules/entities/entities-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import styles from './entities-screen.styles'
class EntitiesScreen extends React.Component {
render () {
return (
<ScrollView style={styles.container}>
<ScrollView style={styles.container} testID="entityScreenScrollList">
<Text style={styles.centerText}>JHipster Entities will appear below</Text>
{/* ignite-jhipster-entity-screen-needle */}
</ScrollView>
Expand Down
1 change: 1 addition & 0 deletions boilerplate/app/modules/home/launch-screen.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Metrics, ApplicationStyles, Colors } from '../../shared/themes/'
export default StyleSheet.create({
...ApplicationStyles.screen,
welcomeText: {
textAlign: 'center',
fontSize: 20,
color: Colors.snow,
fontWeight: '600',
Expand Down
8 changes: 7 additions & 1 deletion boilerplate/e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ const goBack = async () => {
await device.pressBack();
}
}

const scrollTo = async (fieldId, listId) => {
await waitFor(element(by.id(fieldId))).toBeVisible().whileElement(by.id(listId)).scroll(50, 'down', 0, 0)
}

module.exports = {
navigateToLoginScreen,
loginAsUser,
goBack,
logout
logout,
scrollTo,
}
6 changes: 5 additions & 1 deletion src/upgrade/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
description: 'Upgrades an existing IgniteJHipster project to the latest boilerplate code.',
run: async function (context) {
// grab some features
const { ignite, print } = context
const { ignite, print, system, parameters } = context

// load the ignite config and set the default jhipster directory
this.igniteConfig = ignite.loadIgniteConfig()
Expand All @@ -25,6 +25,10 @@ module.exports = {
const jhipsterConfig = await fs.readJson('.jhipster/yo-rc.json')
await generateFiles(context, props, jhipsterConfig)

// run prettier to pass lint on generation
const useNpm = Boolean(parameters.options.npm) || !system.which('yarn')
await system.run(`${useNpm ? 'npm' : 'yarn'} run prettier`, { stdio: 'ignore' })

Insight.trackGenerator(context, 'upgrade')
print.success(`Application successfully upgraded!`)
},
Expand Down
2 changes: 1 addition & 1 deletion templates/entity/entity-detail-screen.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class <%= props.name %>EntityDetailScreen extends React.Component {
return <View><Text>Loading...</Text></View>
}
return (
<ScrollView style={styles.container}>
<ScrollView style={styles.container} testID="<%= camelCase(props.name) %>DetailScrollView">
<Text>ID: {this.props.<%= camelCase(props.name) %>.id}</Text>
<%_ props.entityConfig.fields.forEach(function (field) { _%>
<%_ if (field.fieldType === 'LocalDate') { _%>
Expand Down
19 changes: 16 additions & 3 deletions templates/entity/entity-e2e-test.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('<%= props.name %> Screen Tests', () => {
await expect(element(by.id('launchScreen'))).toBeVisible()
await element(by.id('menuButton')).tap()
await element(by.id('entitiesDrawerButton')).tap()
await Utils.scrollTo('<%= camelCase(props.name) %>EntityScreenButton', 'entityScreenScrollList')
await element(by.id('<%= camelCase(props.name) %>EntityScreenButton')).tap()
}

Expand All @@ -40,7 +41,11 @@ describe('<%= props.name %> Screen Tests', () => {
} else if (field.fieldIsEnum) {
tcombFieldType = field.fieldType
}
if (tcombFieldType === 'String') { _%>
_%>
<%_ if (['String', 'Number'].includes(tcombFieldType)) { _%>
await Utils.scrollTo('<%= field.fieldName %>Input', '<%= camelCase(props.name) %>EditScrollView')
<%_ } _%>
<%_ if (tcombFieldType === 'String') { _%>
await element(by.id('<%= field.fieldName %>Input')).replaceText('sample-data')
<%_ } else if (tcombFieldType === 'Number') { _%>
await element(by.id('<%= field.fieldName %>Input')).replaceText('123')
Expand All @@ -60,7 +65,11 @@ describe('<%= props.name %> Screen Tests', () => {
} else if (field.fieldIsEnum) {
tcombFieldType = field.fieldType
}
if (tcombFieldType === 'String') { _%>
_%>
<%_ if (['String', 'Number'].includes(tcombFieldType)) { _%>
await Utils.scrollTo('<%= field.fieldName %>', '<%= camelCase(props.name) %>DetailScrollView')
<%_ } _%>
<%_ if (tcombFieldType === 'String') { _%>
await expect(element(by.id('<%= field.fieldName %>'))).toHaveText('<%= upperFirst(field.fieldName) %>: sample-data')
<%_ } else if (tcombFieldType === 'Number') { _%>
await expect(element(by.id('<%= field.fieldName %>'))).toHaveText('<%= upperFirst(field.fieldName) %>: 123')
Expand All @@ -80,7 +89,11 @@ describe('<%= props.name %> Screen Tests', () => {
} else if (field.fieldIsEnum) {
tcombFieldType = field.fieldType
}
if (tcombFieldType === 'String') { _%>
_%>
<%_ if (['String', 'Number'].includes(tcombFieldType)) { _%>
await Utils.scrollTo('<%= field.fieldName %>Input', '<%= camelCase(props.name) %>EditScrollView')
<%_ } _%>
<%_ if (tcombFieldType === 'String') { _%>
await element(by.id('<%= field.fieldName %>Input')).replaceText('sample-data-2')
<%_ } else if (tcombFieldType === 'Number') { _%>
await element(by.id('<%= field.fieldName %>Input')).replaceText('1234')
Expand Down
2 changes: 1 addition & 1 deletion templates/entity/entity-edit-screen.js.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class <%= props.name %>EntityEditScreen extends React.Component {
}
return (
<View style={styles.container}>
<KeyboardAwareScrollView testID='entityScrollView'>
<KeyboardAwareScrollView testID='<%= camelCase(props.name) %>EditScrollView'>
<Form
ref={c => {
this.form = c
Expand Down

0 comments on commit d60ac81

Please sign in to comment.