Skip to content

Commit

Permalink
test(creation): e2e tests for identity creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mnzaki committed Sep 12, 2019
1 parent d268196 commit 357fc71
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
38 changes: 38 additions & 0 deletions e2e/01_new_user/02_creation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect } from 'detox'
import jestExpect from 'expect'
import { readVisibleText } from 'e2e/utils'

describe('Identity Creation', () => {
describe('Entropy Screen', () => {
let entropyMsg: Detox.DetoxAny
let progressRegexp = /(\d+) %/

beforeAll(async () => {
const getStarted = element(by.id('getStarted'))
await getStarted.tap()
entropyMsg = element(by.id('entropyMsg'))
})

it('should show an entropyMsg help text at first', async () => {
await expect(entropyMsg).toBeVisible()
const text = await readVisibleText('entropyMsg')
jestExpect(text).not.toMatch(progressRegexp)
})

it('should show a percentage of entropy collected on swipe in scratchArea', async () => {
const scratchArea = element(by.id('scratchArea'))
await scratchArea.swipe('right', 'slow')
const text = await readVisibleText('entropyMsg')
jestExpect(text).toMatch(progressRegexp)

const swipeDirs: Detox.Direction[] = ['up', 'down', 'left', 'right']
for (let progress = 0; progress < 100; ) {
const text = await readVisibleText('entropyMsg')
const match = progressRegexp.exec(text)
jestExpect(match).toHaveLength(2)
progress = parseInt((match as Array<string>)[1])
await scratchArea.swipe(swipeDirs[progress % 4], 'fast')
}
})
})
})
4 changes: 2 additions & 2 deletions src/ui/registration/components/entropy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const EntropyComponent: React.SFC<Props> = props => {

return (
<Container style={styles.mainContainer}>
<Text style={textStyle}>{msg}</Text>
<View style={{ width: '100%' }}>
<Text testID="entropyMsg" style={textStyle}>{msg}</Text>
<View testID="scratchArea" style={{ width: '100%' }}>
<MaskedImageComponent disabled={progress === 1} addPoint={addPoint} />
</View>
<View style={styles.footerButton}>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/registration/containers/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const RegistrationProgressContainer: React.FunctionComponent<
<Text style={styles.text}>{I18n.t(strings.GIVE_US_A_FEW_MOMENTS)}</Text>
<Text style={styles.text}>{I18n.t(strings.TO_SET_UP_YOUR_IDENTITY)}</Text>
</View>
<View style={styles.loadingArea}>
<View testID="progressLoader" style={styles.loadingArea}>
<loaders.RippleLoader
size={80}
strokeWidth={4}
Expand All @@ -83,7 +83,7 @@ export const RegistrationProgressContainer: React.FunctionComponent<
)
})}
</View>
<View>
<View testID="progressMsg">
<Text style={styles.smallText}>{props.loadingMsg}</Text>
</View>
</View>
Expand Down

0 comments on commit 357fc71

Please sign in to comment.