diff --git a/api/materialized_views/search/redactedRecordSubset.test.js b/api/materialized_views/search/redactedRecordSubset.test.js index 35d0af33a..8bae9a36b 100644 --- a/api/materialized_views/search/redactedRecordSubset.test.js +++ b/api/materialized_views/search/redactedRecordSubset.test.js @@ -44,7 +44,7 @@ describe('Record Individual issuedTo redaction test', () => { const testRecord = new TestModel({ issuedTo: generateIssuedTo( false, true, false ), _schemaName: 'Schema', - issuingAgency: 'BC Parks' + issuingAgency: 'AGENCY_ENV_BCPARKS' }); await nrptiCollection.insertOne(testRecord); @@ -62,7 +62,7 @@ describe('Record Individual issuedTo redaction test', () => { const testRecord = new TestModel({ issuedTo: generateIssuedTo( true, false, false ), _schemaName: 'Schema', - issuingAgency: 'BC Parks' + issuingAgency: 'AGENCY_ENV_BCPARKS' }); await nrptiCollection.insertOne(testRecord); @@ -120,4 +120,4 @@ describe('Record Individual issuedTo redaction test', () => { const redacted = await redacted_record_subset.findOne(); expect(redacted.issuedTo.companyName).toEqual(testRecord.issuedTo.companyName); }); -}); \ No newline at end of file +}); diff --git a/api/src/integrations/epic/base-record-utils.js b/api/src/integrations/epic/base-record-utils.js index 80270501d..dbf5500b0 100644 --- a/api/src/integrations/epic/base-record-utils.js +++ b/api/src/integrations/epic/base-record-utils.js @@ -130,6 +130,7 @@ class BaseRecordUtils { _sourceRefId: new ObjectID(epicRecord._id) || '', _epicMilestoneId: epicRecord.milestone || '', mineGuid: (mineRecord && mineRecord._sourceRefId) || null, + issuingAgency: 'AGENCY_EAO', recordName: epicRecord.displayName || '', recordType: this.recordType.displayName, diff --git a/api/src/integrations/epic/management-plans-utils.js b/api/src/integrations/epic/management-plans-utils.js index b0e07a98f..83231951f 100644 --- a/api/src/integrations/epic/management-plans-utils.js +++ b/api/src/integrations/epic/management-plans-utils.js @@ -35,7 +35,7 @@ class ManagementPlans extends BaseRecordUtils { return { ...(await super.transformRecord(epicRecord)), - issuingAgency: 'Environmental Assessment Office', + issuingAgency: 'AGENCY_EAO', author: epicRecord.documentAuthor || '' }; } diff --git a/api/src/integrations/epic/management-plans-utils.test.js b/api/src/integrations/epic/management-plans-utils.test.js new file mode 100644 index 000000000..ced2f67a2 --- /dev/null +++ b/api/src/integrations/epic/management-plans-utils.test.js @@ -0,0 +1,19 @@ +const ManagementPlans = require('./management-plans-utils'); +const RECORD_TYPE = require('../../utils/constants/record-type-enum'); + +describe('ManagementPlans', () => { + describe('transformRecord', () => { + it('transforms an epic management plan record correctly', async () => { + const epicRecord = {'recordName': 'test abc'} + const managementPlans = new ManagementPlans({}, RECORD_TYPE.ManagementPlan); + const transformedRecord = await managementPlans.transformRecord(epicRecord); + + expect(transformedRecord.issuingAgency).toEqual('AGENCY_EAO'); + }); + + it('throws an error if epic record is not provided', async () => { + const managementPlans = new ManagementPlans({}, RECORD_TYPE.ManagementPlan); + await expect(managementPlans.transformRecord(null)).rejects.toThrow('transformRecord - required record must be non-null.'); + }); + }); +});