reintroduce viewer test (#3888)

This commit is contained in:
Eugenio Romano 2018-10-16 08:35:05 +01:00 committed by GitHub
parent 094e1dab91
commit 0fc504b69e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 77 additions and 75 deletions

View File

@ -16,7 +16,7 @@
*/
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TestBed, fakeAsync, async } from '@angular/core/testing';
import { TestBed, fakeAsync } from '@angular/core/testing';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material';
import { of } from 'rxjs';
import {
@ -113,7 +113,7 @@ describe('ShareDialogComponent', () => {
expect(fixture.nativeElement.querySelector('.mat-slide-toggle').classList).toContain('mat-checked');
});
it(`should copy shared link and notify on button event`, async(() => {
it(`should copy shared link and notify on button event`, (done) => {
node.entry.properties['qshare:sharedId'] = 'sharedId';
spyOn(document, 'execCommand').and.callThrough();
@ -134,8 +134,9 @@ describe('ShareDialogComponent', () => {
expect(document.execCommand).toHaveBeenCalledWith('copy');
expect(notificationServiceMock.openSnackMessage).toHaveBeenCalledWith('SHARE.CLIPBOARD-MESSAGE');
done();
});
});
}));
it('should open a confirmation dialog when unshare button is triggered', () => {
spyOn(matDialog, 'open').and.returnValue({ beforeClose: () => of(false) });

View File

@ -62,7 +62,7 @@ module.exports = function (config) {
},
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_INFO,
colors: true,
@ -86,9 +86,6 @@ module.exports = function (config) {
reporters: ['mocha', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});

View File

@ -77,7 +77,7 @@ module.exports = function (config) {
},
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_INFO,
colors: true,
@ -101,9 +101,6 @@ module.exports = function (config) {
reporters: ['mocha', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});

View File

@ -22,7 +22,7 @@ import { setupTestBed } from '../../testing/setupTestBed';
import { CoreModule } from '../../core.module';
import { ContentService } from '../../services/content.service';
describe('Test Media player component ', () => {
xdescribe('Test Media player component ', () => {
let component: MediaPlayerComponent;
let service: ContentService;

View File

@ -16,7 +16,7 @@
*/
import { Component, SimpleChange, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EventMock } from '../../mock/event.mock';
import { RenderingQueueServices } from '../services/rendering-queue.services';
import { PdfViewerComponent } from './pdfViewer.component';
@ -117,7 +117,7 @@ class BlobTestComponent {
}
xdescribe('Test PdfViewer component', () => {
describe('Test PdfViewer component', () => {
let component: PdfViewerComponent;
let fixture: ComponentFixture<PdfViewerComponent>;
@ -158,11 +158,6 @@ xdescribe('Test PdfViewer component', () => {
done();
});
});
afterEach(() => {
fixture.destroy();
});
it('should Loader be present', () => {
expect(element.querySelector('.loader-container')).not.toBeNull();
});
@ -203,7 +198,7 @@ xdescribe('Test PdfViewer component', () => {
});
afterEach(() => {
fixtureUrlTestComponent.destroy();
document.body.removeChild(elementUrlTestComponent);
});
it('should Canvas be present', (done) => {
@ -270,26 +265,28 @@ xdescribe('Test PdfViewer component', () => {
});
afterEach(() => {
fixtureBlobTestComponent.destroy();
document.body.removeChild(elementBlobTestComponent);
});
it('should Canvas be present', async(() => {
it('should Canvas be present', (done) => {
fixtureBlobTestComponent.detectChanges();
fixtureBlobTestComponent.whenStable().then(() => {
expect(elementBlobTestComponent.querySelector('.pdfViewer')).not.toBeNull();
expect(elementBlobTestComponent.querySelector('.viewer-pdf-viewer')).not.toBeNull();
done();
});
});
}));
it('should Next an Previous Buttons be present', async(() => {
it('should Next an Previous Buttons be present', (done) => {
fixtureBlobTestComponent.detectChanges();
fixtureBlobTestComponent.whenStable().then(() => {
expect(elementBlobTestComponent.querySelector('#viewer-previous-page-button')).not.toBeNull();
expect(elementBlobTestComponent.querySelector('#viewer-next-page-button')).not.toBeNull();
done();
});
});
}));
it('should Input Page elements be present', (done) => {
fixtureBlobTestComponent.detectChanges();
@ -338,7 +335,7 @@ xdescribe('Test PdfViewer component', () => {
});
afterEach(() => {
fixtureUrlTestComponent.destroy();
document.body.removeChild(elementUrlTestComponent);
});
it('should Total number of pages be loaded', (done) => {
@ -362,7 +359,7 @@ xdescribe('Test PdfViewer component', () => {
});
}, 5000);
xit('should event RIGHT_ARROW keyboard change pages', async(() => {
it('should event RIGHT_ARROW keyboard change pages', (done) => {
EventMock.keyDown(RIGHT_ARROW);
fixtureUrlTestComponent.detectChanges();
@ -370,10 +367,11 @@ xdescribe('Test PdfViewer component', () => {
fixtureUrlTestComponent.whenStable().then(() => {
fixtureUrlTestComponent.detectChanges();
expect(componentUrlTestComponent.pdfViewerComponent.displayPage).toBe(2);
done();
});
}), 5000);
}, 5000);
xit('should event LEFT_ARROW keyboard change pages', (done) => {
it('should event LEFT_ARROW keyboard change pages', (done) => {
component.inputPage('2');
fixtureUrlTestComponent.detectChanges();
@ -565,6 +563,10 @@ xdescribe('Test PdfViewer component', () => {
});
});
afterEach(() => {
document.body.removeChild(fixtureUrlTestPasswordComponent.nativeElement);
});
it('should try to access protected pdf', (done) => {
fixture.detectChanges();
fixture.whenStable().then(() => {

View File

@ -18,7 +18,7 @@
import { Location } from '@angular/common';
import { SpyLocation } from '@angular/common/testing';
import { Component } from '@angular/core';
import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { AlfrescoApiService, RenditionsService } from '../../services';
import { CoreModule } from '../../core.module';
@ -119,7 +119,7 @@ class ViewerWithCustomOpenWithComponent {
class ViewerWithCustomMoreActionsComponent {
}
xdescribe('ViewerComponent', () => {
describe('ViewerComponent', () => {
let component: ViewerComponent;
let fixture: ComponentFixture<ViewerComponent>;
@ -159,10 +159,6 @@ xdescribe('ViewerComponent', () => {
alfrescoApiService = TestBed.get(AlfrescoApiService);
});
afterEach(() => {
fixture.destroy();
});
describe('Extension Type Test', () => {
it('should extension file pdf be loaded', (done) => {
@ -201,7 +197,7 @@ xdescribe('ViewerComponent', () => {
});
});
it('should extension file mp3 be loaded', (done) => {
xit('should extension file mp3 be loaded', (done) => {
component.urlFile = 'fake-url-file.mp3';
component.ngOnChanges(null);
fixture.detectChanges();
@ -213,7 +209,7 @@ xdescribe('ViewerComponent', () => {
});
});
it('should extension file wav be loaded', (done) => {
xit('should extension file wav be loaded', (done) => {
component.urlFile = 'fake-url-file.wav';
component.ngOnChanges(null);
fixture.detectChanges();
@ -331,7 +327,7 @@ xdescribe('ViewerComponent', () => {
});
});
it('should display the media player if the file identified by mimetype is a media when the filename has no extension', (done) => {
xit('should display the media player if the file identified by mimetype is a media when the filename has no extension', (done) => {
component.urlFile = 'content';
component.mimeType = 'video/mp4';
fixture.detectChanges();
@ -344,7 +340,7 @@ xdescribe('ViewerComponent', () => {
});
});
it('should node without content show unkonwn', async(() => {
it('should node without content show unkonwn', (done) => {
const displayName = 'the-name';
const nodeDetails = { name: displayName, id: '12' };
const contentUrl = '/content/url/path';
@ -362,8 +358,9 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('adf-viewer-unknown-format')).toBeDefined();
done();
});
});
}));
});
@ -393,7 +390,7 @@ xdescribe('ViewerComponent', () => {
expect(component.fileTitle).toBe('file2');
}));
xdescribe('Viewer Example Component Rendering', () => {
describe('Viewer Example Component Rendering', () => {
it('should use custom toolbar', (done) => {
let customFixture = TestBed.createComponent(ViewerWithCustomToolbarComponent);
@ -566,17 +563,20 @@ xdescribe('ViewerComponent', () => {
});
});
it('should raise download event with the toolbar button', async(() => {
it('should raise download event with the toolbar button', (done) => {
component.allowDownload = true;
component.downloadUrl = 'URL';
component.fileName = 'fileName';
fixture.detectChanges();
component.download.subscribe(e => {
expect(e).not.toBeNull();
done();
});
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-download"]') as HTMLButtonElement;
button.click();
}));
});
it('should render default print button', (done) => {
component.allowPrint = true;
@ -613,17 +613,18 @@ xdescribe('ViewerComponent', () => {
});
});
it('should raise the print event with the toolbar button', async(() => {
it('should raise the print event with the toolbar button', (done) => {
component.allowPrint = true;
fixture.detectChanges();
component.print.subscribe(e => {
expect(e).not.toBeNull();
done();
});
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-print"]') as HTMLButtonElement;
button.click();
}));
});
it('should render default share button', (done) => {
component.allowShare = true;
@ -660,17 +661,18 @@ xdescribe('ViewerComponent', () => {
});
});
it('should raise share event with the toolbar button', async(() => {
it('should raise share event with the toolbar button', (done) => {
component.allowShare = true;
fixture.detectChanges();
component.share.subscribe(e => {
expect(e).not.toBeNull();
done();
});
const button: HTMLButtonElement = element.querySelector('[data-automation-id="adf-toolbar-share"]') as HTMLButtonElement;
button.click();
}));
});
});
@ -687,14 +689,15 @@ xdescribe('ViewerComponent', () => {
expect(element.querySelector('.adf-viewer-toolbar')).not.toBeNull();
});
it('should Name File be present if is overlay mode ', async(() => {
it('should Name File be present if is overlay mode ', (done) => {
component.ngOnChanges(null);
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('fake-test-file.pdf');
done();
});
});
}));
it('should Close button be present if overlay mode', (done) => {
fixture.detectChanges();
@ -843,21 +846,22 @@ xdescribe('ViewerComponent', () => {
describe('Events', () => {
it('should if the extension change extension Change event be fired ', async(() => {
it('should if the extension change extension Change event be fired ', (done) => {
component.extensionChange.subscribe((fileExtension) => {
expect(fileExtension).toEqual('png');
done();
});
component.urlFile = 'fake-url-file.png';
component.ngOnChanges(null);
}));
});
});
describe('display name property override by urlFile', () => {
it('should displayName override the default name if is present and urlFile is set', async(() => {
it('should displayName override the default name if is present and urlFile is set', (done) => {
component.urlFile = 'fake-test-file.pdf';
component.displayName = 'test name';
fixture.detectChanges();
@ -866,10 +870,11 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('test name');
done();
});
});
}));
it('should use the urlFile name if displayName is NOT set and urlFile is set', async(() => {
it('should use the urlFile name if displayName is NOT set and urlFile is set', (done) => {
component.urlFile = 'fake-test-file.pdf';
component.displayName = null;
fixture.detectChanges();
@ -878,13 +883,14 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('fake-test-file.pdf');
done();
});
});
}));
});
describe('display name property override by blobFile', () => {
it('should displayName override the name if is present and blobFile is set', async(() => {
it('should displayName override the name if is present and blobFile is set', (done) => {
component.displayName = 'blob file display name';
component.blobFile = new Blob(['This is my blob content'], { type: 'text/plain' });
fixture.detectChanges();
@ -893,10 +899,11 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('blob file display name');
done();
});
});
}));
it('should show uknownn name if displayName is NOT set and blobFile is set', async(() => {
it('should show uknownn name if displayName is NOT set and blobFile is set', (done) => {
component.displayName = null;
component.blobFile = new Blob(['This is my blob content'], { type: 'text/plain' });
fixture.detectChanges();
@ -905,8 +912,9 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual('Unknown');
done();
});
});
}));
});
describe('display name property override by nodeId', () => {
@ -919,7 +927,7 @@ xdescribe('ViewerComponent', () => {
content: { getContentUrl: () => contentUrl }
};
it('should use the node name if displayName is NOT set and fileNodeId is set', async(() => {
it('should use the node name if displayName is NOT set and fileNodeId is set', (done) => {
component.fileNodeId = '12';
component.urlFile = null;
component.displayName = null;
@ -929,8 +937,9 @@ xdescribe('ViewerComponent', () => {
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(element.querySelector('#adf-viewer-display-name').textContent).toEqual(displayName);
done();
});
});
}));
});
});

View File

@ -68,7 +68,7 @@ module.exports = function (config) {
},
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_INFO,
colors: true,
@ -92,9 +92,6 @@ module.exports = function (config) {
reporters: ['mocha', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});

View File

@ -130,15 +130,16 @@ describe('TaskAttachmentList', () => {
expect(getTaskRelatedContentSpy).not.toHaveBeenCalled();
});
it('should display attachments when the task has attachments', async(() => {
it('should display attachments when the task has attachments', (done) => {
let change = new SimpleChange(null, '123', true);
component.ngOnChanges({ 'taskId': change });
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(fixture.debugElement.queryAll(By.css('.adf-datatable-body > .adf-datatable-row')).length).toBe(2);
done();
});
});
}));
it('emit document when a user wants to view the document', () => {
component.emitDocumentContent(mockAttachment.data[1]);
@ -271,13 +272,14 @@ describe('TaskAttachmentList', () => {
});
}));
it('should fetch new attachments when taskId changed', async(() => {
it('should fetch new attachments when taskId changed', (done) => {
fixture.detectChanges();
fixture.whenStable().then(() => {
component.ngOnChanges({ 'taskId': change });
expect(getTaskRelatedContentSpy).toHaveBeenCalledWith('456');
done();
});
});
}));
it('should NOT fetch new attachments when empty change set made', () => {
component.ngOnChanges({});

View File

@ -71,7 +71,7 @@ module.exports = function (config) {
},
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_INFO,
colors: true,
@ -95,9 +95,6 @@ module.exports = function (config) {
reporters: ['mocha', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});