Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.2.47",
"version": "7.2.47-3552",
"engines": {
"node": ">=18.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/ccd-case-ui-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hmcts/ccd-case-ui-toolkit",
"version": "7.2.47",
"version": "7.2.47-3552",
"engines": {
"node": ">=18.19.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('WriteDocumentFieldComponent', () => {
'isUploadInProgress'
]);

appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList']);
appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList', 'logMessage']);
mockDocumentManagementService.isDocumentSecureModeEnabled.and.returnValue(true);
caseNotifier = {};
caseNotifier.caseView = of({ case_type: { id: 'test' } });
Expand Down Expand Up @@ -692,7 +692,7 @@ describe('WriteDocumentFieldComponent with Mandatory casefield', () => {
'isUploadInProgress'
]);

appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList']);
appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList', 'logMessage']);
mockDocumentManagementService.isDocumentSecureModeEnabled.and.returnValue(true);
caseNotifier = {};
caseNotifier.caseView = of({ case_type: { id: 'test' } });
Expand Down Expand Up @@ -772,6 +772,36 @@ describe('WriteDocumentFieldComponent with Mandatory casefield', () => {
expect(component.fileUploadMessages).toEqual('File required');
});

it('should be logged as enabled if file is securemode', () => {
component.caseField = CASE_FIELD_MANDATORY;
mockDocumentManagementService.isDocumentSecureModeEnabled.and.returnValue(true);
caseNotifier.caseView = of({ case_id: '12345', case_type: { id: 'test', jurisdiction: { id: 'test-jurisdiction' } } });
component.ngOnInit();
expect(component.caseField.value).toBeTruthy();

component.fileChangeEvent({
target: {
files: []
}
});
expect(appConfig.logMessage).toHaveBeenCalledWith('CDAM is enabled for case with case ref:: 12345');
});

it('should be logged as disabled if file is NOT securemode', () => {
component.caseField = CASE_FIELD_MANDATORY;
mockDocumentManagementService.isDocumentSecureModeEnabled.and.returnValue(false);
caseNotifier.caseView = of({ case_id: '12345', case_type: { id: 'test', jurisdiction: { id: 'test-jurisdiction' } } });
component.ngOnInit();
expect(component.caseField.value).toBeTruthy();

component.fileChangeEvent({
target: {
files: []
}
});
expect(appConfig.logMessage).toHaveBeenCalledWith('CDAM is disabled for case with case ref:: 12345');
});

it('should be valid if no document specified for upload for not read only. Empty file.', () => {
// Initialization.
component.valid = true;
Expand Down Expand Up @@ -918,7 +948,7 @@ describe('WriteDocumentFieldComponent', () => {
'isUploadInProgress'
]);

appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList']);
appConfig = createSpyObj('AbstractAppConfig', ['getCdamExclusionList', 'logMessage']);
mockDocumentManagementService.isDocumentSecureModeEnabled.and.returnValue(true);
caseNotifier = {};
caseNotifier.caseView = of(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export class WriteDocumentFieldComponent extends AbstractFieldWriteComponent imp
}
// use the documentManagement service to check if the document upload should use CDAM
if (this.documentManagement.isDocumentSecureModeEnabled()) {
this.appConfig.logMessage(`CDAM is enabled for case with case ref:: ${caseDetails?.case_id}`);
this.fileSecureModeOn = true;
} else {
this.appConfig.logMessage(`CDAM is disabled for case with case ref:: ${caseDetails?.case_id}`);
}
this.dialogConfig = initDialog();
let document = this.caseField.value || { document_url: null, document_binary_url: null, document_filename: null };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('DocumentManagementService', () => {
appConfig = createSpyObj<AbstractAppConfig>('appConfig', [
'getDocumentManagementUrl', 'getRemoteDocumentManagementUrl',
'getHrsUrl', 'getRemoteHrsUrl',
'getAnnotationApiUrl', 'getCdamExclusionList', 'getDocumentManagementUrlV2'
'getAnnotationApiUrl', 'getCdamExclusionList', 'getDocumentManagementUrlV2', 'logMessage'
]);
appConfig.getRemoteDocumentManagementUrl.and.returnValue(REMOTE_DOCUMENT_MANAGEMENT_URL);
appConfig.getDocumentManagementUrl.and.returnValue(DOCUMENT_MANAGEMENT_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export class DocumentManagementService {
// Do not set any headers, such as "Accept" or "Content-Type", with null values; this is not permitted with the
// Angular HttpClient in @angular/common/http. Just create and pass a new HttpHeaders object. Angular will add the
// correct headers and values automatically
this.appConfig.logMessage(`Uploading document for case type: ${this.caseTypeId}, with url: ${url}`);
const headers = new HttpHeaders();
return this.http
.post(url, formData, {headers, observe: 'body'})
Expand Down Expand Up @@ -145,7 +146,7 @@ export class DocumentManagementService {
public isDocumentSecureModeEnabled(): boolean {
const documentSecureModeCaseTypeExclusions = this.appConfig.getCdamExclusionList()?.split(',');
const isDocumentOnExclusionList = documentSecureModeCaseTypeExclusions?.includes(this.caseTypeId);

this.appConfig.logMessage(`isDocumentOnExclusionList: ${isDocumentOnExclusionList}`);
if (!isDocumentOnExclusionList){
return true;
}
Expand Down