Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-8865] Viewer / DOCX files could not load preview for the first 20 seconds - error 409 for renditions #10267

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[ACS-8865] reduce duplication
nikita-web-ua committed Oct 2, 2024
commit bc7a9600c158f4060b9f8470a79c1950754e0caf
Original file line number Diff line number Diff line change
@@ -147,10 +147,19 @@ class ViewerWithCustomOpenWithComponent {}
})
class ViewerWithCustomMoreActionsComponent {}

const getSimpleChanges = (currentValue: string, previousValue?: string): SimpleChanges => {
return {
nodeId: new SimpleChange(previousValue || null, currentValue, false)
};
const getSimpleChanges = (currentValue: string, previousValue?: string): SimpleChanges => ({
nodeId: new SimpleChange(previousValue || null, currentValue, false)
});

const verifyCustomElement = (component: any, selector: string, done: DoneFn) => {
const customFixture = TestBed.createComponent(component);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();
customFixture.whenStable().then(() => {
expect(customElement.querySelector(selector)).toBeDefined();
done();
});
};

describe('AlfrescoViewerComponent', () => {
@@ -365,61 +374,23 @@ describe('AlfrescoViewerComponent', () => {

describe('Viewer Example Component Rendering', () => {
it('should use custom toolbar', (done) => {
const customFixture = TestBed.createComponent(ViewerWithCustomToolbarComponent);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();
fixture.whenStable().then(() => {
expect(customElement.querySelector('.custom-toolbar-element')).toBeDefined();
done();
});
verifyCustomElement(ViewerWithCustomToolbarComponent, '.custom-toolbar-element', done);
});

it('should use custom toolbar actions', (done) => {
const customFixture = TestBed.createComponent(ViewerWithCustomToolbarActionsComponent);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();
fixture.whenStable().then(() => {
expect(customElement.querySelector('#custom-button')).toBeDefined();
done();
});
verifyCustomElement(ViewerWithCustomToolbarActionsComponent, '#custom-button', done);
});

it('should use custom info drawer', (done) => {
const customFixture = TestBed.createComponent(ViewerWithCustomSidebarComponent);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();

fixture.whenStable().then(() => {
expect(customElement.querySelector('.custom-info-drawer-element')).toBeDefined();
done();
});
verifyCustomElement(ViewerWithCustomSidebarComponent, '.custom-info-drawer-element', done);
});

it('should use custom open with menu', (done) => {
const customFixture = TestBed.createComponent(ViewerWithCustomOpenWithComponent);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();

fixture.whenStable().then(() => {
expect(customElement.querySelector('.adf-viewer-container-open-with')).toBeDefined();
done();
});
verifyCustomElement(ViewerWithCustomOpenWithComponent, '.adf-viewer-container-open-with', done);
});

it('should use custom more actions menu', (done) => {
const customFixture = TestBed.createComponent(ViewerWithCustomMoreActionsComponent);
const customElement: HTMLElement = customFixture.nativeElement;

customFixture.detectChanges();

fixture.whenStable().then(() => {
expect(customElement.querySelector('.adf-viewer-container-more-actions')).toBeDefined();
done();
});
verifyCustomElement(ViewerWithCustomMoreActionsComponent, '.adf-viewer-container-more-actions', done);
});

it('should stop propagation on sidebar keydown event [keydown]', async () => {