Skip to content

Commit

Permalink
fix missing agency codes in integrations; add epic test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidclaveau committed Oct 6, 2023
1 parent 435da7c commit 329ac93
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/materialized_views/search/redactedRecordSubset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
});
});
});
1 change: 1 addition & 0 deletions api/src/integrations/epic/base-record-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion api/src/integrations/epic/management-plans-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ManagementPlans extends BaseRecordUtils {

return {
...(await super.transformRecord(epicRecord)),
issuingAgency: 'Environmental Assessment Office',
issuingAgency: 'AGENCY_EAO',
author: epicRecord.documentAuthor || ''
};
}
Expand Down
19 changes: 19 additions & 0 deletions api/src/integrations/epic/management-plans-utils.test.js
Original file line number Diff line number Diff line change
@@ -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.');
});
});
});

0 comments on commit 329ac93

Please sign in to comment.