mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-09 11:03:05 +00:00
[CST-4884] Code cleanup and test improvement
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
<div class="float-left w-75">
|
<div class="float-left w-75">
|
||||||
<h3>{{fileName}} <span class="text-muted">({{fileData?.sizeBytes | dsFileSize}})</span></h3>
|
<h3>{{fileName}} <span class="text-muted">({{fileData?.sizeBytes | dsFileSize}})</span></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="float-right w-15" [class.sticky-buttons]="!readMode">
|
<div class="float-right w-15">
|
||||||
<ng-container>
|
<ng-container>
|
||||||
<ds-file-download-link [cssClasses]="'btn btn-link-focus'" [isBlank]="true" [bitstream]="getBitstream()" [enableRequestACopy]="false">
|
<ds-file-download-link [cssClasses]="'btn btn-link-focus'" [isBlank]="true" [bitstream]="getBitstream()" [enableRequestACopy]="false">
|
||||||
<i class="fa fa-download fa-2x text-normal" aria-hidden="true"></i>
|
<i class="fa fa-download fa-2x text-normal" aria-hidden="true"></i>
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
.sticky-buttons {
|
|
||||||
position: sticky;
|
|
||||||
top: calc(var(--bs-dropdown-item-padding-x) * 3);
|
|
||||||
z-index: var(--ds-submission-footer-z-index);
|
|
||||||
background-color: rgba(255, 255, 255, .97);
|
|
||||||
}
|
|
||||||
|
@@ -217,86 +217,20 @@ describe('SubmissionSectionUploadFileComponent test suite', () => {
|
|||||||
pathCombiner.subRootElement);
|
pathCombiner.subRootElement);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*it('should save Bitstream File data properly when form is valid', fakeAsync(() => {
|
it('should open edit modal when edit button is clicked', () => {
|
||||||
compAsAny.fileEditComp = TestBed.inject(SubmissionSectionUploadFileEditComponent);
|
spyOn(compAsAny, 'editBitstreamData').and.callThrough();
|
||||||
compAsAny.fileEditComp.formRef = {formGroup: null};
|
comp.fileData = fileData;
|
||||||
compAsAny.fileData = fileData;
|
|
||||||
compAsAny.pathCombiner = pathCombiner;
|
|
||||||
const event = new Event('click', null);
|
|
||||||
spyOn(comp, 'switchMode');
|
|
||||||
formService.validateAllFormFields.and.callFake(() => null);
|
|
||||||
formService.isValid.and.returnValue(observableOf(true));
|
|
||||||
formService.getFormData.and.returnValue(observableOf(mockFileFormData));
|
|
||||||
|
|
||||||
const response = [
|
fixture.detectChanges();
|
||||||
Object.assign(mockSubmissionObject, {
|
|
||||||
sections: {
|
|
||||||
upload: {
|
|
||||||
files: mockUploadFiles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
];
|
|
||||||
operationsService.jsonPatchByResourceID.and.returnValue(observableOf(response));
|
|
||||||
|
|
||||||
const accessConditionsToSave = [
|
const modalBtn = fixture.debugElement.query(By.css('.fa-edit '));
|
||||||
{ name: 'openaccess' },
|
|
||||||
{ name: 'lease', endDate: dateToISOFormat('2019-01-16T00:00:00Z') },
|
|
||||||
{ name: 'embargo', startDate: dateToISOFormat('2019-01-16T00:00:00Z') },
|
|
||||||
];
|
|
||||||
comp.saveBitstreamData(event);
|
|
||||||
tick();
|
|
||||||
|
|
||||||
let path = 'metadata/dc.title';
|
modalBtn.nativeElement.click();
|
||||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
fixture.detectChanges();
|
||||||
pathCombiner.getPath(path),
|
|
||||||
mockFileFormData.metadata['dc.title'],
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
path = 'metadata/dc.description';
|
expect(compAsAny.editBitstreamData).toHaveBeenCalled();
|
||||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
|
||||||
pathCombiner.getPath(path),
|
|
||||||
mockFileFormData.metadata['dc.description'],
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
path = 'accessConditions';
|
|
||||||
expect(operationsBuilder.add).toHaveBeenCalledWith(
|
|
||||||
pathCombiner.getPath(path),
|
|
||||||
accessConditionsToSave,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(comp.switchMode).toHaveBeenCalled();
|
|
||||||
expect(uploadService.updateFileData).toHaveBeenCalledWith(submissionId, sectionId, mockUploadFiles[0].uuid, mockUploadFiles[0]);
|
|
||||||
|
|
||||||
}));*/
|
|
||||||
|
|
||||||
/*it('should not save Bitstream File data properly when form is not valid', fakeAsync(() => {
|
|
||||||
compAsAny.fileEditComp = TestBed.inject(SubmissionSectionUploadFileEditComponent);
|
|
||||||
compAsAny.fileEditComp.formRef = {formGroup: null};
|
|
||||||
compAsAny.pathCombiner = pathCombiner;
|
|
||||||
const event = new Event('click', null);
|
|
||||||
spyOn(comp, 'switchMode');
|
|
||||||
formService.validateAllFormFields.and.callFake(() => null);
|
|
||||||
formService.isValid.and.returnValue(observableOf(false));
|
|
||||||
|
|
||||||
expect(comp.switchMode).not.toHaveBeenCalled();
|
|
||||||
expect(uploadService.updateFileData).not.toHaveBeenCalled();
|
|
||||||
|
|
||||||
}));*/
|
|
||||||
|
|
||||||
it('should switch read mode', () => {
|
|
||||||
comp.readMode = false;
|
|
||||||
|
|
||||||
comp.switchMode();
|
|
||||||
expect(comp.readMode).toBeTruthy();
|
|
||||||
|
|
||||||
comp.switchMode();
|
|
||||||
|
|
||||||
expect(comp.readMode).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -217,14 +217,6 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch from edit form to metadata view
|
|
||||||
*/
|
|
||||||
public switchMode() {
|
|
||||||
this.readMode = !this.readMode;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
editBitstreamData() {
|
editBitstreamData() {
|
||||||
|
|
||||||
const options: NgbModalOptions = {
|
const options: NgbModalOptions = {
|
||||||
|
Reference in New Issue
Block a user