Skip to content

Commit

Permalink
LPD-23390 SF
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-oliveira446 authored and brianchandotcom committed May 2, 2024
1 parent 4d1c84d commit e41255a
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ const editObjectDefinitionPagesTest = test.extend<{
},
});

export {editObjectDefinitionPagesTest};
export {editObjectDefinitionPagesTest};
11 changes: 5 additions & 6 deletions modules/test/playwright/helpers/NotificationApiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -66,11 +66,10 @@ export class NotificationApiHelper {

async postRandomNotificationTemplate(
name?: string
) : Promise<TNotificationTemplate> {

): Promise<TNotificationTemplate> {
const requestBody = {
editorType: 'richText',
name: name,
name,
recipientType: 'email',
recipients: [
{
Expand All @@ -79,12 +78,12 @@ export class NotificationApiHelper {
en_US: '[email protected]',
},
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
134 changes: 77 additions & 57 deletions modules/test/playwright/tests/object-web/objectActions.spec.ts
Original file line number Diff line number Diff line change
@@ -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]);
}
});
});
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]
);
}
});
});

0 comments on commit e41255a

Please sign in to comment.