Skip to content

Commit 26bf6e2

Browse files
feat(#10676): require explicit skip action after GPS capture failure
Previously, GPS failure immediately wrote 'not_captured' to the hidden input, allowing the form to advance without user acknowledgement. Now the widget waits: retry/skip buttons are shown but the input stays empty. Clicking Skip removes the buttons, shows a localized confirmation message, and writes 'skipped' to the input. The geo_capture bind is marked required so the form cannot be submitted until the user either captures or explicitly skips. Also stops the context radio change event from propagating to Enketo's form handler, which was logging 'Data node not found' warnings and failing integration tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2172e71 commit 26bf6e2

12 files changed

Lines changed: 104 additions & 5 deletions

File tree

api/resources/translations/messages-en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ geolocation.progress = Progress
729729
geolocation.result.label = Result
730730
geolocation.retry = Retry here to capture GPS location
731731
geolocation.skip = Continue without location tracking
732+
geolocation.skipped = Continuing without location capture
732733
geolocation.success = Success
733734
geolocation.unavailable = GPS is not available on this device.
734735
health_center.field.children = Areas

api/resources/translations/messages-es.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ geolocation.progress = Progreso
729729
geolocation.result.label = Resultado
730730
geolocation.retry = Reintentar
731731
geolocation.skip = Continuar sin seguimiento de ubicación
732+
geolocation.skipped = Continuando sin capturar la ubicación
732733
geolocation.success = Exitoso
733734
geolocation.unavailable = El GPS no está disponible en este dispositivo.
734735
health_center.field.children = Áreas

api/resources/translations/messages-fr.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ geolocation.progress = Progression
729729
geolocation.result.label = Résultat
730730
geolocation.retry = Réessayer
731731
geolocation.skip = Continuer sans suivi de localisation
732+
geolocation.skipped = Poursuite sans capture de localisation
732733
geolocation.success = Succès
733734
geolocation.unavailable = Le GPS n'est pas disponible sur cet appareil.
734735
health_center.field.children = Cliniques

api/resources/translations/messages-ne.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ geolocation.progress = प्रगति
729729
geolocation.result.label = परिणाम
730730
geolocation.retry = पुनः प्रयास गर्नुहोस्
731731
geolocation.skip = स्थान ट्र्याकिङ बिना जारी राख्नुहोस्
732+
geolocation.skipped = स्थान कैप्चर बिना जारी राख्दै
732733
geolocation.success = सफल
733734
geolocation.unavailable = यस उपकरणमा GPS उपलब्ध छैन।
734735
health_center.field.children = क्लिनिक

api/resources/translations/messages-sw.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ geolocation.progress = Maendeleo
729729
geolocation.result.label = Matokeo
730730
geolocation.retry = Jaribu tena
731731
geolocation.skip = Endelea bila ufuatiliaji wa eneo
732+
geolocation.skipped = Inaendelea bila kupata eneo
732733
geolocation.success = Imefaulu
733734
geolocation.unavailable = GPS haipatikani kwenye kifaa hiki.
734735
health_center.field.children = Eneo

tests/e2e/default/contacts/forms/geolocation-contact-create.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<bind nodeset="/data/person_with_geo/parent" type="string"/>
3030
<bind nodeset="/data/person_with_geo/type" type="string"/>
3131
<bind nodeset="/data/person_with_geo/name" type="string" required="true()"/>
32-
<bind nodeset="/data/person_with_geo/geo_capture" type="string"/>
32+
<bind nodeset="/data/person_with_geo/geo_capture" type="string" required="true()"/>
3333
<bind nodeset="/data/meta/instanceID" type="string" readonly="true()" jr:preload="uid"/>
3434
</model>
3535
</h:head>

tests/e2e/default/contacts/geolocation-widget.wdio-spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ const selectHomeContext = async () => {
1515
await $('.geolocation-context-options input[value="home"]').click();
1616
};
1717

18+
const captureAndWait = async () => {
19+
await $('.geolocation-capture-btn').click();
20+
// GPS may succeed or fail depending on the environment. Wait for either outcome.
21+
await browser.waitUntil(
22+
async () => {
23+
const success = await $('.geolocation-success-msg').isExisting();
24+
const skip = await $('.geolocation-skip-btn').isExisting();
25+
return success || skip;
26+
},
27+
{ timeout: 35000 }
28+
);
29+
if (await $('.geolocation-skip-btn').isExisting()) {
30+
await $('.geolocation-skip-btn').click();
31+
}
32+
};
33+
1834
describe('Geolocation widget - contact save pipeline', () => {
1935
const places = placeFactory.generateHierarchy();
2036
const healthCenter = places.get(CONTACT_TYPES.HEALTH_CENTER);
@@ -91,6 +107,7 @@ describe('Geolocation widget - contact save pipeline', () => {
91107

92108
await $('.or-appearance-geolocation-capture').waitForDisplayed();
93109
await selectHomeContext();
110+
await captureAndWait();
94111
await commonEnketoPage.setInputValue('Full name', 'Test Person With Geo');
95112
await genericForm.submitForm();
96113
await commonPage.waitForPageLoaded();

tests/integration/cht-form/default/forms/geolocation-widget.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<meta><instanceID/></meta>
1010
</data>
1111
</instance>
12+
<bind nodeset="/data/geo_capture" type="string" required="true()"/>
1213
</model>
1314
</h:head>
1415
<h:body>

tests/integration/cht-form/default/geolocation-widget.wdio-spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,22 @@ describe('cht-form web component - Geolocation Widget', () => {
110110
await $('.geolocation-retry-btn').waitForExist();
111111
expect(await $('.geolocation-context-options').isDisplayed()).to.be.false;
112112
});
113+
114+
it('should show a confirmation message and remove retry/skip buttons when skip is clicked', async () => {
115+
await mockConfig.loadForm('default', 'test', 'geolocation-widget');
116+
117+
await browser.execute((geoFailure) => {
118+
window.CHTCore.Geolocation = { currentPromise: Promise.resolve(geoFailure), retry: () => {} };
119+
}, GEO_FAILURE);
120+
121+
await selectHomeContext();
122+
await $('.geolocation-capture-btn').click();
123+
124+
await $('.geolocation-skip-btn').waitForExist();
125+
await $('.geolocation-skip-btn').click();
126+
127+
await $('.geolocation-skipped-msg').waitForExist();
128+
expect(await $('.geolocation-retry-btn').isExisting()).to.be.false;
129+
expect(await $('.geolocation-skip-btn').isExisting()).to.be.false;
130+
});
113131
});

webapp/src/css/enketo/medic.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@
423423
text-align: left;
424424
background-color: @gray-light;
425425
}
426+
427+
.geolocation-skipped-msg {
428+
margin: 4px 0;
429+
font-style: italic;
430+
}
426431
}
427432
}
428433

0 commit comments

Comments
 (0)