mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-11762] Automated MNT 25285 (#5190)
* [ACS-11762] Automated MNT 25285 * [ACS-11762] small refactoring * [ACS-11762] more fixes for viewer tests * [ACS-11762] NOSONAR added for type issue * [ACS-11762] copilot review fixes 1 * [ACS-11762] copilot review fixes 2 * [ACS-11762] copilot review fixes 3 * [ACS-11762] review fixes 1 * [ACS-11762] race condition fixed
This commit is contained in:
@@ -239,7 +239,7 @@ export class FileActionsApi {
|
||||
}
|
||||
}
|
||||
|
||||
async updateNodeContent(nodeId: string, content: string, majorVersion: boolean = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
||||
async updateNodeContent(nodeId: string, content: string | Buffer, majorVersion = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
||||
try {
|
||||
const opts: { [key: string]: string | boolean } = { majorVersion };
|
||||
if (comment !== undefined) {
|
||||
@@ -248,10 +248,15 @@ export class FileActionsApi {
|
||||
if (newName !== undefined) {
|
||||
opts['name'] = newName;
|
||||
}
|
||||
return await this.apiService.nodes.updateNodeContent(nodeId, content, opts);
|
||||
return await this.apiService.nodes.updateNodeContent(nodeId, content as unknown as string, opts); // NOSONAR
|
||||
} catch (error) {
|
||||
logger.error(`${this.constructor.name} ${this.updateNodeContent.name}: ${error}`);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
async updateNodeContentFromFile(nodeId: string, fileLocation: string, majorVersion = true, comment?: string, newName?: string): Promise<NodeEntry> {
|
||||
const fileContent = await fs.promises.readFile(fileLocation);
|
||||
return this.updateNodeContent(nodeId, fileContent, majorVersion, comment, newName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ViewerComponent extends BaseComponent {
|
||||
public thumbnailsCloseButton = this.getChild('[data-automation-id="adf-thumbnails-close"]');
|
||||
public viewerPage = this.getChild('[data-automation-id="adf-page-selector"]');
|
||||
public viewerMedia = this.getChild('adf-media-player');
|
||||
public viewerSpinner = this.getChild('.adf-viewer-render__loading-screen');
|
||||
public viewerSpinner = this.getChild('.adf-viewer-render__loading-screen__spinner');
|
||||
public zoomInButton = this.getChild('#viewer-zoom-in-button');
|
||||
public zoomOutButton = this.getChild('#viewer-zoom-out-button');
|
||||
public zoomScale = this.getChild('[data-automation-id="adf-page-scale"]');
|
||||
@@ -75,13 +75,9 @@ export class ViewerComponent extends BaseComponent {
|
||||
await this.viewerLocator.waitFor({ state: 'visible', timeout: timeouts.large });
|
||||
}
|
||||
|
||||
async waitForViewerLoaderToFinish(customTimeout?: number): Promise<void> {
|
||||
try {
|
||||
await this.viewerSpinner.waitFor({ state: 'hidden', timeout: customTimeout || timeouts.extraLarge });
|
||||
} catch (error) {
|
||||
this.logger.log('waitForViewerLoaderToFinish: Timeout reached while waiting for viewer loader to finish.');
|
||||
throw error;
|
||||
}
|
||||
async waitForViewerLoaderToFinish(): Promise<void> {
|
||||
await this.viewerSpinner.waitFor({ state: 'attached', timeout: timeouts.medium }).catch(() => {});
|
||||
await this.viewerSpinner.waitFor({ state: 'detached', timeout: timeouts.fortySeconds }).catch(() => {});
|
||||
}
|
||||
|
||||
async checkViewerActivePage(pageNumber: number): Promise<void> {
|
||||
@@ -105,7 +101,7 @@ export class ViewerComponent extends BaseComponent {
|
||||
async waitForZoomPercentageToDisplay(): Promise<void> {
|
||||
await this.zoomScale.waitFor({ state: 'visible', timeout: timeouts.normal });
|
||||
const startTime = Date.now();
|
||||
let textContent: string;
|
||||
let textContent = '';
|
||||
|
||||
while (Date.now() - startTime <= timeouts.medium) {
|
||||
textContent = await this.zoomScale.innerText();
|
||||
@@ -123,12 +119,24 @@ export class ViewerComponent extends BaseComponent {
|
||||
async getFileTitle(): Promise<string> {
|
||||
await this.fileTitleButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
|
||||
await this.waitForViewerLoaderToFinish();
|
||||
return this.fileTitleButtonLocator.textContent();
|
||||
const title = await this.fileTitleButtonLocator.textContent();
|
||||
if (!title) {
|
||||
const errorMessage = 'File title is not displayed in the viewer';
|
||||
this.logger.error(errorMessage);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
async getCloseButtonTooltip(): Promise<string> {
|
||||
await this.closeButtonLocator.waitFor({ state: 'visible', timeout: timeouts.normal });
|
||||
return this.closeButtonLocator.getAttribute('title');
|
||||
const tooltip = await this.closeButtonLocator.getAttribute('title');
|
||||
if (!tooltip) {
|
||||
const errorMessage = 'Close button tooltip is not available';
|
||||
this.logger.error(errorMessage);
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
async verifyViewerPrimaryActions(expectedToolbarPrimary: string[]): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user