mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
ACS 9871 - add additional transformation rule tests (#4927)
* ACS-9871: Add transformation rule tests and supporting methods * ACS-9871: Add transformation rule tests and supporting methods (Addressed PR Comments) * ACS-9871: Fix async expect pattern in transformation tests * ACS-9871: Add readonly modifiers and clean up code formatting * ACS-9871: Simplify expect statements and reorder assertions * ACS-9871: Refactor transformation tests with helper function - Add testTransformation helper function to reduce code duplication - Refactor PDF, BMP, and JPG transformation tests to use helper - Improve test maintainability and readability - Add comprehensive JSDoc documentation * ACS-9871: Replace any types with proper Page Object types - Replace 'any' with PersonalFilesPage, NodesPage, and LoginPage - Add proper imports for page object types - Improve type safety in testTransformation helper function * ACS-9871: Add image transformation tests for GIF, TIFF, and PNG - Add new test cases for GIF, TIFF, and PNG transformations - Add MimeType enums for GIFImage, TIFFImage, and PNGImage - Add TIFF_FILE and BMP_FILE to test-files registry - Add physical test files (file-tif.tif, file-bmp.bmp) - Test multiple image format conversions (JPG, PNG, BMP, GIF, TIFF) * Fix parallel test execution by removing logout/login cycle in transformation tests * Refactor transformation tests to reduce code duplication for SonarQube * Refactor transformation tests following Single Responsibility Principle and extract TestFileConfig interface to shared models * Replace any type with Page type in triggerTransformation function
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { expect } from '@playwright/test';
|
import { expect, Page } from '@playwright/test';
|
||||||
import {
|
import {
|
||||||
ActionType,
|
ActionType,
|
||||||
ApiClientFactory,
|
ApiClientFactory,
|
||||||
@@ -32,9 +32,79 @@ import {
|
|||||||
NodesApi,
|
NodesApi,
|
||||||
MimeType,
|
MimeType,
|
||||||
FileActionsApi,
|
FileActionsApi,
|
||||||
TEST_FILES
|
TEST_FILES,
|
||||||
|
PersonalFilesPage,
|
||||||
|
NodesPage,
|
||||||
|
timeouts,
|
||||||
|
TestFileConfig
|
||||||
} from '@alfresco/aca-playwright-shared';
|
} from '@alfresco/aca-playwright-shared';
|
||||||
|
|
||||||
|
function generateUniqueFiles(testFiles: Array<TestFileConfig>): Array<TestFileConfig> {
|
||||||
|
return testFiles.map((file) => ({ path: file.path, name: `${file.name}-${Utils.random()}` }));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setupTransformationTest(
|
||||||
|
context: { personalFiles: PersonalFilesPage; nodesPage: NodesPage },
|
||||||
|
config: {
|
||||||
|
nodesApi: NodesApi;
|
||||||
|
testString: string;
|
||||||
|
parentFolderName: string;
|
||||||
|
destinationFolderName: string;
|
||||||
|
mimeType: MimeType;
|
||||||
|
}
|
||||||
|
): Promise<string> {
|
||||||
|
const { personalFiles, nodesPage } = context;
|
||||||
|
const { nodesApi, testString, parentFolderName, destinationFolderName, mimeType } = config;
|
||||||
|
|
||||||
|
const parentFolderId = (await nodesApi.createFolder(parentFolderName)).entry.id;
|
||||||
|
await nodesApi.createFolder(destinationFolderName);
|
||||||
|
|
||||||
|
await personalFiles.navigate({ remoteUrl: `#/nodes/${parentFolderId}/rules` });
|
||||||
|
await nodesPage.toolbar.clickCreateRuleButton();
|
||||||
|
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(testString);
|
||||||
|
await nodesPage.manageRulesDialog.ruleDescriptionInputLocator.fill(testString);
|
||||||
|
await nodesPage.actionsDropdown.selectAction(ActionType.TransformAndCopyContent, 0);
|
||||||
|
await nodesPage.actionsDropdown.selectMimeType(mimeType, 0);
|
||||||
|
await nodesPage.actionsDropdown.selectDestinationFolderTransformAndCopyContent(0, destinationFolderName);
|
||||||
|
await nodesPage.manageRulesDialog.createRuleButton.click();
|
||||||
|
await expect(nodesPage.manageRules.getGroupsList(testString)).toBeVisible();
|
||||||
|
return parentFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function triggerTransformation(config: {
|
||||||
|
fileActionApi: FileActionsApi;
|
||||||
|
files: Array<TestFileConfig>;
|
||||||
|
parentFolderId: string;
|
||||||
|
page: Page;
|
||||||
|
}): Promise<void> {
|
||||||
|
const { fileActionApi, files, parentFolderId, page } = config;
|
||||||
|
for (const file of files) {
|
||||||
|
await fileActionApi.uploadFile(file.path, file.name, parentFolderId);
|
||||||
|
}
|
||||||
|
await page.waitForTimeout(timeouts.medium);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function verifyTransformation(
|
||||||
|
context: { personalFiles: PersonalFilesPage },
|
||||||
|
config: {
|
||||||
|
destinationFolderName: string;
|
||||||
|
files: Array<TestFileConfig>;
|
||||||
|
expectedExtension: string;
|
||||||
|
}
|
||||||
|
): Promise<void> {
|
||||||
|
const { personalFiles } = context;
|
||||||
|
const { destinationFolderName, files, expectedExtension } = config;
|
||||||
|
|
||||||
|
await personalFiles.navigate();
|
||||||
|
await personalFiles.dataTable.performClickFolderOrFileToOpen(destinationFolderName);
|
||||||
|
await personalFiles.spinner.waitForReload();
|
||||||
|
for (const file of files) {
|
||||||
|
const transformedFileName = `${file.name}.${expectedExtension}`;
|
||||||
|
const exists = await personalFiles.dataTable.isItemPresent(transformedFileName);
|
||||||
|
expect(exists, `Transformed file ${transformedFileName} was not present in data table`).toBe(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test.use({ launchOptions: { slowMo: 300 } });
|
test.use({ launchOptions: { slowMo: 300 } });
|
||||||
test.describe('Folder Rules Actions', () => {
|
test.describe('Folder Rules Actions', () => {
|
||||||
const apiClientFactory = new ApiClientFactory();
|
const apiClientFactory = new ApiClientFactory();
|
||||||
@@ -42,17 +112,8 @@ test.describe('Folder Rules Actions', () => {
|
|||||||
let trashcanApi: TrashcanApi;
|
let trashcanApi: TrashcanApi;
|
||||||
let fileActionApi: FileActionsApi;
|
let fileActionApi: FileActionsApi;
|
||||||
const username = `user-e2e-${Utils.random()}`;
|
const username = `user-e2e-${Utils.random()}`;
|
||||||
|
|
||||||
const randomFolderName1 = `folder-name-${Utils.random()}`;
|
|
||||||
const randomDocxName = `${TEST_FILES.DOCX.name}-${Utils.random()}`;
|
|
||||||
const randomXLSXName = `${TEST_FILES.XLSX.name}-${Utils.random()}`;
|
|
||||||
const randomPPTXName = `${TEST_FILES.PPTX_FILE.name}-${Utils.random()}`;
|
|
||||||
|
|
||||||
const copyFileName = `copy-file-${Utils.random()}`;
|
|
||||||
const testString = '"!@£$%^&*()_+{}|:""?><,/.\';][=-`~"';
|
const testString = '"!@£$%^&*()_+{}|:""?><,/.\';][=-`~"';
|
||||||
|
|
||||||
let randomFolderName1Id: string;
|
|
||||||
|
|
||||||
test.beforeAll(async () => {
|
test.beforeAll(async () => {
|
||||||
try {
|
try {
|
||||||
await apiClientFactory.setUpAcaBackend('admin');
|
await apiClientFactory.setUpAcaBackend('admin');
|
||||||
@@ -60,8 +121,6 @@ test.describe('Folder Rules Actions', () => {
|
|||||||
nodesApi = await NodesApi.initialize(username, username);
|
nodesApi = await NodesApi.initialize(username, username);
|
||||||
trashcanApi = await TrashcanApi.initialize(username, username);
|
trashcanApi = await TrashcanApi.initialize(username, username);
|
||||||
fileActionApi = await FileActionsApi.initialize(username, username);
|
fileActionApi = await FileActionsApi.initialize(username, username);
|
||||||
randomFolderName1Id = (await nodesApi.createFolder(randomFolderName1)).entry.id;
|
|
||||||
await nodesApi.createFile(copyFileName, randomFolderName1Id);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`beforeAll failed : ${error}`);
|
console.error(`beforeAll failed : ${error}`);
|
||||||
}
|
}
|
||||||
@@ -75,31 +134,87 @@ test.describe('Folder Rules Actions', () => {
|
|||||||
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
|
await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('[XAT-8050] Supported types transformation to PDF', async ({ personalFiles, nodesPage, loginPage }) => {
|
test('[XAT-8050] Supported types transformation to PDF', async ({ personalFiles, nodesPage }) => {
|
||||||
const toFolderName = 'TO_PDF';
|
const parentFolderName = `parent-pdf-${Utils.random()}`;
|
||||||
await nodesApi.createFolder(toFolderName);
|
const destinationFolderName = `TO_PDF-${Utils.random()}`;
|
||||||
await personalFiles.navigate({ remoteUrl: `#/nodes/${randomFolderName1Id}/rules` });
|
const files = generateUniqueFiles([TEST_FILES.DOCX, TEST_FILES.XLSX, TEST_FILES.PPTX_FILE]);
|
||||||
await nodesPage.toolbar.clickCreateRuleButton();
|
|
||||||
await nodesPage.manageRulesDialog.ruleNameInputLocator.fill(testString);
|
const parentFolderId = await setupTransformationTest(
|
||||||
await nodesPage.manageRulesDialog.ruleDescriptionInputLocator.fill(testString);
|
{ personalFiles, nodesPage },
|
||||||
await nodesPage.actionsDropdown.selectAction(ActionType.TransformAndCopyContent, 0);
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.AdobePDFDocument }
|
||||||
await nodesPage.actionsDropdown.selectMimeType(MimeType.AdobePDFDocument, 0);
|
);
|
||||||
await nodesPage.actionsDropdown.selectDestinationFolderTransformAndCopyContent(0, toFolderName);
|
|
||||||
await nodesPage.manageRulesDialog.createRuleButton.click();
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
await expect(nodesPage.manageRules.getGroupsList(testString)).toBeVisible();
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'pdf' });
|
||||||
await fileActionApi.uploadFile(TEST_FILES.DOCX.path, randomDocxName, randomFolderName1Id);
|
});
|
||||||
await fileActionApi.uploadFile(TEST_FILES.XLSX.path, randomXLSXName, randomFolderName1Id);
|
|
||||||
await fileActionApi.uploadFile(TEST_FILES.PPTX_FILE.path, randomPPTXName, randomFolderName1Id);
|
test('[XAT-8051] Supported types transformation to BMP', async ({ personalFiles, nodesPage }) => {
|
||||||
await loginPage.logoutUser();
|
const parentFolderName = `parent-bmp-${Utils.random()}`;
|
||||||
await expect(loginPage.username, 'User name was not visible').toBeVisible();
|
const destinationFolderName = `TO_BMP-${Utils.random()}`;
|
||||||
await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed');
|
const files = generateUniqueFiles([TEST_FILES.JPG_FILE, TEST_FILES.PNG_FILE, TEST_FILES.GIF_FILE, TEST_FILES.TIFF_FILE]);
|
||||||
await personalFiles.dataTable.performClickFolderOrFileToOpen(toFolderName);
|
|
||||||
await personalFiles.spinner.waitForReload();
|
const parentFolderId = await setupTransformationTest(
|
||||||
const docxToPDF = `${randomDocxName}.pdf`;
|
{ personalFiles, nodesPage },
|
||||||
const xlsxToPDF = `${randomXLSXName}.pdf`;
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.BitmapImage }
|
||||||
const pptxToPDF = `${randomPPTXName}.pdf`;
|
);
|
||||||
expect(await personalFiles.dataTable.isItemPresent(docxToPDF), `Converted PDF from DOCX ${docxToPDF} was not present in data table`).toBe(true);
|
|
||||||
expect(await personalFiles.dataTable.isItemPresent(pptxToPDF), `Converted PDF from PPTX ${pptxToPDF} was not present in data table`).toBe(true);
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
expect(await personalFiles.dataTable.isItemPresent(xlsxToPDF), `Converted PDF from XLSX ${xlsxToPDF} was not present in data table`).toBe(true);
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'bmp' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[XAT-8052] Supported types transformation to JPG', async ({ personalFiles, nodesPage }) => {
|
||||||
|
const parentFolderName = `parent-jpg-${Utils.random()}`;
|
||||||
|
const destinationFolderName = `TO_JPG-${Utils.random()}`;
|
||||||
|
const files = generateUniqueFiles([TEST_FILES.PNG_FILE, TEST_FILES.GIF_FILE, TEST_FILES.BMP_FILE, TEST_FILES.TIFF_FILE]);
|
||||||
|
|
||||||
|
const parentFolderId = await setupTransformationTest(
|
||||||
|
{ personalFiles, nodesPage },
|
||||||
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.JPEGImage }
|
||||||
|
);
|
||||||
|
|
||||||
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'jpg' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[XAT-8053] Supported types transformation to GIF', async ({ personalFiles, nodesPage }) => {
|
||||||
|
const parentFolderName = `parent-gif-${Utils.random()}`;
|
||||||
|
const destinationFolderName = `TO_GIF-${Utils.random()}`;
|
||||||
|
const files = generateUniqueFiles([TEST_FILES.PNG_FILE, TEST_FILES.JPG_FILE, TEST_FILES.BMP_FILE, TEST_FILES.TIFF_FILE]);
|
||||||
|
|
||||||
|
const parentFolderId = await setupTransformationTest(
|
||||||
|
{ personalFiles, nodesPage },
|
||||||
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.GIFImage }
|
||||||
|
);
|
||||||
|
|
||||||
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'gif' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[XAT-8054] Supported types transformation to TIFF', async ({ personalFiles, nodesPage }) => {
|
||||||
|
const parentFolderName = `parent-tiff-${Utils.random()}`;
|
||||||
|
const destinationFolderName = `TO_TIFF-${Utils.random()}`;
|
||||||
|
const files = generateUniqueFiles([TEST_FILES.PNG_FILE, TEST_FILES.JPG_FILE, TEST_FILES.BMP_FILE, TEST_FILES.GIF_FILE]);
|
||||||
|
|
||||||
|
const parentFolderId = await setupTransformationTest(
|
||||||
|
{ personalFiles, nodesPage },
|
||||||
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.TIFFImage }
|
||||||
|
);
|
||||||
|
|
||||||
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'tif' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[XAT-8055] Supported types transformation to PNG', async ({ personalFiles, nodesPage }) => {
|
||||||
|
const parentFolderName = `parent-png-${Utils.random()}`;
|
||||||
|
const destinationFolderName = `TO_PNG-${Utils.random()}`;
|
||||||
|
const files = generateUniqueFiles([TEST_FILES.JPG_FILE, TEST_FILES.BMP_FILE, TEST_FILES.GIF_FILE, TEST_FILES.TIFF_FILE]);
|
||||||
|
|
||||||
|
const parentFolderId = await setupTransformationTest(
|
||||||
|
{ personalFiles, nodesPage },
|
||||||
|
{ nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.PNGImage }
|
||||||
|
);
|
||||||
|
|
||||||
|
await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page });
|
||||||
|
await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'png' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,3 +24,4 @@
|
|||||||
|
|
||||||
export * from './user-model';
|
export * from './user-model';
|
||||||
export * from './custom-config';
|
export * from './custom-config';
|
||||||
|
export * from './test-file.model';
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export interface TestFileConfig {
|
||||||
|
path: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
+6
-1
@@ -51,7 +51,12 @@ export enum ActionType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum MimeType {
|
export enum MimeType {
|
||||||
AdobePDFDocument = 'Adobe PDF Document [application/pdf]'
|
AdobePDFDocument = 'Adobe PDF Document [application/pdf]',
|
||||||
|
BitmapImage = 'Bitmap Image [image/bmp]',
|
||||||
|
JPEGImage = 'JPEG Image [image/jpeg]',
|
||||||
|
GIFImage = 'GIF Image [image/gif]',
|
||||||
|
TIFFImage = 'TIFF Image [image/tiff]',
|
||||||
|
PNGImage = 'PNG Image [image/png]'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ActionsDropdownComponent extends BaseComponent {
|
export class ActionsDropdownComponent extends BaseComponent {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 78 B |
Binary file not shown.
@@ -78,6 +78,14 @@ export const TEST_FILES = {
|
|||||||
path: resolve(__dirname, 'file-gif.gif'),
|
path: resolve(__dirname, 'file-gif.gif'),
|
||||||
name: 'file-gif'
|
name: 'file-gif'
|
||||||
},
|
},
|
||||||
|
TIFF_FILE: {
|
||||||
|
path: resolve(__dirname, 'file-tif.tif'),
|
||||||
|
name: 'file-tif'
|
||||||
|
},
|
||||||
|
BMP_FILE: {
|
||||||
|
path: resolve(__dirname, 'file-bmp.bmp'),
|
||||||
|
name: 'file-bmp'
|
||||||
|
},
|
||||||
PPTX_FILE: {
|
PPTX_FILE: {
|
||||||
path: resolve(__dirname, 'file-pptx.pptx'),
|
path: resolve(__dirname, 'file-pptx.pptx'),
|
||||||
name: 'file-pptx'
|
name: 'file-pptx'
|
||||||
|
|||||||
Reference in New Issue
Block a user