Skip to content

Commit c037f7d

Browse files
committed
Replace test with lower level
1 parent 99b3961 commit c037f7d

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/audit/AuditTest.kt

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,4 @@ class AuditTest {
5454
assertThat(auditLog[11].get("event"), equalTo("form exit"))
5555
assertThat(auditLog[12].get("event"), equalTo("form finalize"))
5656
}
57-
58-
@Test
59-
fun fillingFormWithTrackChanges_withConstraint_andViolatingConstraint_andCorrectingAnswer_tracksCorrectedAnswer() {
60-
rule.startAtMainMenu()
61-
.copyForm("one-question-audit-constraint.xml")
62-
.startBlankForm("One Question Audit Constraint")
63-
.answerQuestion("What is your age?", "120")
64-
.swipeToNextQuestionWithConstraintViolation("Too old!")
65-
.answerQuestion("What is your age?", "119")
66-
.swipeToEndScreen()
67-
.clickSaveAndExit()
68-
69-
val auditLog = StorageUtils.getAuditLogForFirstInstance()
70-
assertThat(auditLog.size, equalTo(6))
71-
72-
assertThat(auditLog[0].get("event"), equalTo("form start"))
73-
74-
val questionEvent = auditLog[1]
75-
assertThat(questionEvent.get("event"), equalTo("question"))
76-
assertThat(questionEvent.get("old-value"), equalTo(""))
77-
assertThat(questionEvent.get("new-value"), equalTo("119"))
78-
79-
assertThat(auditLog[2].get("event"), equalTo("end screen"))
80-
assertThat(auditLog[3].get("event"), equalTo("form save"))
81-
assertThat(auditLog[4].get("event"), equalTo("form exit"))
82-
assertThat(auditLog[5].get("event"), equalTo("form finalize"))
83-
}
8457
}

collect_app/src/test/java/org/odk/collect/android/formentry/FormEntryViewModelTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,20 @@ public void moveForward_whenThereIsAFailedConstraint_setsFailedConstraint() thro
237237
assertThat(getOrAwaitValue(viewModel.getFailedConstraint()), equalTo(failedConstraint));
238238
}
239239

240+
/**
241+
* We don't want to flush the log before answers are actually committed.
242+
*/
243+
@Test
244+
public void moveForward_whenThereIsAFailedConstraint_doesNotFlushAuditLog() throws Exception {
245+
FailedConstraint failedConstraint = new FailedConstraint(startingIndex, 0);
246+
when(formController.saveAllScreenAnswers(any(), anyBoolean())).thenReturn(failedConstraint);
247+
248+
viewModel.moveForward(new HashMap<>());
249+
scheduler.runBackground();
250+
251+
verify(auditEventLogger, never()).flush();
252+
}
253+
240254
@Test
241255
public void moveForward_whenThereIsAFailedConstraint_doesNotStepToNextEvent() throws Exception {
242256
FailedConstraint failedConstraint = new FailedConstraint(startingIndex, 0);

0 commit comments

Comments
 (0)