diff --git a/modules/test/playwright/fixtures/editObjectDefinitionPagesTest.ts b/modules/test/playwright/fixtures/editObjectDefinitionPagesTest.ts index c90ef8430b517f..fd2f616bc4717f 100644 --- a/modules/test/playwright/fixtures/editObjectDefinitionPagesTest.ts +++ b/modules/test/playwright/fixtures/editObjectDefinitionPagesTest.ts @@ -30,4 +30,4 @@ const editObjectDefinitionPagesTest = test.extend<{ }, }); -export {editObjectDefinitionPagesTest}; \ No newline at end of file +export {editObjectDefinitionPagesTest}; diff --git a/modules/test/playwright/helpers/NotificationApiHelper.ts b/modules/test/playwright/helpers/NotificationApiHelper.ts index 4880fa0a1eb9d0..6e2d6d782c55bf 100644 --- a/modules/test/playwright/helpers/NotificationApiHelper.ts +++ b/modules/test/playwright/helpers/NotificationApiHelper.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 */ -import { getRandomInt } from '../utils/getRandomInt'; +import {getRandomInt} from '../utils/getRandomInt'; import {ApiHelpers} from './ApiHelpers'; type TNotificationTemplate = { @@ -66,11 +66,10 @@ export class NotificationApiHelper { async postRandomNotificationTemplate( name?: string - ) : Promise { - + ): Promise { const requestBody = { editorType: 'richText', - name: name, + name, recipientType: 'email', recipients: [ { @@ -79,12 +78,12 @@ export class NotificationApiHelper { en_US: 'do-not-replay@liferay.com', }, to: { - en_US: 'to' + getRandomInt()+"@liferay.com", + en_US: 'to' + getRandomInt() + '@liferay.com', }, }, ], subject: { - en_US: 'subject' + getRandomInt() + en_US: 'subject' + getRandomInt(), }, type: 'email', } as TNotificationTemplate; diff --git a/modules/test/playwright/pages/object-web/EditObjectDefinitionPage.ts b/modules/test/playwright/pages/object-web/EditObjectDefinitionPage.ts index 3825108fe07d1e..c6b9acbd785ae5 100644 --- a/modules/test/playwright/pages/object-web/EditObjectDefinitionPage.ts +++ b/modules/test/playwright/pages/object-web/EditObjectDefinitionPage.ts @@ -1,13 +1,18 @@ -import { Locator, Page } from "@playwright/test"; +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +import {Locator, Page} from '@playwright/test'; export class EditObjectDefinitionPage { - readonly actionsTab: Locator; + readonly actionsTab: Locator; - constructor(page: Page) { - this.actionsTab = page.getByRole('link', { name: 'Actions' }); - } + constructor(page: Page) { + this.actionsTab = page.getByRole('link', {name: 'Actions'}); + } - async openActionsTab() { + async openActionsTab() { await this.actionsTab.click(); } -} \ No newline at end of file +} diff --git a/modules/test/playwright/pages/object-web/ViewObjectDefinitionsPage.ts b/modules/test/playwright/pages/object-web/ViewObjectDefinitionsPage.ts index 64dfacd14ff108..af80fe4b16ea28 100644 --- a/modules/test/playwright/pages/object-web/ViewObjectDefinitionsPage.ts +++ b/modules/test/playwright/pages/object-web/ViewObjectDefinitionsPage.ts @@ -72,9 +72,9 @@ export class ViewObjectDefinitionsPage { } async clickEditObjectDefinitionLink(objectDefinitionName: string) { - await this.page.getByRole('link', { name: objectDefinitionName }).click(); + await this.page.getByRole('link', {name: objectDefinitionName}).click(); } - + async createObjectFolder(objectFolderLabel: string) { await this.addObjectFolderButton.click(); await this.objectFolderLabelInput.click(); diff --git a/modules/test/playwright/pages/object-web/object-action/ActionBuilderPage.ts b/modules/test/playwright/pages/object-web/object-action/ActionBuilderPage.ts index 4b084c11c2ea67..4f841f2ffee892 100644 --- a/modules/test/playwright/pages/object-web/object-action/ActionBuilderPage.ts +++ b/modules/test/playwright/pages/object-web/object-action/ActionBuilderPage.ts @@ -1,22 +1,35 @@ -import { Locator, Page } from "@playwright/test"; +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +import {Locator, Page} from '@playwright/test'; export class ActionBuilderPage { - readonly inputNotificationsCombo: Locator; - readonly inputThenCombo: Locator; - readonly optionNotification: Locator; + readonly inputNotificationsCombo: Locator; + readonly inputThenCombo: Locator; + readonly optionNotification: Locator; - constructor(page: Page) { - this.inputNotificationsCombo = page.frameLocator('iframe').getByRole('combobox').getByText('Select an Option') - this.inputThenCombo = page.frameLocator('iframe').getByRole('combobox').getByText('Choose an Action'); - this.optionNotification = page.frameLocator('iframe').getByRole('option', { name: 'Notification' }); - } + constructor(page: Page) { + this.inputNotificationsCombo = page + .frameLocator('iframe') + .getByRole('combobox') + .getByText('Select an Option'); + this.inputThenCombo = page + .frameLocator('iframe') + .getByRole('combobox') + .getByText('Choose an Action'); + this.optionNotification = page + .frameLocator('iframe') + .getByRole('option', {name: 'Notification'}); + } - async chooseNotificationOption() { + async chooseNotificationOption() { await this.inputThenCombo.click(); - await this.optionNotification.click(); + await this.optionNotification.click(); } - - async clickInputNotificationsCombo() { + + async clickInputNotificationsCombo() { await this.inputNotificationsCombo.click(); } -} \ No newline at end of file +} diff --git a/modules/test/playwright/pages/object-web/object-action/SidePanelObjectActionPage.ts b/modules/test/playwright/pages/object-web/object-action/SidePanelObjectActionPage.ts index def4af4d598c58..5b18e0ba55d4b0 100644 --- a/modules/test/playwright/pages/object-web/object-action/SidePanelObjectActionPage.ts +++ b/modules/test/playwright/pages/object-web/object-action/SidePanelObjectActionPage.ts @@ -1,13 +1,20 @@ -import { Locator, Page } from "@playwright/test"; +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +import {Locator, Page} from '@playwright/test'; export class SidePanelObjectActionPage { - readonly actionBuilderTab: Locator; + readonly actionBuilderTab: Locator; - constructor(page: Page) { - this.actionBuilderTab = page.frameLocator('iframe').getByRole('tab', { name: 'Action Builder' }); - } + constructor(page: Page) { + this.actionBuilderTab = page + .frameLocator('iframe') + .getByRole('tab', {name: 'Action Builder'}); + } - async openActionBuilderTab() { + async openActionBuilderTab() { await this.actionBuilderTab.click(); } -} \ No newline at end of file +} diff --git a/modules/test/playwright/pages/object-web/object-action/ViewObjectActionsPage.ts b/modules/test/playwright/pages/object-web/object-action/ViewObjectActionsPage.ts index d1c4b7ba4511c1..d0c08b45a9283e 100644 --- a/modules/test/playwright/pages/object-web/object-action/ViewObjectActionsPage.ts +++ b/modules/test/playwright/pages/object-web/object-action/ViewObjectActionsPage.ts @@ -1,13 +1,18 @@ -import { Locator, Page } from "@playwright/test"; +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ + +import {Locator, Page} from '@playwright/test'; export class ViewObjectActionsPage { - readonly addObjectActionButton: Locator; + readonly addObjectActionButton: Locator; - constructor(page: Page) { - this.addObjectActionButton = page.getByLabel('Add Object Action'); - } + constructor(page: Page) { + this.addObjectActionButton = page.getByLabel('Add Object Action'); + } - async openObjectActionSidePanel() { + async openObjectActionSidePanel() { await this.addObjectActionButton.click(); } -} \ No newline at end of file +} diff --git a/modules/test/playwright/tests/object-web/objectActions.spec.ts b/modules/test/playwright/tests/object-web/objectActions.spec.ts index f5bdeb26f4bae1..3820bb9e517167 100644 --- a/modules/test/playwright/tests/object-web/objectActions.spec.ts +++ b/modules/test/playwright/tests/object-web/objectActions.spec.ts @@ -1,64 +1,84 @@ -import { expect, mergeTests } from "@playwright/test"; -import { apiHelpersTest } from "../../fixtures/apiHelpersTest"; -import { loginTest } from "../../fixtures/loginTest"; -import { objectPagesTest } from "../../fixtures/objectPagesTest"; -import { getRandomInt } from "../../utils/getRandomInt"; -import { editObjectDefinitionPagesTest } from "../../fixtures/editObjectDefinitionPagesTest"; +/** + * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com + * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 + */ -export const test = mergeTests(apiHelpersTest, editObjectDefinitionPagesTest,loginTest(), objectPagesTest); +import {expect, mergeTests} from '@playwright/test'; + +import {apiHelpersTest} from '../../fixtures/apiHelpersTest'; +import {editObjectDefinitionPagesTest} from '../../fixtures/editObjectDefinitionPagesTest'; +import {loginTest} from '../../fixtures/loginTest'; +import {objectPagesTest} from '../../fixtures/objectPagesTest'; +import {getRandomInt} from '../../utils/getRandomInt'; + +export const test = mergeTests( + apiHelpersTest, + editObjectDefinitionPagesTest, + loginTest(), + objectPagesTest +); test.describe('manage object actions through object actions tab', () => { test('notification action section must display all persisted notifications', async ({ actionBuilderPage, - apiHelpers, - editObjectDefinitionPage, - page, - sidePanelObjectActionPage, - viewObjectActionsPage, + apiHelpers, + editObjectDefinitionPage, + page, + sidePanelObjectActionPage, + viewObjectActionsPage, viewObjectDefinitionsPage, }) => { - const ids: number[] = []; - const names: string[] = []; - - for(let index=1;index <= 21;index++){ - const notificationTemplate = await apiHelpers.notification.postRandomNotificationTemplate( - "notification template test " + getRandomInt() - ) - ids.push(notificationTemplate.id) - names.push(notificationTemplate.name + " " + notificationTemplate.type) - } - - const objectDefinition = - await apiHelpers.objectAdmin.postRandomObjectDefinition( - 'default' - ); - - await viewObjectDefinitionsPage.goto() - - await viewObjectDefinitionsPage.clickEditObjectDefinitionLink(objectDefinition.name); - - await editObjectDefinitionPage.openActionsTab(); - - await viewObjectActionsPage.openObjectActionSidePanel(); - - await sidePanelObjectActionPage.openActionBuilderTab(); - - await actionBuilderPage.chooseNotificationOption(); - - await actionBuilderPage.clickInputNotificationsCombo(); - - for (let index = 0; index < names.length; index++) { - await expect( - page.frameLocator('iframe').getByRole('option', { name: names[index] }) - ).toBeVisible(); - } - - // Clean up - - await apiHelpers.objectAdmin.deleteObjectDefinition(objectDefinition.id); - - for (let index = 0; index < ids.length; index++) { - await apiHelpers.notification.deleteNotificationTemplate(ids[index]); - } - }); -}); \ No newline at end of file + const ids: number[] = []; + const names: string[] = []; + + for (let index = 1; index <= 21; index++) { + const notificationTemplate = + await apiHelpers.notification.postRandomNotificationTemplate( + 'notification template test ' + getRandomInt() + ); + ids.push(notificationTemplate.id); + names.push( + notificationTemplate.name + ' ' + notificationTemplate.type + ); + } + + const objectDefinition = + await apiHelpers.objectAdmin.postRandomObjectDefinition('default'); + + await viewObjectDefinitionsPage.goto(); + + await viewObjectDefinitionsPage.clickEditObjectDefinitionLink( + objectDefinition.name + ); + + await editObjectDefinitionPage.openActionsTab(); + + await viewObjectActionsPage.openObjectActionSidePanel(); + + await sidePanelObjectActionPage.openActionBuilderTab(); + + await actionBuilderPage.chooseNotificationOption(); + + await actionBuilderPage.clickInputNotificationsCombo(); + + for (let index = 0; index < names.length; index++) { + await expect( + page + .frameLocator('iframe') + .getByRole('option', {name: names[index]}) + ).toBeVisible(); + } + + // Clean up + + await apiHelpers.objectAdmin.deleteObjectDefinition( + objectDefinition.id + ); + + for (let index = 0; index < ids.length; index++) { + await apiHelpers.notification.deleteNotificationTemplate( + ids[index] + ); + } + }); +});