-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store shared entities for follow up forms #6108
Changes from 34 commits
96200a0
1b58dd3
4c9933b
6df93d5
06c3fa7
822a964
5c9e999
adefa58
7007f4f
dd353b3
2e75373
67eaeae
cbcfa5d
7a01eae
6621684
6b1ebba
97f5722
5c38ca9
2bed805
1f34eb3
322130e
1cc9f97
c9532cc
1ffc276
9497a37
251f0e9
6b70a0b
d577bdc
5de51a4
4afc2b5
998871f
d792337
bda9c3e
73f533a
9142929
8421443
4d4b8d3
42d8478
3caca3a
6ac28fd
a9f9e50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.odk.collect.android.feature.entitymanagement | ||
|
||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.RuleChain | ||
import org.odk.collect.android.support.TestDependencies | ||
import org.odk.collect.android.support.pages.FormEntryPage | ||
import org.odk.collect.android.support.rules.CollectTestRule | ||
import org.odk.collect.android.support.rules.TestRuleChain | ||
|
||
class ViewEntitiesTest { | ||
|
||
private val rule = CollectTestRule(useDemoProject = false) | ||
private val testDependencies = TestDependencies() | ||
|
||
@get:Rule | ||
val ruleChain: RuleChain = TestRuleChain.chain(testDependencies) | ||
.around(rule) | ||
|
||
@Test | ||
fun canViewLocallyCreatedEntitiesInBrowser() { | ||
testDependencies.server.addForm("one-question-entity-registration.xml") | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.addEntityListInBrowser("people") | ||
.startBlankForm("One Question Entity Registration") | ||
.fillOutAndFinalize(FormEntryPage.QuestionAndAnswer("Name", "Logan Roy")) | ||
.openEntityBrowser() | ||
.clickOnDataset("people") | ||
.assertEntity("Logan Roy", "full_name: Logan Roy") | ||
} | ||
|
||
@Test | ||
fun canViewListEntitiesInBrowser() { | ||
testDependencies.server.addForm("one-question-entity-follow-up.xml", listOf("people.csv")) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.addEntityListInBrowser("people") | ||
.refreshForms() | ||
.openEntityBrowser() | ||
.clickOnDataset("people") | ||
.assertEntity("Roman Roy", "full_name: Roman Roy") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import org.junit.rules.RuleChain | |
import org.junit.runner.RunWith | ||
import org.odk.collect.android.support.TestDependencies | ||
import org.odk.collect.android.support.pages.FormEntryPage | ||
import org.odk.collect.android.support.pages.MainMenuPage | ||
import org.odk.collect.android.support.rules.CollectTestRule | ||
import org.odk.collect.android.support.rules.TestRuleChain | ||
|
||
|
@@ -21,15 +22,20 @@ class EntityFormTest { | |
.around(rule) | ||
|
||
@Test | ||
fun fillingEntityRegistrationForm_createsEntityInTheBrowser() { | ||
fun fillingEntityRegistrationForm_beforeCreatingEntityList_doesNotCreateEntityForFollowUpForms() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This title sounds confusing to me similar to #6108 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You "create an entity list" in the browser using the "Add entity list" flow. Does that make sense or do you think it needs updated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But you don't do that here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right. That's the "beforeCreatingEntityList" part. I'm testing that we don't create entities if we haven't manually created an entity list yet. |
||
testDependencies.server.addForm("one-question-entity-registration.xml") | ||
testDependencies.server.addForm("one-question-entity-update.xml", listOf("people.csv")) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.enableLocalEntitiesInForms() | ||
|
||
.startBlankForm("One Question Entity Registration") | ||
.fillOutAndFinalize(FormEntryPage.QuestionAndAnswer("Name", "Logan Roy")) | ||
.openEntityBrowser() | ||
.clickOnDataset("people") | ||
.assertEntity("Logan Roy", "full_name: Logan Roy") | ||
|
||
.startBlankForm("One Question Entity Update") | ||
.assertQuestion("Select person") | ||
.assertText("Roman Roy") | ||
.assertTextDoesNotExist("Logan Roy") | ||
} | ||
|
||
@Test | ||
|
@@ -38,7 +44,7 @@ class EntityFormTest { | |
testDependencies.server.addForm("one-question-entity-update.xml", listOf("people.csv")) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.enableLocalEntitiesInForms() | ||
.setupEntities("people") | ||
|
||
.startBlankForm("One Question Entity Registration") | ||
.fillOutAndFinalize(FormEntryPage.QuestionAndAnswer("Name", "Logan Roy")) | ||
|
@@ -55,7 +61,7 @@ class EntityFormTest { | |
testDependencies.server.addForm("one-question-entity-update.xml", listOf("people.csv")) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.enableLocalEntitiesInForms() | ||
.setupEntities("people") | ||
|
||
.startBlankForm("One Question Entity Update") // Open to create cached form def | ||
.pressBackAndDiscardForm() | ||
|
@@ -74,7 +80,7 @@ class EntityFormTest { | |
testDependencies.server.addForm("one-question-entity-update.xml", listOf("people.csv")) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.enableLocalEntitiesInForms() | ||
.setupEntities("people") | ||
|
||
.startBlankForm("One Question Entity Update") | ||
.assertQuestion("Select person") | ||
|
@@ -90,54 +96,39 @@ class EntityFormTest { | |
} | ||
|
||
@Test | ||
fun fillingEntityFollowUpForm_whenOnlineDuplicateHasHigherVersion_showsOnlineVersion() { | ||
testDependencies.server.addForm("one-question-entity-update.xml", listOf("people.csv")) | ||
|
||
val mainMenuPage = rule.withMatchExactlyProject(testDependencies.server.url) | ||
fun entityListsAreConsistentBetweenFollowUpForms() { | ||
seadowg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testDependencies.server.apply { | ||
addForm( | ||
"one-question-entity-update.xml", | ||
listOf("people.csv") | ||
) | ||
|
||
addForm( | ||
"one-question-entity-follow-up.xml", | ||
mapOf("people.csv" to "updated-people.csv") | ||
) | ||
} | ||
|
||
rule.withProject(testDependencies.server) | ||
.enableLocalEntitiesInForms() | ||
.addEntityListInBrowser("people") | ||
|
||
.clickGetBlankForm() | ||
.clickClearAll() | ||
.clickForm("one-question-entity-update.xml") | ||
.clickGetSelected() | ||
.clickOK(MainMenuPage()) | ||
.startBlankForm("One Question Entity Update") | ||
.assertQuestion("Select person") | ||
.clickOnText("Roman Roy") | ||
.swipeToNextQuestion("Name") | ||
.answerQuestion("Name", "Romulus Roy") | ||
.swipeToEndScreen() | ||
.clickFinalize() | ||
|
||
testDependencies.server.updateMediaFile( | ||
"one-question-entity-update.xml", | ||
"people.csv", | ||
"updated-people.csv" | ||
) | ||
.assertText("Roman Roy") | ||
.pressBackAndDiscardForm() | ||
|
||
mainMenuPage.clickFillBlankForm() | ||
.clickRefresh() | ||
.clickOnForm("One Question Entity Update") | ||
.clickGetBlankForm() | ||
.clickClearAll() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why those forms are both selected here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to specifically download 'one-question-entity-follow-up.xml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it makes sense but my question was about something else. Once you download the first form and open the list of forms to download again the one you already have should be unselected by default. It seems like both are selected as if the first one was removed or not downloaded at all yet. You shouldn't need to click the clear button and then select that form because the form you want to download should be the only one selected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah got you! I think I'd still prefer the "clear all" to make it explicit I'm selecting that form. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, I think you don't. Please run that test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry! That'll be the brain fog last week. I see what you mean: it's weird that both forms are selected. I'm guessing this is a problem with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it's because |
||
.clickForm("one-question-entity-follow-up.xml") | ||
.clickGetSelected() | ||
.clickOK(MainMenuPage()) | ||
.startBlankForm("One Question Entity Update") | ||
.assertText("Ro-Ro Roy") | ||
.assertTextDoesNotExist("Romulus Roy") | ||
.assertTextDoesNotExist("Roman Roy") | ||
} | ||
|
||
@Test | ||
fun fillingEntityFollowUpForm_whenOfflineDuplicateHasHigherVersion_showsOfflineVersion() { | ||
testDependencies.server.addForm( | ||
"one-question-entity-update.xml", | ||
mapOf("people.csv" to "updated-people.csv") | ||
) | ||
|
||
rule.withMatchExactlyProject(testDependencies.server.url) | ||
.enableLocalEntitiesInForms() | ||
|
||
.startBlankForm("One Question Entity Update") | ||
.assertQuestion("Select person") | ||
.clickOnText("Ro-Ro Roy") | ||
.swipeToNextQuestion("Name") | ||
.answerQuestion("Name", "Romulus Roy") | ||
.swipeToEndScreen() | ||
.clickFinalize() | ||
|
||
.startBlankForm("One Question Entity Update") | ||
.assertText("Romulus Roy") | ||
.assertTextDoesNotExist("Ro-Ro Roy") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we started using different names... online and offline entities are I think the clearest options but here we have
local entities
. The test title below is also not clear it's about online entities.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I ended up using local is because we know store both the "offline" and "online" entities in one place ("local"), but can create or update them locally (rather than those creates/updates coming from the server). It's definitely got me a little twisted up. Do you think we should use "offline" here?
I reckon this will become easier again with #6011, as we'll need to start tracking if local entities are "offline" or "online" so we know whether to delete them or not if they're not in the "online" lists any longer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be
local
instead ofoffline
(maybe it's even better) but it would require reviewing the code and fixing other occurrences ofoffline
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we leave this for #6011? I think, it'll be best to consolidate the naming there.