mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
ACS-9871: Add transformation rule tests and supporting methods (#4921)
https://hyland.atlassian.net/browse/ACS-9871 This pull request introduces a new end-to-end test for folder rules that transform supported file types to PDF, and enhances the shared Playwright testing utilities to support MIME type selection and destination folder specification for transformation actions. The changes primarily add test coverage for the "Transform and Copy Content" rule and extend the reusable test components to support these scenarios. Enhancements to Playwright shared utilities: Added a new MimeType enum to actions-dropdown.component.ts to standardize MIME type selection for transformation actions. Introduced the selectMimeType method in ActionsDropdownComponent for selecting a target MIME type (e.g., PDF) in rule configuration. Added the selectDestinationFolderTransformAndCopyContent method in ActionsDropdownComponent to automate picking a destination folder for transformed files. Declared new locators in ActionsDropdownComponent to support MIME type dropdown and destination folder selection. New end-to-end test: Created transform-rules.e2e.ts to verify that DOCX, XLSX, and PPTX files are correctly transformed to PDF and copied to the specified folder when a folder rule is configured.
This commit is contained in:
+66
@@ -24,6 +24,7 @@
|
||||
|
||||
import { Locator, Page } from '@playwright/test';
|
||||
import { BaseComponent } from './base.component';
|
||||
import { timeouts } from '../../public-api';
|
||||
|
||||
export enum ActionType {
|
||||
AddAspect = 'Add aspect',
|
||||
@@ -49,6 +50,10 @@ export enum ActionType {
|
||||
TransformAndCopyImage = 'Transform and copy image'
|
||||
}
|
||||
|
||||
export enum MimeType {
|
||||
AdobePDFDocument = 'Adobe PDF Document [application/pdf]'
|
||||
}
|
||||
|
||||
export class ActionsDropdownComponent extends BaseComponent {
|
||||
private static rootElement = 'aca-edit-rule-dialog aca-rule-action-list';
|
||||
|
||||
@@ -67,6 +72,9 @@ export class ActionsDropdownComponent extends BaseComponent {
|
||||
private actionSimpleWorkflowLabelApproveLocator = `[data-automation-id="card-boolean-label-approve-move"]`;
|
||||
private actionSimpleWorkflowSRejectStepLocator = '[data-automation-id="header-reject-step"] input';
|
||||
private actionSimpleWorkflowRejectFolderLocator = `[data-automation-id="header-reject-folder"] input`;
|
||||
private readonly mimeTypeDropdownLocator = this.getChild('[data-automation-class="select-box"][aria-label="Mimetype *"]');
|
||||
private readonly actionTransformAndCopyContentDestinationFolderLocator = '[data-automation-id="card-textitem-value-destination-folder"]';
|
||||
private readonly contentNodeSelectorSearchInput = '[data-automation-id="content-node-selector-search-input"]';
|
||||
|
||||
constructor(page: Page) {
|
||||
super(page, ActionsDropdownComponent.rootElement);
|
||||
@@ -112,4 +120,62 @@ export class ActionsDropdownComponent extends BaseComponent {
|
||||
await this.ruleActionLocator.nth(index).locator(this.actionSimpleWorkflowRejectFolderLocator).click();
|
||||
await this.page.locator(this.actionSimpleWorkflowActionChoiceLocator).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a MIME type from the dropdown for content transformation actions.
|
||||
* This method is typically used when configuring folder rules with transform actions
|
||||
* (e.g., Transform and Copy Content) to specify the target format for file conversion.
|
||||
*
|
||||
* @param mimeType - The MIME type to select (e.g., MimeType.AdobePDFDocument for PDF conversion)
|
||||
* @param index - The zero-based index of the action dropdown (use 0 for the first action, 1 for the second, etc.)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Select PDF as the target format for the first transform action
|
||||
* await actionsDropdown.selectMimeType(MimeType.AdobePDFDocument, 0);
|
||||
* ```
|
||||
*/
|
||||
async selectMimeType(mimeType: Partial<MimeType>, index: number): Promise<void> {
|
||||
await this.mimeTypeDropdownLocator.nth(index).hover({ timeout: timeouts.short });
|
||||
await this.mimeTypeDropdownLocator.nth(index).click();
|
||||
const option = this.getOptionLocator(mimeType);
|
||||
await option.click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a destination folder for the Transform and Copy Content action.
|
||||
* This method opens the folder picker dialog, searches for a folder by name,
|
||||
* and selects it as the destination where transformed files will be copied.
|
||||
*
|
||||
* The method performs the following steps:
|
||||
* 1. Clicks the destination folder field to open the content node selector dialog
|
||||
* 2. Fills the search input with the provided search term
|
||||
* 3. Waits for search results to load
|
||||
* 4. Clicks on the first matching folder from the results
|
||||
* 5. Confirms the selection by clicking the Choose button
|
||||
*
|
||||
* @param index - The zero-based index of the action dropdown (use 0 for the first action, 1 for the second, etc.)
|
||||
* @param searchTerm - The name or partial name of the destination folder to search for (e.g., 'TO_PDF')
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Select 'TO_PDF' folder as the destination for transformed files
|
||||
* await actionsDropdown.selectDestinationFolderTransformAndCopyContent(0, 'TO_PDF');
|
||||
* ```
|
||||
*/
|
||||
async selectDestinationFolderTransformAndCopyContent(index: number, searchTerm: string): Promise<void> {
|
||||
// Click on the destination folder input field to open the folder picker dialog
|
||||
await this.ruleActionLocator.nth(index).locator(this.actionTransformAndCopyContentDestinationFolderLocator).click();
|
||||
|
||||
// Locate and fill the search input field within the content node selector
|
||||
const searchInput = this.page.locator(this.contentNodeSelectorSearchInput);
|
||||
await searchInput.fill(searchTerm);
|
||||
|
||||
// Click on the folder from the search results (first match if multiple)
|
||||
const folderRow = this.page.locator('.adf-datatable-body .adf-name-location-cell-name', { hasText: searchTerm }).first();
|
||||
await folderRow.click();
|
||||
|
||||
// Click the Choose button to confirm selection
|
||||
await this.page.locator(this.actionSimpleWorkflowActionChoiceLocator).click();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user