mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-11868] check pdf viewer e2e file (#5279)
* [ACS-11868] fix for excluded test add document check * [ACS-11868] fix test check pdf and image viewer-e2e-test * [ACS-11868] fix test check pdf and image viewer-e2e-test * resolve pr review changes * text fix * review fix
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
{
|
||||
"all": {
|
||||
"XAT-19377": "https://hyland.atlassian.net/browse/ACS-11868"
|
||||
}
|
||||
}
|
||||
"all": {}
|
||||
}
|
||||
@@ -89,8 +89,9 @@ test.describe('Version actions', () => {
|
||||
fileId = (await fileActionsApi.uploadFile(filesToUpload[0].path, filenameBeforeUpdate, '-my-')).entry.id;
|
||||
|
||||
fileAfterUpdateId = (
|
||||
await fileActionsApi.updateNodeContentFromFile(fileId, filesToUpload[1].path, true, 'new major version description', filenameAfterUpdate)
|
||||
await fileActionsApi.uploadNewVersionFile(fileId, filesToUpload[1].path, filenameAfterUpdate, true, 'new major version description')
|
||||
).entry.id;
|
||||
await fileActionsApi.waitForNodes(filenameAfterUpdate, { expect: 1 });
|
||||
|
||||
await favoritesApi.addFavoritesByIds('file', [fileId]);
|
||||
await favoritesApi.waitForApi(username, { expect: 1 });
|
||||
@@ -132,6 +133,8 @@ test.describe('Version actions', () => {
|
||||
|
||||
test('[XAT-19377] Can view previous version of a document after a viewer is opened from Manage Versions dialog', async ({ personalFiles }) => {
|
||||
await personalFiles.viewer.waitForViewerToOpen();
|
||||
await personalFiles.viewer.waitForViewerContentToRender('document');
|
||||
|
||||
await personalFiles.viewer.toolbar.clickViewerMoreActions();
|
||||
await personalFiles.matMenu.clickMenuItem('Manage Versions');
|
||||
await personalFiles.manageVersionsDialog.clickListActionButtonForVersion('2.0');
|
||||
|
||||
@@ -69,6 +69,34 @@ export class FileActionsApi {
|
||||
}
|
||||
}
|
||||
|
||||
async uploadNewVersionFile(nodeId: string, fileLocation: string, newFileName: string, majorVersion = true, comment = ''): Promise<NodeEntry> {
|
||||
try {
|
||||
const existingNode = await this.apiService.nodes.getNode(nodeId);
|
||||
const parentId = existingNode.entry.parentId;
|
||||
|
||||
if (newFileName !== existingNode.entry.name) {
|
||||
await this.apiService.nodes.updateNode(nodeId, { name: newFileName });
|
||||
}
|
||||
|
||||
const file = await toUploadFile(fileLocation);
|
||||
await this.apiService.upload.uploadFile(file, '', parentId, undefined, {
|
||||
name: newFileName,
|
||||
nodeType: 'cm:content',
|
||||
renditions: 'doclib',
|
||||
overwrite: true,
|
||||
majorVersion,
|
||||
comment
|
||||
});
|
||||
|
||||
logger.info(`New version uploaded successfully for node ${nodeId}: ${newFileName}`);
|
||||
return await this.apiService.nodes.getNode(nodeId);
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? (error.stack ?? error.message) : JSON.stringify(error);
|
||||
logger.error(`Failed to upload new version for node ${nodeId}: ${errorMessage}`);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFileWithRename(
|
||||
fileLocation: string,
|
||||
newName: string,
|
||||
@@ -262,9 +290,4 @@ export class FileActionsApi {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,13 +154,8 @@ export class ViewerComponent extends BaseComponent {
|
||||
const toRemove = ['Close', 'Previous File', 'Next File', 'View details'];
|
||||
const removeClosePreviousNextOldInfo = (actions: string[]): string[] => actions.filter((elem) => !toRemove.includes(elem));
|
||||
|
||||
const buttons = await this.page.$$('adf-viewer button');
|
||||
let actualPrimaryActions: string[] = await Promise.all(
|
||||
buttons.map(async (button) => {
|
||||
const title = await button.getAttribute('title');
|
||||
return title || '';
|
||||
})
|
||||
);
|
||||
const buttons = await this.page.locator('adf-viewer button').all();
|
||||
let actualPrimaryActions: string[] = await Promise.all(buttons.map(async (button) => (await button.getAttribute('title')) ?? ''));
|
||||
|
||||
actualPrimaryActions = removeClosePreviousNextOldInfo(actualPrimaryActions);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user