Merge branch 'data-input-e2e-test' into 'master'
Adds e2e symptom data input tests and necessary testIDs to the existing components See merge request bloodyhealth/drip!244
This commit is contained in:
@@ -50,6 +50,7 @@ class Note extends SymptomView {
|
||||
this.setState({ currentValue: val })
|
||||
}}
|
||||
value={this.state.currentValue}
|
||||
testID='noteInput'
|
||||
/>
|
||||
</SymptomSection>
|
||||
</ScrollView>
|
||||
|
||||
@@ -70,6 +70,7 @@ export default class TemperatureInput extends Component {
|
||||
onChangeText={this.setTemperature}
|
||||
keyboardType='numeric'
|
||||
maxLength={5}
|
||||
testID='temperatureInput'
|
||||
/>
|
||||
<AppText style={{ marginLeft: 5 }}>°C</AppText>
|
||||
</View>
|
||||
|
||||
@@ -110,6 +110,7 @@ class Temperature extends SymptomView {
|
||||
placeholder={sharedLabels.enter}
|
||||
value={this.state.note}
|
||||
onChangeText={this.setNote}
|
||||
testID='noteInput'
|
||||
/>
|
||||
</SymptomSection>
|
||||
<SymptomSection
|
||||
|
||||
@@ -49,6 +49,7 @@ export default class TimeInput extends Component {
|
||||
style={styles.temperatureTextInput}
|
||||
onFocus={this.showTimePicker}
|
||||
value={this.props.time}
|
||||
testID='timeInput'
|
||||
/>
|
||||
<DateTimePicker
|
||||
mode="time"
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
const LocalTime = require("js-joda").LocalTime
|
||||
const ChronoUnit = require("js-joda").ChronoUnit
|
||||
|
||||
const {
|
||||
symptomValues,
|
||||
reloadApp,
|
||||
goToHomePage,
|
||||
goBack,
|
||||
} = require('./helpers')
|
||||
|
||||
const minutes = ChronoUnit.MINUTES
|
||||
let currentTime
|
||||
|
||||
const symptoms = Object.keys(symptomValues).map( symptom => {
|
||||
return symptom === 'mucus' ? 'cervical mucus' : symptom
|
||||
})
|
||||
|
||||
const navigateToSymptomView = (symptom) => {
|
||||
return element(by.text(symptom)).tap()
|
||||
}
|
||||
|
||||
const navigateToCycleDayOverview = () => {
|
||||
return element(by.text('add data for today')).tap()
|
||||
}
|
||||
|
||||
const tapExclude = () => {
|
||||
return element(by.type('android.widget.CompoundButton')).tap()
|
||||
}
|
||||
|
||||
const enterSymptomData = async (symptom) => {
|
||||
const { valuesToSelect, shouldExclude } = symptomValues[symptom]
|
||||
|
||||
for (const value of valuesToSelect) {
|
||||
await element(by.text(value)).tap()
|
||||
}
|
||||
|
||||
if (shouldExclude) {
|
||||
await tapExclude()
|
||||
}
|
||||
}
|
||||
|
||||
const formExpectedSymptomSummary = (symptom) => {
|
||||
const { valuesToSelect, shouldExclude } = symptomValues[symptom]
|
||||
let expectedText, temperature
|
||||
|
||||
switch (symptom) {
|
||||
case 'temperature':
|
||||
temperature = valuesToSelect[0]
|
||||
expectedText = `${temperature} °C - ${currentTime}`
|
||||
break
|
||||
case 'mucus':
|
||||
expectedText = `feeling: ${valuesToSelect[0]}, texture: ${valuesToSelect[1]}\n => S`
|
||||
break
|
||||
case 'cervix':
|
||||
expectedText = `opening: ${valuesToSelect[0]}, firmness: ${valuesToSelect[1]}, position: ${valuesToSelect[2]}`
|
||||
break
|
||||
case 'note':
|
||||
expectedText = valuesToSelect[0]
|
||||
break
|
||||
default: expectedText = valuesToSelect.join(', ')
|
||||
}
|
||||
|
||||
if (shouldExclude) {
|
||||
expectedText = `(${expectedText})`
|
||||
}
|
||||
|
||||
return expectedText
|
||||
}
|
||||
|
||||
const enterNote = async() => {
|
||||
const note = symptomValues['note'].valuesToSelect[0]
|
||||
await element(by.id('noteInput')).replaceText(note)
|
||||
}
|
||||
|
||||
const enterTemperature = async() => {
|
||||
const temperature = symptomValues['temperature'].valuesToSelect[0]
|
||||
currentTime = LocalTime.now().truncatedTo(minutes).toString()
|
||||
const note = symptomValues['temperature'].valuesToSelect[1]
|
||||
|
||||
await element(by.id('temperatureInput')).typeText(temperature)
|
||||
await element(by.id('timeInput')).tap()
|
||||
await element(by.text('OK')).tap()
|
||||
await element(by.id('noteInput')).replaceText(note)
|
||||
await tapExclude()
|
||||
}
|
||||
|
||||
describe('Symptom Data Input', () => {
|
||||
|
||||
before(async () => {
|
||||
await reloadApp()
|
||||
await goToHomePage()
|
||||
await navigateToCycleDayOverview()
|
||||
})
|
||||
|
||||
for (const symptom of symptoms) {
|
||||
it(`Should test ${symptom} data input.`, async () => {
|
||||
|
||||
await navigateToSymptomView(symptom)
|
||||
|
||||
let expectedSymptomSummary
|
||||
await expect(element(by.id('symptomViewTitleName').and(by.text(symptom))))
|
||||
.toBeVisible()
|
||||
|
||||
switch (symptom) {
|
||||
case 'temperature':
|
||||
await enterTemperature()
|
||||
expectedSymptomSummary = formExpectedSymptomSummary('temperature')
|
||||
break
|
||||
case 'note':
|
||||
await enterNote()
|
||||
expectedSymptomSummary = formExpectedSymptomSummary('note')
|
||||
break
|
||||
case 'cervical mucus':
|
||||
await enterSymptomData('mucus')
|
||||
expectedSymptomSummary = formExpectedSymptomSummary('mucus')
|
||||
break
|
||||
default:
|
||||
await enterSymptomData(symptom)
|
||||
expectedSymptomSummary = formExpectedSymptomSummary(symptom)
|
||||
}
|
||||
|
||||
await goBack()
|
||||
|
||||
await expect(element(by.text(expectedSymptomSummary))).toExist()
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -7,7 +7,6 @@ describe('Date', () => {
|
||||
})
|
||||
|
||||
it('should have same date when navigating between cycle day and symptom view', async () => {
|
||||
await element(by.id('licenseOkButton')).tap()
|
||||
|
||||
await element(by.text('add data for today')).tap()
|
||||
await expect(
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
const symptomValues = {
|
||||
bleeding: {
|
||||
valuesToSelect: ['spotting'],
|
||||
shouldExclude: true,
|
||||
},
|
||||
temperature: {
|
||||
valuesToSelect: ['36.63', 'This is test text'],
|
||||
shouldExclude: true,
|
||||
},
|
||||
mucus: {
|
||||
valuesToSelect: ['dry', 'creamy'],
|
||||
shouldExclude: true,
|
||||
},
|
||||
cervix: {
|
||||
valuesToSelect: ['closed', 'hard', 'low'],
|
||||
shouldExclude: true,
|
||||
},
|
||||
desire: {
|
||||
valuesToSelect: ['low'],
|
||||
shouldExclude: false,
|
||||
},
|
||||
sex: {
|
||||
valuesToSelect: ['solo', 'condom'],
|
||||
shouldExclude: false,
|
||||
},
|
||||
pain: {
|
||||
valuesToSelect: ['cramps'],
|
||||
shouldExclude: false,
|
||||
},
|
||||
mood: {
|
||||
valuesToSelect: ['happy'],
|
||||
shouldExclude: false,
|
||||
},
|
||||
note: {
|
||||
valuesToSelect: ['This is test text'],
|
||||
shouldExclude: false,
|
||||
}
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
return device.pressBack()
|
||||
}
|
||||
|
||||
function reloadApp() {
|
||||
return device.reloadReactNative()
|
||||
}
|
||||
|
||||
function goToHomePage() {
|
||||
try {
|
||||
element(by.id('licenseOkButton')).tap()
|
||||
} catch (error) {
|
||||
goBack()
|
||||
element(by.text('home')).tap()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
symptomValues,
|
||||
reloadApp,
|
||||
goToHomePage,
|
||||
goBack,
|
||||
}
|
||||
@@ -57,81 +57,4 @@ describe('Home Navigation', () => {
|
||||
await isOnPage('nfp settings', 'settings')
|
||||
await device.pressBack()
|
||||
})
|
||||
|
||||
it('should navigate to today cycle day page and all its symptoms', async () => {
|
||||
await element(by.text('add data for today')).tap()
|
||||
await expect(
|
||||
element(by.id('cycleDayTitleDate').and(by.text('today')))
|
||||
).toBeVisible()
|
||||
|
||||
await element(by.id('drip-icon-bleeding')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('bleeding')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-temperature')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('temperature')))
|
||||
).toBeVisible()
|
||||
// first back press removes the focus from the field and the input keyboard
|
||||
await device.pressBack()
|
||||
// second back press goes back to the cycle day view
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-mucus')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('cervical mucus')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-cervix')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('cervix')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-desire')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('desire')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-sex')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('sex')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-pain')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('pain')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-mood')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('mood')))
|
||||
).toBeVisible()
|
||||
await device.pressBack()
|
||||
|
||||
await element(by.id('drip-icon-note')).tap()
|
||||
await expect(
|
||||
element(by.id('symptomViewTitleName').and(by.text('note')))
|
||||
).toBeVisible()
|
||||
await element(by.id('symptomInfoButton')).tap()
|
||||
await expect(element(by.id('symptomInfoPopup'))).toBeVisible()
|
||||
|
||||
// first back press removes the focus from the field and the input keyboard
|
||||
await device.pressBack()
|
||||
// second back press goes back to the cycle day view
|
||||
await device.pressBack()
|
||||
|
||||
await expect(
|
||||
element(by.id('cycleDayTitleDate').and(by.text('today')))
|
||||
).toBeVisible()
|
||||
|
||||
// waiting for a feedback on what should happen on pressing back
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
Generated
+1915
-1917
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user