Skip to content

Commit

Permalink
Fix discard changes when editing finalized form
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Sep 11, 2023
1 parent 78a4278 commit 967501b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.odk.collect.android.support.pages.FormEntryPage.QuestionAndAnswer
import org.odk.collect.android.support.pages.MainMenuPage
import org.odk.collect.android.support.pages.OkDialog
import org.odk.collect.android.support.pages.ProjectSettingsPage
import org.odk.collect.android.support.pages.SaveOrDiscardFormDialog
import org.odk.collect.android.support.pages.SendFinalizedFormPage
import org.odk.collect.android.support.rules.CollectTestRule
import org.odk.collect.android.support.rules.TestRuleChain.chain
Expand Down Expand Up @@ -70,6 +71,25 @@ class SendFinalizedFormTest {
.assertText("53")
}

@Test
fun canEditAFormAndLeaveFinalizedBeforeSending() {
rule.withProject(testDependencies.server.url)
.copyForm("one-question.xml", projectName = testDependencies.server.hostName)
.startBlankForm("One Question")
.fillOutAndFinalize(QuestionAndAnswer("what is your age", "52"))

.clickSendFinalizedForm(1)
.clickOnFormToEdit("One Question")
.clickGoToStart()
.answerQuestion("what is your age", "53")
.pressBack(SaveOrDiscardFormDialog(MainMenuPage()))
.clickDiscardChanges()

.clickSendFinalizedForm(1)
.clickOnFormToEdit("One Question")
.assertText("52")
}

@Test
fun whenThereIsAnAuthenticationError_allowsUserToReenterCredentials() {
testDependencies.server.setCredentials("Draymond", "Green")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ protected void onSaveInstanceState(Bundle outState) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == RESULT_CANCELED) {
multiSelectViewModel.unselectAll();
return;
}

switch (requestCode) {
// returns with a form path, start entry
case INSTANCE_UPLOADER:
if (resultCode == RESULT_CANCELED) {
multiSelectViewModel.unselectAll();
return;
}

if (intent.getBooleanExtra(FormFillingActivity.KEY_SUCCESS, false)) {
listView.clearChoices();
if (listAdapter.isEmpty()) {
Expand Down

0 comments on commit 967501b

Please sign in to comment.