mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Viewer enhancements and Viewer Dialog prototype (#2200)
* viewer dialog scaffold * toolbar divider component * simple error screen * material module and tooltips * show file name in the title * improved settings, simple image viewer * flex-based image viewer, minor fixes * ability to switch between viewers * single viewer for images * remove MDL from the Viewer component * remove hardcoded demo shell layout remove harcoded assumptions on "header" and "main" elements * rework text viewer, remove MDL dependency * upgrade 'unknown format' view, remove MDL * simplify media viewer layout * simplify image viewer * clean pdf viewer * migrate pdf viewer styles to scss * rewrite pdf viewer host styles in scss * fix unit tests and cleanup layout * file viewer service * viewer dialog supports downloads if url provided
This commit is contained in:
committed by
Mario Romano
parent
d460824df4
commit
bb53844f92
@@ -17,18 +17,10 @@
|
||||
|
||||
import { DebugElement } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MdButtonModule, MdIconModule, MdProgressSpinnerModule } from '@angular/material';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import {
|
||||
AlfrescoApiService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
ContentService,
|
||||
CoreModule,
|
||||
LogService,
|
||||
RenditionsService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { ContentService, CoreModule, RenditionsService } from 'ng2-alfresco-core';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { MaterialModule } from './../material.module';
|
||||
import { NotSupportedFormatComponent } from './notSupportedFormat.component';
|
||||
import { PdfViewerComponent } from './pdfViewer.component';
|
||||
|
||||
@@ -49,28 +41,18 @@ describe('NotSupportedFormatComponent', () => {
|
||||
let element: HTMLElement;
|
||||
let renditionsService: RenditionsService;
|
||||
|
||||
let renditionSubject: Subject<RenditionResponse>,
|
||||
conversionSubject: Subject<any>;
|
||||
let renditionSubject: Subject<RenditionResponse>;
|
||||
let conversionSubject: Subject<any>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule,
|
||||
MdIconModule,
|
||||
MdButtonModule,
|
||||
MdProgressSpinnerModule
|
||||
MaterialModule
|
||||
],
|
||||
declarations: [
|
||||
NotSupportedFormatComponent,
|
||||
PdfViewerComponent
|
||||
],
|
||||
providers: [
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoApiService,
|
||||
ContentService,
|
||||
RenditionsService,
|
||||
LogService
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
@@ -96,8 +78,8 @@ describe('NotSupportedFormatComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should be present Download button', () => {
|
||||
expect(element.querySelector('#viewer-download-button')).not.toBeNull();
|
||||
it('should display the Download button', () => {
|
||||
expect(element.querySelector('[data-automation-id="viewer-download-button"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should display the name of the file', () => {
|
||||
@@ -107,7 +89,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
});
|
||||
|
||||
it('should NOT show loading spinner by default', () => {
|
||||
expect(element.querySelector('#conversion-spinner')).toBeNull('Conversion spinner should NOT be shown by default');
|
||||
expect(element.querySelector('[data-automation-id="viewer-conversion-spinner"]')).toBeNull('Conversion spinner should NOT be shown by default');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -115,7 +97,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
|
||||
it('should not show the "Convert to PDF" button by default', () => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-convert-button')).toBeNull();
|
||||
expect(element.querySelector('[data-automation-id="viewer-convert-button"]')).toBeNull();
|
||||
});
|
||||
|
||||
it('should be checked on ngInit', () => {
|
||||
@@ -135,7 +117,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-convert-button')).not.toBeNull();
|
||||
expect(element.querySelector('[data-automation-id="viewer-convert-button"]')).not.toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -146,7 +128,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-convert-button')).toBeNull();
|
||||
expect(element.querySelector('[data-automation-id="viewer-convert-button"]')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -155,7 +137,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#viewer-convert-button')).toBeNull();
|
||||
expect(element.querySelector('[data-automation-id="viewer-convert-button"]')).toBeNull();
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -226,7 +208,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
spyOn(window, 'open');
|
||||
component.urlFile = 'test';
|
||||
|
||||
let downloadButton: any = element.querySelector('#viewer-download-button');
|
||||
let downloadButton: any = element.querySelector('[data-automation-id="viewer-download-button"]');
|
||||
downloadButton.click();
|
||||
|
||||
expect(window.open).toHaveBeenCalled();
|
||||
@@ -237,7 +219,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
|
||||
component.blobFile = new Blob();
|
||||
|
||||
let downloadButton: any = element.querySelector('#viewer-download-button');
|
||||
let downloadButton: any = element.querySelector('[data-automation-id="viewer-download-button"]');
|
||||
downloadButton.click();
|
||||
|
||||
expect(service.downloadBlob).toHaveBeenCalled();
|
||||
@@ -250,7 +232,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
renditionSubject.next({ entry: { status: 'NOT_CREATED' } });
|
||||
fixture.detectChanges();
|
||||
|
||||
let convertButton: any = element.querySelector('#viewer-convert-button');
|
||||
let convertButton: any = element.querySelector('[data-automation-id="viewer-convert-button"]');
|
||||
convertButton.click();
|
||||
fixture.detectChanges();
|
||||
}
|
||||
@@ -258,8 +240,8 @@ describe('NotSupportedFormatComponent', () => {
|
||||
it('should show loading spinner and disable the "Convert to PDF button" after the button was clicked', () => {
|
||||
clickOnConvertButton();
|
||||
|
||||
let convertButton: any = element.querySelector('#viewer-convert-button');
|
||||
expect(element.querySelector('#conversion-spinner')).not.toBeNull('Conversion spinner should be shown');
|
||||
let convertButton: any = element.querySelector('[data-automation-id="viewer-convert-button"]');
|
||||
expect(element.querySelector('[data-automation-id="viewer-conversion-spinner"]')).not.toBeNull('Conversion spinner should be shown');
|
||||
expect(convertButton.disabled).toBe(true);
|
||||
});
|
||||
|
||||
@@ -269,8 +251,8 @@ describe('NotSupportedFormatComponent', () => {
|
||||
conversionSubject.error(new Error());
|
||||
fixture.detectChanges();
|
||||
|
||||
let convertButton: any = element.querySelector('#viewer-convert-button');
|
||||
expect(element.querySelector('#conversion-spinner')).toBeNull('Conversion spinner should be shown');
|
||||
let convertButton: any = element.querySelector('[data-automation-id="viewer-convert-button"]');
|
||||
expect(element.querySelector('[data-automation-id="viewer-conversion-spinner"]')).toBeNull('Conversion spinner should be shown');
|
||||
expect(convertButton.disabled).toBe(false);
|
||||
});
|
||||
|
||||
@@ -282,7 +264,7 @@ describe('NotSupportedFormatComponent', () => {
|
||||
fixture.detectChanges();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#pdf-rendition-viewer')).not.toBeNull('Pdf rendition should be shown.');
|
||||
expect(element.querySelector('[data-automation-id="pdf-rendition-viewer"]')).not.toBeNull('Pdf rendition should be shown.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user