mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6587] ACA: Viewer does not update after restoring version and the toolbar disappears (#9383)
* [ACS-6587] reload files after update * [ACS-6587] update view after version change * [ACS-6587] update view after version change * [ACS-6587] update tests * AAE-0000 e2e affected were not running on ADF pipeline' (#9409) * AAE-14727 Removed unused css rule (#9408) * [ACS-6587] update tests * [ACS-6587] rearrange tests description --------- Co-authored-by: Vito Albano <vito.albano@alfresco.com> Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com>
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
<div id="adf-image-container" (keydown)="onKeyDown($event)" class="adf-image-container" tabindex="0" role="img" [attr.aria-label]="fileName" data-automation-id="adf-image-container">
|
||||
<img #image id="viewer-image" [src]="urlFile" [alt]="fileName" (error)="onImageError()" />
|
||||
<div id="adf-image-container"
|
||||
(keydown)="onKeyDown($event)"
|
||||
class="adf-image-container"
|
||||
tabindex="0"
|
||||
role="img"
|
||||
[attr.aria-label]="fileName"
|
||||
data-automation-id="adf-image-container">
|
||||
<img #image id="viewer-image"
|
||||
[src]="urlFile"
|
||||
[alt]="fileName"
|
||||
(error)="onImageError()" />
|
||||
</div>
|
||||
|
||||
<div class="adf-image-viewer__toolbar" *ngIf="showToolbar">
|
||||
|
@@ -125,40 +125,38 @@ describe('Test Img viewer component ', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('If no url or blob are passed should thrown an error', () => {
|
||||
it('should thrown an error if no url or blob are passed', () => {
|
||||
const change = new SimpleChange(null, null, true);
|
||||
expect(() => {
|
||||
component.ngOnChanges({ blobFile: change, urlFile: change });
|
||||
}).toThrow(new Error('Attribute urlFile or blobFile is required'));
|
||||
});
|
||||
|
||||
it('If url is passed should not thrown an error', () => {
|
||||
it('should not thrown an error if url is passed ', () => {
|
||||
component.urlFile = 'fake-url';
|
||||
expect(() => {
|
||||
component.ngOnChanges(null);
|
||||
}).not.toThrow(new Error('Attribute urlFile or blobFile is required'));
|
||||
});
|
||||
|
||||
it('The file Name should be present in the alt attribute', () => {
|
||||
it('should present file name in the alt attribute', () => {
|
||||
component.fileName = 'fake-name';
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-image').getAttribute('alt')).toEqual('fake-name');
|
||||
});
|
||||
|
||||
it('should call replace on cropper with new url if blobFile is null', () => {
|
||||
component.fileName = 'fake-name';
|
||||
component.urlFile = 'fake-url';
|
||||
spyOn(component.cropper, 'replace').and.stub();
|
||||
const fileName = new SimpleChange('val', 'val2', false);
|
||||
const urlFile = new SimpleChange('fake-url', 'fake-url-2', false);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ fileName, urlFile });
|
||||
component.ngOnChanges({ urlFile });
|
||||
|
||||
expect(component.cropper.replace).toHaveBeenCalledWith('fake-url-2');
|
||||
});
|
||||
|
||||
it('If blob is passed should not thrown an error', () => {
|
||||
it('should not thrown an error if blob is passed ', () => {
|
||||
const blob = createFakeBlob();
|
||||
|
||||
spyOn(urlService, 'createTrustedUrl').and.returnValue('fake-blob-url');
|
||||
|
@@ -78,7 +78,10 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
||||
return Math.round(this.scale * 100) + '%';
|
||||
}
|
||||
|
||||
constructor(private appConfigService: AppConfigService, private urlService: UrlService) {
|
||||
constructor(
|
||||
private appConfigService: AppConfigService,
|
||||
private urlService: UrlService
|
||||
) {
|
||||
this.initializeScaling();
|
||||
}
|
||||
|
||||
@@ -155,8 +158,8 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!changes['urlFile'].firstChange && changes['fileName']) {
|
||||
if (changes['fileName'].previousValue !== changes['fileName'].currentValue) {
|
||||
if (!changes['urlFile'].firstChange) {
|
||||
if (changes['urlFile'].previousValue !== changes['urlFile'].currentValue) {
|
||||
this.cropper.replace(changes['urlFile'].currentValue);
|
||||
}
|
||||
}
|
||||
|
@@ -132,7 +132,7 @@ export class ViewerRenderComponent implements OnChanges, OnInit, OnDestroy {
|
||||
return this._externalViewer;
|
||||
}
|
||||
|
||||
cacheTypeForContent = '';
|
||||
cacheTypeForContent = 'no-cache';
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
@@ -143,7 +143,7 @@ export class ViewerRenderComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.cacheTypeForContent = '';
|
||||
this.cacheTypeForContent = 'no-cache';
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
@@ -262,7 +262,7 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
|
||||
}
|
||||
|
||||
if (urlFile?.currentValue) {
|
||||
this.fileName = this.fileName ? this.fileName : this.viewUtilsService.getFilenameFromUrl(urlFile.currentValue);
|
||||
this.fileName ||= this.viewUtilsService.getFilenameFromUrl(urlFile.currentValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user