Skip to content

Commit

Permalink
Issue 30682 automation phase1 (#31009)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Adding test to create pages

### Checklist
- [ ] Tests
- [ ] Documentation
  • Loading branch information
bryanboza authored Jan 2, 2025
1 parent c3b958a commit 21eadec
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 23 deletions.
8 changes: 7 additions & 1 deletion e2e/dotcms-e2e-node/frontend/locators/globalLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
export const iFramesLocators = {
main_iframe: 'iframe[name="detailFrame"]',
dot_iframe: 'dot-iframe-dialog iframe[name="detailFrame"]',
wysiwygFrame: 'iframe[title="Rich Text Area\\. Press ALT-F9 for menu\\. Press ALT-F10 for toolbar\\. Press ALT-0 for help"]'
wysiwygFrame: 'iframe[title="Rich Text Area\\. Press ALT-F9 for menu\\. Press ALT-F10 for toolbar\\. Press ALT-0 for help"]',
dataTestId: '[data-testid="iframe"]'
}

/**
Expand Down Expand Up @@ -38,6 +39,11 @@ export const fileAsset = {
label: "File Asset"
}

export const pageAsset = {
locator: "descriptionPage",
label: "Page"
}

export {
} from './navigation/menuLocators';

15 changes: 15 additions & 0 deletions e2e/dotcms-e2e-node/frontend/tests/contentSearch/contentData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Page} from "@playwright/test";

/**
* Content to add a Rich Text content
*/
Expand Down Expand Up @@ -29,3 +31,16 @@ export const fileAssetContent = {
host:"default"
}

export const pageAssetContent = {
title: "PageAsset1",
host: "default",
template: "System Template",
friendlyName: "friendlyName-test",
showOnMenu: true,
sortOrder: "1",
cacheTTL: 0,
}




Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import {expect, Page, test} from '@playwright/test';
import {expect, test} from '@playwright/test';
import {dotCMSUtils, waitForVisibleAndCallback} from '../../utils/dotCMSUtils';
import {
GroupEntriesLocators,
MenuEntriesLocators,
ToolEntriesLocators
} from '../../locators/navigation/menuLocators';
import {ContentUtils} from "../../utils/contentUtils";
import {iFramesLocators, contentGeneric, fileAsset} from "../../locators/globalLocators";
import {genericContent1, contentProperties, fileAssetContent} from "./contentData";
import {iFramesLocators, contentGeneric, fileAsset, pageAsset} from "../../locators/globalLocators";
import {genericContent1, contentProperties, fileAssetContent, pageAssetContent} from "./contentData";
import {assert} from "console";

const cmsUtils = new dotCMSUtils();

/**
* Test to navigate to the content portlet and login to the dotCMS instance
* @param page
*/
test.beforeEach('Navigate to content portlet', async ({page}) => {
// Instance the menu Navigation locators
const cmsUtils = new dotCMSUtils();
const menuLocators = new MenuEntriesLocators(page);
const groupsLocators = new GroupEntriesLocators(page);
const toolsLocators = new ToolEntriesLocators(page);
Expand Down Expand Up @@ -82,7 +81,7 @@ test('Delete a generic of content', async ({ page }) => {
* */
test('Validate required on text fields', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe).first();
const iframe = page.frameLocator(iFramesLocators.dot_iframe);

await contentUtils.addNewContentAction(page, contentGeneric.locator, contentGeneric.label);
await contentUtils.fillRichTextForm(page, '', genericContent1.body, contentProperties.publishWfAction);
Expand Down Expand Up @@ -110,7 +109,6 @@ test('Validate required on blockContent fields', async ({page}) => {
*/
test('Validate you are able to add file assets importing from url', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe);

await contentUtils.addNewContentAction(page, fileAsset.locator, fileAsset.label);
const params = {
Expand All @@ -130,7 +128,6 @@ test('Validate you are able to add file assets importing from url', async ({page
*/
test('Validate you are able to add file assets creating a new file', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe);

await contentUtils.addNewContentAction(page, fileAsset.locator, fileAsset.label);
const params = {
Expand Down Expand Up @@ -216,7 +213,7 @@ test('Validate the auto complete on FileName field rejecting change', async ({pa
* Test to validate the title is not changing in the auto complete on FileName
*/
/** ENABLE AS SOON WE FIXED THE ISSUE #30945
test('Validate the title field is not chaging in the file asset auto complete', async ({page}) => {
test('Validate the title field is not changing in the file asset auto complete', async ({page}) => {
const detailsFrame = page.frameLocator(iFramesLocators.dot_iframe);
const contentUtils = new ContentUtils(page);
Expand All @@ -237,6 +234,77 @@ test('Delete a file asset content', async ({ page }) => {
await contentUtils.deleteContent(page, fileAssetContent.title);
});

/**
* Test to validate you are able to add new pages
*/
test('Add a new page', async ({page}) => {
const contentUtils = new ContentUtils(page);
const iframe = page.frameLocator(iFramesLocators.main_iframe);

await contentUtils.addNewContentAction(page, pageAsset.locator, pageAsset.label);
const params = {
page: page,
title: pageAssetContent.title,
host: pageAssetContent.host,
template: pageAssetContent.template,
friendlyName: pageAssetContent.friendlyName,
showOnMenu: pageAssetContent.showOnMenu,
sortOrder: pageAssetContent.sortOrder,
cacheTTL: pageAssetContent.cacheTTL,
action: contentProperties.publishWfAction,
}
await contentUtils.fillPageAssetForm(params);
const dataFrame = page.frameLocator(iFramesLocators.dataTestId);
await waitForVisibleAndCallback(dataFrame.getByRole('banner'), async () => {});
await expect(page.locator('ol')).toContainText('Pages'+ pageAssetContent.title);
});

/**
* Test to validate the required fields on the page form
*/
test('Validate required fields on page asset', async ({page}) => {
const contentUtils = new ContentUtils(page);
const detailFrame = page.frameLocator(iFramesLocators.dot_iframe);

await contentUtils.addNewContentAction(page, pageAsset.locator, pageAsset.label);
const params = {
page: page,
title: "",
host: pageAssetContent.host,
template: pageAssetContent.template,
showOnMenu: pageAssetContent.showOnMenu,
action: contentProperties.publishWfAction
}
await contentUtils.fillPageAssetForm(params);
await waitForVisibleAndCallback(detailFrame.getByText('Error x'), async () => {});

await expect(detailFrame.getByText('The field Title is required.')).toBeVisible();
await expect(detailFrame.getByText('The field Url is required.')).toBeVisible();
await expect(detailFrame.getByText('The field Friendly Name is')).toBeVisible();
});

/**
* Test to validate the auto generation of fields on page asset
*/
test('Validate auto generation of fields on page asset', async ({page}) => {
const contentUtils = new ContentUtils(page);
const detailFrame = page.frameLocator(iFramesLocators.dot_iframe);

await contentUtils.addNewContentAction(page, pageAsset.locator, pageAsset.label);
const params = {
page: page,
title: pageAssetContent.title,
host: pageAssetContent.host,
template: pageAssetContent.template,
showOnMenu: pageAssetContent.showOnMenu,
}
await contentUtils.fillPageAssetForm(params);

await expect(detailFrame.locator('#url')).toHaveValue(pageAssetContent.title.toLowerCase());
await expect(detailFrame.locator('#friendlyName')).toHaveValue(pageAssetContent.title);
});





69 changes: 56 additions & 13 deletions e2e/dotcms-e2e-node/frontend/utils/contentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect, FrameLocator, Locator, Page} from '@playwright/test';
import {contentGeneric, iFramesLocators, fileAsset } from '../locators/globalLocators';
import {contentGeneric, iFramesLocators, fileAsset, pageAsset} from '../locators/globalLocators';
import {waitForVisibleAndCallback} from './dotCMSUtils';
import {contentProperties} from "../tests/contentSearch/contentData";

Expand Down Expand Up @@ -36,17 +36,10 @@ export class ContentUtils {

/**
* Fill the file asset form
* @param page
* @param host
* @param title
* @param action
* @param fileName
* @param fromURL
* @param newFileName
* @param newFileText
* @param params
*/
async fillFileAssetForm(params: FileAssetFormParams) {
const { page, host, title, action, fileName, fromURL, newFileName, newFileText } = params;
const { page, host, title, action, fromURL, newFileName, newFileText } = params;
const dotIframe = page.frameLocator(iFramesLocators.dot_iframe);

await waitForVisibleAndCallback(page.getByRole('heading'), () =>
Expand Down Expand Up @@ -79,6 +72,7 @@ export class ContentUtils {
/**
* Validate the workflow execution and close the modal
* @param page
* @param message
*/
async workflowExecutionValidationAndClose(page: Page, message: string) {
const dotIframe = page.frameLocator(iFramesLocators.dot_iframe);
Expand Down Expand Up @@ -114,7 +108,6 @@ export class ContentUtils {
* Select content type on filter on the content portlet
* @param page
* @param typeLocator
* @param typeString
*/
async selectTypeOnFilter(page: Page, typeLocator: string) {
const iframe = page.frameLocator(iFramesLocators.main_iframe);
Expand Down Expand Up @@ -144,7 +137,7 @@ export class ContentUtils {
/**
* Validate if the content exists in the results table on the content portlet
* @param page
* @param title
* @param text
*/
async validateContentExist(page: Page, text: string) {
const iframe = page.frameLocator(iFramesLocators.main_iframe);
Expand Down Expand Up @@ -267,8 +260,9 @@ export class ContentUtils {
}

/**
* Get the content state from the results table on the content portle
* Get the content state from the results table on the content portlet
* @param page
* @param title
*/
async getContentState(page: Page, title: string): Promise<string | null> {
const iframe = page.frameLocator(iFramesLocators.main_iframe);
Expand All @@ -293,8 +287,42 @@ export class ContentUtils {
}


/**
* Fill the pageAsset form
* @param params
*/
async fillPageAssetForm(params: PageAssetFormParams) {
const { page, title, action, url, host, template, friendlyName, showOnMenu, sortOrder, cacheTTL } = params;
const dotIframe = page.frameLocator(iFramesLocators.dot_iframe);

await waitForVisibleAndCallback(page.getByRole('heading'), () =>
expect.soft(page.getByRole('heading')).toContainText(pageAsset.label)
);
await dotIframe.locator('#titleBox').fill(title);

if (url) await dotIframe.locator('#url').fill(url);
if (host) {
await dotIframe.locator('#hostFolder_field div').nth(2).click();
await dotIframe.getByRole('treeitem', { name: host }).click();
}
if (template) {
await dotIframe.locator('#widget_templateSel div').first().click();
await dotIframe.getByText(template).click();
}
if (friendlyName) await dotIframe.locator('#friendlyName').fill(friendlyName);
if (showOnMenu) await dotIframe.getByLabel('Content', { exact: true }).getByLabel('').check();
if (sortOrder) await dotIframe.locator('#sortOrder').fill(sortOrder);
if (cacheTTL) await dotIframe.locator('#cachettlbox').fill(cacheTTL.toString());
if (action) await dotIframe.getByText(action).first().click();
}


}


/**
* Parameters for the fillFileAssetForm method
*/
interface FileAssetFormParams {
page: Page;
host: string;
Expand All @@ -306,6 +334,21 @@ interface FileAssetFormParams {
newFileText?: string;
}

/**
* Parameters for the fillPageAssetForm method
*/
interface PageAssetFormParams {
page: Page;
title: string;
url?: string;
host?: string;
action?: string;
template?: string;
friendlyName?: string;
showOnMenu?: boolean;
sortOrder?: string;
cacheTTL?: number
}



Expand Down

0 comments on commit 21eadec

Please sign in to comment.