diff --git a/e2e/playwright/folder-rules/src/tests/transform-rules.e2e.ts b/e2e/playwright/folder-rules/src/tests/transform-rules.e2e.ts index 2c38dc1d3..7b11bc619 100644 --- a/e2e/playwright/folder-rules/src/tests/transform-rules.e2e.ts +++ b/e2e/playwright/folder-rules/src/tests/transform-rules.e2e.ts @@ -22,7 +22,7 @@ * from Hyland Software. If not, see . */ -import { expect } from '@playwright/test'; +import { expect, Page } from '@playwright/test'; import { ActionType, ApiClientFactory, @@ -32,9 +32,79 @@ import { NodesApi, MimeType, FileActionsApi, - TEST_FILES + TEST_FILES, + PersonalFilesPage, + NodesPage, + timeouts, + TestFileConfig } from '@alfresco/aca-playwright-shared'; +function generateUniqueFiles(testFiles: Array): Array { + 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 { + 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; + parentFolderId: string; + page: Page; +}): Promise { + 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; + expectedExtension: string; + } +): Promise { + 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.describe('Folder Rules Actions', () => { const apiClientFactory = new ApiClientFactory(); @@ -42,17 +112,8 @@ test.describe('Folder Rules Actions', () => { let trashcanApi: TrashcanApi; let fileActionApi: FileActionsApi; 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 = '"!@£$%^&*()_+{}|:""?><,/.\';][=-`~"'; - let randomFolderName1Id: string; - test.beforeAll(async () => { try { await apiClientFactory.setUpAcaBackend('admin'); @@ -60,8 +121,6 @@ test.describe('Folder Rules Actions', () => { nodesApi = await NodesApi.initialize(username, username); trashcanApi = await TrashcanApi.initialize(username, username); fileActionApi = await FileActionsApi.initialize(username, username); - randomFolderName1Id = (await nodesApi.createFolder(randomFolderName1)).entry.id; - await nodesApi.createFile(copyFileName, randomFolderName1Id); } catch (error) { console.error(`beforeAll failed : ${error}`); } @@ -75,31 +134,87 @@ test.describe('Folder Rules Actions', () => { await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed'); }); - test('[XAT-8050] Supported types transformation to PDF', async ({ personalFiles, nodesPage, loginPage }) => { - const toFolderName = 'TO_PDF'; - await nodesApi.createFolder(toFolderName); - await personalFiles.navigate({ remoteUrl: `#/nodes/${randomFolderName1Id}/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.AdobePDFDocument, 0); - await nodesPage.actionsDropdown.selectDestinationFolderTransformAndCopyContent(0, toFolderName); - await nodesPage.manageRulesDialog.createRuleButton.click(); - await expect(nodesPage.manageRules.getGroupsList(testString)).toBeVisible(); - 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); - await loginPage.logoutUser(); - await expect(loginPage.username, 'User name was not visible').toBeVisible(); - await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed'); - await personalFiles.dataTable.performClickFolderOrFileToOpen(toFolderName); - await personalFiles.spinner.waitForReload(); - const docxToPDF = `${randomDocxName}.pdf`; - const xlsxToPDF = `${randomXLSXName}.pdf`; - 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); - expect(await personalFiles.dataTable.isItemPresent(xlsxToPDF), `Converted PDF from XLSX ${xlsxToPDF} was not present in data table`).toBe(true); + test('[XAT-8050] Supported types transformation to PDF', async ({ personalFiles, nodesPage }) => { + const parentFolderName = `parent-pdf-${Utils.random()}`; + const destinationFolderName = `TO_PDF-${Utils.random()}`; + const files = generateUniqueFiles([TEST_FILES.DOCX, TEST_FILES.XLSX, TEST_FILES.PPTX_FILE]); + + const parentFolderId = await setupTransformationTest( + { personalFiles, nodesPage }, + { nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.AdobePDFDocument } + ); + + await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page }); + await verifyTransformation({ personalFiles }, { destinationFolderName, files, expectedExtension: 'pdf' }); + }); + + test('[XAT-8051] Supported types transformation to BMP', async ({ personalFiles, nodesPage }) => { + const parentFolderName = `parent-bmp-${Utils.random()}`; + const destinationFolderName = `TO_BMP-${Utils.random()}`; + const files = generateUniqueFiles([TEST_FILES.JPG_FILE, TEST_FILES.PNG_FILE, TEST_FILES.GIF_FILE, TEST_FILES.TIFF_FILE]); + + const parentFolderId = await setupTransformationTest( + { personalFiles, nodesPage }, + { nodesApi, testString, parentFolderName, destinationFolderName, mimeType: MimeType.BitmapImage } + ); + + await triggerTransformation({ fileActionApi, files, parentFolderId, page: personalFiles.page }); + 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' }); }); }); diff --git a/projects/aca-playwright-shared/src/models/index.ts b/projects/aca-playwright-shared/src/models/index.ts index b218c4376..5f69fd1fb 100644 --- a/projects/aca-playwright-shared/src/models/index.ts +++ b/projects/aca-playwright-shared/src/models/index.ts @@ -24,3 +24,4 @@ export * from './user-model'; export * from './custom-config'; +export * from './test-file.model'; diff --git a/projects/aca-playwright-shared/src/models/test-file.model.ts b/projects/aca-playwright-shared/src/models/test-file.model.ts new file mode 100644 index 000000000..7507e0a12 --- /dev/null +++ b/projects/aca-playwright-shared/src/models/test-file.model.ts @@ -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 . + */ + +export interface TestFileConfig { + path: string; + name: string; +} diff --git a/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts b/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts index 5f902f660..6fc8a8d69 100644 --- a/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts +++ b/projects/aca-playwright-shared/src/page-objects/components/actions-dropdown.component.ts @@ -51,7 +51,12 @@ export enum ActionType { } 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 { diff --git a/projects/aca-playwright-shared/src/resources/test-files/file-bmp.bmp b/projects/aca-playwright-shared/src/resources/test-files/file-bmp.bmp new file mode 100644 index 000000000..872e8465f Binary files /dev/null and b/projects/aca-playwright-shared/src/resources/test-files/file-bmp.bmp differ diff --git a/projects/aca-playwright-shared/src/resources/test-files/file-tif.tif b/projects/aca-playwright-shared/src/resources/test-files/file-tif.tif new file mode 100644 index 000000000..fe51399c5 Binary files /dev/null and b/projects/aca-playwright-shared/src/resources/test-files/file-tif.tif differ diff --git a/projects/aca-playwright-shared/src/resources/test-files/index.ts b/projects/aca-playwright-shared/src/resources/test-files/index.ts index cf933d6c3..e53507525 100644 --- a/projects/aca-playwright-shared/src/resources/test-files/index.ts +++ b/projects/aca-playwright-shared/src/resources/test-files/index.ts @@ -78,6 +78,14 @@ export const TEST_FILES = { path: resolve(__dirname, 'file-gif.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: { path: resolve(__dirname, 'file-pptx.pptx'), name: 'file-pptx'