diff --git a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts index a01f2918c..fd94ac033 100644 --- a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts +++ b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts @@ -258,4 +258,18 @@ describe('isExpressionDescriptionValidation', () => { }) ).toBe(false) }) + it('returns true for a POST to "programIndicators/expression/description"', () => { + expect( + isExpressionDescriptionValidation('create', { + resource: 'programIndicators/expression/description', + }) + ).toBe(true) + }) + it('retuns false for a POST to a different resource', () => { + expect( + isMetadataPackageInstallation('create', { + resource: 'programIndicators/expression/somethingelse', + }) + ).toBe(false) + }) }) diff --git a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts index d6bde09ba..90b0427fc 100644 --- a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts +++ b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts @@ -122,9 +122,11 @@ export const isMetadataPackageInstallation = ( { resource }: ResolvedResourceQuery ): boolean => type === 'create' && resource === 'synchronization/metadataPull' -// POST to 'indicaators/expression/description' (validate an expression) +// POST to 'indicators/expression/description' or 'programIndicator/expression/description' (validate an expression) export const isExpressionDescriptionValidation = ( type: FetchType, { resource }: ResolvedResourceQuery -): boolean => - type === 'create' && resource === 'indicators/expression/description' +): boolean => { + const pattern = /^(indicators|programIndicators)\/expression\/description$/ + return type === 'create' && pattern.test(resource) +}