fix(forms): clear hidden listener fields instead of applying default value#12459
fix(forms): clear hidden listener fields instead of applying default value#12459
Conversation
|
Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:
|
|
ℹ️ Coverage metrics explained: |
📊 commons test coverage |
📊 events test coverage |
| // Record the time just before dispatching so we can ignore any | ||
| // pre-existing runs when polling below. | ||
| const dispatchedAt = new Date(); | ||
|
|
||
| if (runs.data.workflow_runs.length > 0) { | ||
| const runId = runs.data.workflow_runs[0].id; | ||
| console.log(`Captured runId: ${runId}`); | ||
| // GitHub Actions can take variable time to register a newly dispatched | ||
| // run in the API. Poll every 5 seconds for up to 60 seconds, and only | ||
| // accept a run whose created_at is >= dispatchedAt to avoid picking up | ||
| // a stale run from a previous dispatch (e.g. one triggered by farajaland). | ||
| let runId; | ||
| for (let i = 0; i < 12; i++) { | ||
| await new Promise(resolve => setTimeout(resolve, 5000)); | ||
|
|
||
| // Set the runId as an output | ||
| core.setOutput('run_id', runId); | ||
| } else { | ||
| throw new Error('No workflow run found.'); | ||
| const runs = await github.rest.actions.listWorkflowRunsForRepo({ | ||
| owner: 'opencrvs', | ||
| repo: 'e2e', | ||
| event: 'repository_dispatch', | ||
| per_page: 5 | ||
| }); | ||
|
|
||
| const newRun = runs.data.workflow_runs.find( | ||
| r => new Date(r.created_at) >= dispatchedAt | ||
| ); | ||
|
|
||
| if (newRun) { | ||
| runId = newRun.id; | ||
| console.log(`Captured runId: ${runId} (created at ${newRun.created_at})`); | ||
| break; | ||
| } | ||
|
|
||
| console.log(`Run not visible yet, retrying... (attempt ${i + 1}/12)`); | ||
| } | ||
|
|
||
| if (!runId) { | ||
| throw new Error('No workflow run found after 60 seconds.'); | ||
| } |
There was a problem hiding this comment.
added it because we found a stale link here: https://github.com/opencrvs/opencrvs-core/actions/runs/25014351156/job/73261242356#step:10:1
Reason: The newly triggered run hadn't appeared in the API yet after the 10-second wait. GitHub Actions has variable latency before a freshly dispatched run shows up in listWorkflowRunsForRepo. When the list was fetched, the new run wasn't there yet, so it returned the previous run from hours ago.
Fix result example: https://github.com/opencrvs/opencrvs-core/actions/runs/25017463464/job/73269507432?pr=12459#step:9:97
|
Your environment is deployed to https://ocrvs-12433.e2e-k8s.opencrvs.dev |
CC PR: opencrvs/opencrvs-countryconfig#1401
Farajaland PR: opencrvs/opencrvs-farajaland#2120
Description
Why
When a field with a parent listener is hidden (e.g.
child.birthLocation.privateHomeis only shown whenplaceOfBirth = PRIVATE_HOME), (configured as part of this pull request) switching the parent to a different option (e.g.HEALTH_FACILITY) was still applying the field'sdefaultValueto hidden listener fields. This causedchild.birthLocationId— a derived hidden field that readsadministrativeAreafrom whichever location field is filled — to pick up the admin areaUUIDfrom a hidden address field's default, rather than staying empty.This admin area
UUIDthen propagated toplaceOfEventin the Elasticsearch index (viaresolvePlaceOfEvent), causing jurisdiction-based workqueue filters to fail forNOTIFYevents submitted by hospital clerk system users. https://github.com/opencrvs/e2e/actions/runs/24998390203The bug predates the workqueue jurisdiction filter. It was only exposed when we introduced scope-based
placeOfEventfiltering inworkqueues, which made the incorrectplaceOfEventvalue visible as a query mismatch.Fix
In
setValueForListenerField, hidden listener fields are now explicitly cleared to null instead of having theirdefaultValueapplied. This is consistent with howapplyVisibilityTransitionsalready handles fields that transition from visible to hidden, and with howcomputeInitialValuesskips hidden fields at form initialization.Also fixes a flaky CI issue where the E2E trigger job would capture a stale run link from a previous dispatch. The workflow now polls until a run created after the dispatch time appears, rather than assuming a fixed 10-second wait is sufficient.
Checklist