mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
GH Auto: Upstream dependencies ADF:8.6.0-26272920976 JS-API:9.6.0-26272920976 using Tag:8.6.0-26272920976 (#5178)
* [ci:force][auto-commit] Update dependencies ADF:8.6.0-26272920976 JS:9.6.0-26272920976 * remove adf-core.globals * file upload fix * fail e2e with wait fix * fix(e2e): unique username + viewer content render wait * feat(viewer): register providePdfViewer for ADF 8.6.0+ * exclude test * fix comment --------- Co-authored-by: MichalKinas <113341662+MichalKinas@users.noreply.github.com> Co-authored-by: Mykyta Maliarchuk <mykyta.maliarchuk@hyland.com> Co-authored-by: akashrathod28 <akash.rathod@hyland.com>
This commit is contained in:
co-authored by
MichalKinas
Mykyta Maliarchuk
akashrathod28
parent
adadbe17d5
commit
c4ff14f359
@@ -23,10 +23,23 @@
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { File as NodeFile } from 'node:buffer';
|
||||
import { ApiClientFactory } from './api-client-factory';
|
||||
import { logger, Utils, waitForApi } from '../utils';
|
||||
import { NodeBodyCreate, NodeEntry, ResultSetPaging, SearchRequest } from '@alfresco/js-api';
|
||||
|
||||
const fileFixtureCache = new Map<string, Buffer>();
|
||||
|
||||
async function toUploadFile(fileLocation: string): Promise<NodeFile> {
|
||||
let buffer = fileFixtureCache.get(fileLocation);
|
||||
if (!buffer) {
|
||||
buffer = await fs.promises.readFile(fileLocation);
|
||||
fileFixtureCache.set(fileLocation, buffer);
|
||||
}
|
||||
return new NodeFile([buffer], path.basename(fileLocation));
|
||||
}
|
||||
|
||||
export class FileActionsApi {
|
||||
private readonly apiService: ApiClientFactory;
|
||||
|
||||
@@ -41,7 +54,7 @@ export class FileActionsApi {
|
||||
}
|
||||
|
||||
async uploadFile(fileLocation: string, fileName: string, parentFolderId: string): Promise<NodeEntry> {
|
||||
const file = fs.createReadStream(fileLocation);
|
||||
const file = await toUploadFile(fileLocation);
|
||||
try {
|
||||
const result = await this.apiService.upload.uploadFile(file, '', parentFolderId, undefined, {
|
||||
name: fileName,
|
||||
@@ -63,7 +76,7 @@ export class FileActionsApi {
|
||||
title: string = '',
|
||||
description: string = ''
|
||||
): Promise<NodeEntry> {
|
||||
const file = fs.createReadStream(fileLocation);
|
||||
const file = await toUploadFile(fileLocation);
|
||||
const nodeProps = {
|
||||
properties: {
|
||||
'cm:title': title,
|
||||
|
||||
@@ -37,7 +37,7 @@ export class ViewerComponent extends BaseComponent {
|
||||
public shareButton = this.getChild('button[id="share-action-button"]');
|
||||
public downloadButton = this.getChild('button[id="app.viewer.download"]');
|
||||
public unknownFormat = this.getChild(`adf-viewer-unknown-format .adf-viewer__unknown-format-view`);
|
||||
public viewerImage = this.viewerLocator.locator('.cropper-canvas img');
|
||||
public viewerImage = this.viewerLocator.locator('#viewer-image');
|
||||
public viewerDocument = this.viewerLocator.locator('.adf-pdf-viewer__content [role="document"]');
|
||||
public documentThumbnailButton = this.getChild('[data-automation-id="adf-thumbnails-button"]');
|
||||
public thumbnailsPages = this.getChild('[data-automation-id="adf-thumbnails-content"] adf-pdf-thumb');
|
||||
@@ -72,12 +72,24 @@ export class ViewerComponent extends BaseComponent {
|
||||
|
||||
async waitForViewerToOpen(): Promise<void> {
|
||||
await this.waitForViewerLoaderToFinish();
|
||||
await this.viewerLocator.waitFor({ state: 'visible', timeout: timeouts.extraLarge });
|
||||
await this.viewerLocator.waitFor({ state: 'visible', timeout: timeouts.large });
|
||||
}
|
||||
|
||||
async waitForViewerLoaderToFinish(): Promise<void> {
|
||||
await this.viewerSpinner.waitFor({ state: 'attached', timeout: timeouts.medium }).catch(() => {});
|
||||
await this.viewerSpinner.waitFor({ state: 'detached', timeout: timeouts.fortySeconds }).catch(() => {});
|
||||
await this.viewerSpinner.waitFor({ state: 'attached', timeout: timeouts.short }).catch(() => {});
|
||||
await this.viewerSpinner.waitFor({ state: 'detached', timeout: timeouts.extraLarge }).catch(() => {});
|
||||
}
|
||||
|
||||
async waitForViewerContentToRender(type: 'document' | 'image' | 'media' = 'document'): Promise<void> {
|
||||
if (type === 'image') {
|
||||
await this.viewerImage.waitFor({ state: 'attached', timeout: timeouts.extraLarge });
|
||||
return;
|
||||
}
|
||||
if (type === 'media') {
|
||||
await this.viewerMedia.waitFor({ state: 'visible', timeout: timeouts.extraLarge });
|
||||
return;
|
||||
}
|
||||
await this.pdfViewerContentPages.first().waitFor({ state: 'attached', timeout: timeouts.extraLarge });
|
||||
}
|
||||
|
||||
async checkViewerActivePage(pageNumber: number): Promise<void> {
|
||||
@@ -118,7 +130,6 @@ export class ViewerComponent extends BaseComponent {
|
||||
|
||||
async getFileTitle(): Promise<string> {
|
||||
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
|
||||
await this.waitForViewerLoaderToFinish();
|
||||
const title = await this.fileTitleButtonLocator.textContent();
|
||||
if (!title) {
|
||||
const errorMessage = 'File title is not displayed in the viewer';
|
||||
@@ -159,7 +170,8 @@ export class ViewerComponent extends BaseComponent {
|
||||
}
|
||||
|
||||
async checkUnknownFormatIsDisplayed(): Promise<void> {
|
||||
await this.unknownFormat.waitFor({ state: 'visible', timeout: timeouts.normal });
|
||||
await this.waitForViewerLoaderToFinish();
|
||||
await this.unknownFormat.waitFor({ state: 'visible', timeout: timeouts.fortySeconds });
|
||||
}
|
||||
|
||||
async getUnknownFormatMessage(): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user