Skip to content

Commit

Permalink
New cases with repeat group (getodk#3603)
Browse files Browse the repository at this point in the history
* Added test for the case when page behind a repeat group with a regular group inside is visible

* Added test for breadcrumb path on hierarchy view

* Added test for dynamic group label
  • Loading branch information
mmarciniak90 authored and grzesiek2010 committed Jan 21, 2020
1 parent edb3d8c commit e20bdb5
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 1 deletion.
138 changes: 138 additions & 0 deletions collect_app/src/androidTest/assets/forms/RepeatTitles_1648.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
<h:head>
<h:title>Repeat titles 1648</h:title>
<model>
<instance>
<data id="build_1648_1511357420">
<meta>
<instanceID/>
</meta>
<Text/>
<gr1>
<gr2>
<name/>
<age/>
<photo/>
</gr2>
</gr1>
<part1>
<part2>
<partText/>
<date/>
<multi/>
</part2>
</part1>
</data>
</instance>
<itext>
<translation lang="English">
<text id="/data/Text:label">
<value>Text</value>
</text>
<text id="/data/gr1:label">
<value>gr1</value>
</text>
<text id="/data/gr1/gr2:label">
<value>gr2</value>
</text>
<text id="/data/gr1/gr2/name:label">
<value>Name</value>
</text>
<text id="/data/gr1/gr2/age:label">
<value>Age</value>
</text>
<text id="/data/gr1/gr2/photo:label">
<value>Photo</value>
</text>
<text id="/data/part1:label">
<value>Part1</value>
</text>
<text id="/data/part1/part2:label">
<value>Part2</value>
</text>
<text id="/data/part1/part2/partText:label">
<value>Part text</value>
</text>
<text id="/data/part1/part2/date:label">
<value>Date</value>
</text>
<text id="/data/part1/part2/multi:label">
<value>Multi Select</value>
</text>
<text id="/data/part1/part2/multi:hint">
<value></value>
</text>
<text id="/data/part1/part2/multi:option0">
<value>a</value>
</text>
<text id="/data/part1/part2/multi:option1">
<value>b</value>
</text>
<text id="/data/part1/part2/multi:option2">
<value>c</value>
</text>
</translation>
</itext>
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
<bind nodeset="/data/Text" type="string"/>
<bind nodeset="/data/gr1/gr2/name" type="string"/>
<bind nodeset="/data/gr1/gr2/age" type="int"/>
<bind nodeset="/data/gr1/gr2/photo" type="binary"/>
<bind nodeset="/data/part1/part2/partText" type="string"/>
<bind nodeset="/data/part1/part2/date" type="date"/>
<bind nodeset="/data/part1/part2/multi" type="select"/>
</model>
</h:head>
<h:body>
<input ref="/data/Text">
<label ref="jr:itext('/data/Text:label')"/>
</input>
<group>
<label ref="jr:itext('/data/gr1:label')"/>
<repeat nodeset="/data/gr1">
<group ref="/data/gr1/gr2">
<label> Person: <output value="/data/gr1/gr2/age"/></label>
<input ref="/data/gr1/gr2/name">
<label ref="jr:itext('/data/gr1/gr2/name:label')"/>
</input>
<input ref="/data/gr1/gr2/age">
<label ref="jr:itext('/data/gr1/gr2/age:label')"/>
</input>
<upload ref="/data/gr1/gr2/photo" mediatype="image/*">
<label ref="jr:itext('/data/gr1/gr2/photo:label')"/>
</upload>
</group>
</repeat>
</group>
<group>
<label ref="jr:itext('/data/part1:label')"/>
<repeat nodeset="/data/part1">
<group ref="/data/part1/part2">
<label> Xxx: <output value="/data/part1/part2/partText"/></label>
<input ref="/data/part1/part2/partText">
<label ref="jr:itext('/data/part1/part2/partText:label')"/>
</input>
<input ref="/data/part1/part2/date">
<label ref="jr:itext('/data/part1/part2/date:label')"/>
</input>
<select ref="/data/part1/part2/multi">
<label ref="jr:itext('/data/part1/part2/multi:label')"/>
<hint ref="jr:itext('/data/part1/part2/multi:hint')"/>
<item>
<label ref="jr:itext('/data/part1/part2/multi:option0')"/>
<value>a</value>
</item>
<item>
<label ref="jr:itext('/data/part1/part2/multi:option1')"/>
<value>b</value>
</item>
<item>
<label ref="jr:itext('/data/part1/part2/multi:option2')"/>
<value>c</value>
</item>
</select>
</group>
</repeat>
</group>
</h:body>
</h:html>
51 changes: 51 additions & 0 deletions collect_app/src/androidTest/assets/forms/repeat_group_new.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa">
<h:head>
<h:title>RepeatGroupNew</h:title>
<model>
<instance>
<data id="build_Untitled-Form_150757354889">
<meta>
<instanceID/>
</meta>
<RepeatGroup jr:template="">
<Name/>
<Age/>
</RepeatGroup>
</data>
</instance>
<itext>
<translation lang="English">
<text id="/data/RepeatGroup:label">
<value>RepeatGroup</value>
</text>
<text id="/data/RepeatGroup/Name:label">
<value>Name</value>
</text>
<text id="/data/RepeatGroup/Age:label">
<value>Age</value>
</text>
</translation>
</itext>
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/>
<bind nodeset="/data/RepeatGroup/Name" type="string"/>
<bind nodeset="/data/RepeatGroup/Age" type="int"/>
</model>
</h:head>
<h:body>
<group>
<label>People</label>
<repeat nodeset="/data/RepeatGroup">
<group>
<label>Person: <output value="/data/RepeatGroup/Name"/></label>
<input ref="/data/RepeatGroup/Name">
<label ref="jr:itext('/data/RepeatGroup/Name:label')"/>
</input>
<input ref="/data/RepeatGroup/Age">
<label ref="jr:itext('/data/RepeatGroup/Age:label')"/>
</input>
</group>
</repeat>
</group>

</h:body>
</h:html>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class FillBlankFormWithRepeatGroupTest extends BaseRegressionTest {
.around(new CopyFormRule("form9.xml"))
.around(new CopyFormRule("RepeatGroupAndGroup.xml"))
.around(new CopyFormRule("basic.xml"))
.around(new CopyFormRule("repeat_group_form.xml"));
.around(new CopyFormRule("repeat_group_form.xml"))
.around(new CopyFormRule("repeat_group_new.xml"))
.around(new CopyFormRule("RepeatTitles_1648.xml"));

@Test
public void whenNoRepeatGroupAdded_ShouldNotDoubleLastQuestion() {
Expand All @@ -61,6 +63,40 @@ public void whenNoRepeatGroupAdded_ShouldNotDoubleLastQuestion() {
.clickSaveAndExit();
}

@Test
public void dynamicGroupLabel_should_beCalculatedProperly() {

//TestCase3
new MainMenuPage(rule)
.startBlankForm("Repeat titles 1648")
.inputText("test")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("FirstPerson")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("25")
.closeSoftKeyboard()
.swipeToNextQuestion()
.checkIsTextDisplayed("gr1 > 1 > Person: 25")
.clickGoToArrow()
.checkIsTextDisplayed("gr1 > 1 > Person: 25")
.clickOnText("Photo")
.swipeToNextQuestion()
.clickOnDoNotAddGroup()
.inputText("SecondPart")
.closeSoftKeyboard()
.swipeToNextQuestion()
.checkIsTextDisplayed("Part1 > 1 > Xxx: SecondPart")
.clickGoToArrow()
.checkIsTextDisplayed("Part1 > 1 > Xxx: SecondPart")
.clickOnText("Date")
.swipeToNextQuestion()
.swipeToNextQuestion()
.clickOnDoNotAddGroup()
.clickSaveAndExit();
}

@Test
public void nestedGroupsWithFieldListAppearance_ShouldBeAbleToFillTheForm() {

Expand Down Expand Up @@ -162,6 +198,74 @@ public void whenNoRepeatGroupAdded_ShouldBackwardButtonBeClickable() {
.clickSaveAndExit();
}

@Test
public void when_pageBehindRepeatGroupWithRegularGroupInsideIsVisible_should_swipeBackWork() {

//TestCase7
new MainMenuPage(rule)
.startBlankFormWithRepeatGroup("RepeatGroupNew")
.clickOnAddGroup(new FormEntryPage("RepeatGroupNew", rule))
.inputText("A")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("1")
.closeSoftKeyboard()
.swipeToNextQuestion()
.clickOnAddGroup()
.inputText("B")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("2")
.closeSoftKeyboard()
.swipeToNextQuestion()
.clickOnAddGroup()
.inputText("C")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("3")
.closeSoftKeyboard()
.swipeToNextQuestion()
.clickOnDoNotAddGroup()
.swipeToPreviousQuestion()
.checkIsTextDisplayed("3")
.swipeToNextQuestion()
.clickOnDoNotAddGroup()
.clickSaveAndExit();
}

@Test
public void when_navigateOnHierarchyView_should_breadcrumbPathBeVisible() {

//TestCase8
new MainMenuPage(rule)
.startBlankFormWithRepeatGroup("RepeatGroupNew")
.clickOnAddGroup(new FormEntryPage("RepeatGroupNew", rule))
.inputText("A")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("1")
.closeSoftKeyboard()
.swipeToNextQuestion()
.clickOnAddGroup()
.inputText("B")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("2")
.closeSoftKeyboard()
.swipeToNextQuestion()
.clickOnAddGroup()
.inputText("C")
.closeSoftKeyboard()
.swipeToNextQuestion()
.inputText("3")
.clickGoToArrow()
.checkIsTextDisplayed("People > 3 > Person: C")
.clickGoUpIcon()
.checkIsTextDisplayed("3.\u200E Person: C")
.clickJumpEndButton()
.clickSaveAndExit();
}

@Test
public void firstQuestionWithLongLabel_ShouldDisplayBothAnswersInHierarchyPage() {

Expand Down

0 comments on commit e20bdb5

Please sign in to comment.