Skip to content

Commit

Permalink
LPD-39283 Migrates NavigateToLockedPagesInList and SearchLockedPagesI…
Browse files Browse the repository at this point in the history
…nLockedPagesAdmin test to playwright
  • Loading branch information
ealonso authored and brianchandotcom committed Oct 15, 2024
1 parent d13c92f commit 8f7b1c3
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* 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 {expect, mergeTests} from '@playwright/test';

import {apiHelpersTest} from '../../fixtures/apiHelpersTest';
import {featureFlagsTest} from '../../fixtures/featureFlagsTest';
import {isolatedSiteTest} from '../../fixtures/isolatedSiteTest';
import {loginTest} from '../../fixtures/loginTest';
import {pageEditorPagesTest} from '../../fixtures/pageEditorPagesTest';
import fillAndClickOutside from '../../utils/fillAndClickOutside';
import getRandomString from '../../utils/getRandomString';
import {PORTLET_URLS} from '../../utils/portletUrls';

export const test = mergeTests(
apiHelpersTest,
isolatedSiteTest,
featureFlagsTest({
'LPS-178052': true,
}),
pageEditorPagesTest,
loginTest()
);

test(
'User can search locked pages',
{
tag: ['@LPS-182024', '@LPS-194499'],
},
async ({apiHelpers, context, pageEditorPage, site}) => {

// Create a content page and navigate to view mode

const layoutTitle = getRandomString();

const layout = await apiHelpers.headlessDelivery.createSitePage({
siteId: site.id,
title: layoutTitle,
});

await pageEditorPage.goto(layout, site.friendlyUrlPath);

// Add new fragment to content page to lock the content page

await pageEditorPage.addFragment('Basic Components', 'Heading');

// Navigate to locked pages in a new page

const newPage = await context.newPage();

await newPage.goto(
`/group${site.friendlyUrlPath}${PORTLET_URLS.lockedPages}`
);

// Assert locked page name is a link and it opens in a new window

await expect(
newPage.getByLabel(layoutTitle, {exact: true})
).toHaveAttribute('target', '_blank');

// Assert search

await fillAndClickOutside(
newPage,
newPage.getByPlaceholder('Search for'),
'Welcome'
);

const searchButton = newPage.getByRole('button', {name: 'Search'});

await searchButton.click();

await expect(
newPage.getByText('No locked pages were found.', {exact: true})
).toBeVisible();

await newPage.getByRole('button', {name: 'Clear'}).click();

await expect(
newPage.getByLabel(layoutTitle, {exact: true})
).toBeVisible();
}
);
2 changes: 2 additions & 0 deletions modules/test/playwright/utils/portletUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const PORTLET_URLS = {
'/~/control_panel/manage?p_p_id=com_liferay_portal_language_override_web_internal_portlet_PLOPortlet',
lockedItems:
'/~/control_panel/manage?p_p_id=com_liferay_locked_items_web_internal_portlet_LockedItemsPortlet',
lockedPages:
'/~/control_panel/manage?p_p_id=com_liferay_layout_locked_layouts_web_internal_portlet_LockedLayoutsPortlet',
masterPages:
'/~/control_panel/manage?p_p_id=com_liferay_layout_page_template_admin_web_portlet_LayoutPageTemplatesPortlet&_com_liferay_layout_page_template_admin_web_portlet_LayoutPageTemplatesPortlet_tabs1=master-layouts',
messageBoardsAdmin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,123 +109,4 @@ definition {
}
}

@description = "This is a test for LPS-194499. In the list of locked pages, the name of the content page and collection page are clickable and the link opens the pages in a new tab."
@priority = 5
test NavigateToLockedPagesInList {
var siteName = selenium.getText("Home#SITE_NAME");
var baseURL = PropsUtil.get("portal.url");

task ("Given a locked content page and locked collection page") {
JSONLayout.addPublicLayout(
groupName = "Test Site Name",
layoutName = "Test Page Name",
type = "content");

ContentPagesNavigator.openEditContentPage(
pageName = "Test Page Name",
siteName = "Test Site Name");

PageEditor.addFragment(
collectionName = "Basic Components",
fragmentName = "Button");

Open.openInTheNewTab(value1 = "${baseURL}/web/test-site-name");

PagesAdmin.openPagesAdmin(siteURLKey = "test-site-name");

ContentPages.addCollectionPage(
collectionName = "Recent Content",
pageName = "Collection Page Name",
tabName = "Collection Providers");

PageEditor.addFragment(
collectionName = "Basic Components",
dropTarget = "Header",
fragmentName = "Button",
targetFragmentName = "Container");
}

task ("When navigating to the Locked Pages admin page") {
Open.openInTheNewTab(value1 = "${baseURL}/web/test-site-name");

ProductMenu.gotoPortlet(
category = "Configuration",
portlet = "Locked Pages");
}

task ("Then in the list of locked page names are clickable and the link opens the pages in a new tab") {
for (var pageName : list "Test Page Name,Collection Page Name") {
LexiconTable.clickTableEntryColumnLink(
columnName = "name",
tableEntry = ${pageName});

SelectWindow(value1 = "title=${pageName} - Test Site Name - ${siteName}");

ControlMenu.viewHeaderDraftTitle(headerTitle = ${pageName});

Close.closeAndSelectWindow(value1 = "title=Locked Pages - Test Site Name - ${siteName}");
}
}
}

@description = "This is a test for LPS-182024. The administrator could search locked pages in Locked Pages admin."
@priority = 4
test SearchLockedPagesInLockedPagesAdmin {
var baseURL = PropsUtil.get("portal.url");
var siteName = selenium.getText("Home#SITE_NAME");

task ("Given two locked pages") {
for (var pageName : list "Welcome,Blog") {
JSONLayout.addPublicLayout(
groupName = "Test Site Name",
layoutName = ${pageName},
type = "content");
}

ContentPagesNavigator.openEditContentPage(
pageName = "Welcome",
siteName = "Test Site Name");

PageEditor.addFragment(
collectionName = "Basic Components",
fragmentName = "Button");

Open.openInTheNewTab(value1 = "${baseURL}/web/test-site-name");

ContentPagesNavigator.openEditContentPage(
pageName = "Blog",
siteName = "Test Site Name");

PageEditor.addFragment(
collectionName = "Basic Components",
fragmentName = "Heading");
}

task ("When navigating to locked pages admin in a new tab") {
Open.openInTheNewTab(value1 = "${baseURL}/web/test-site-name");

ProductMenu.gotoPortlet(
category = "Configuration",
portlet = "Locked Pages");

for (var pageName : list "Welcome,Blog") {
LexiconTable.viewTableEntryTitle(tableEntry = ${pageName});
}
}

task ("Then it is possible to search for locked pages by name or user created") {
Search.searchCP(searchTerm = "Welcome");

LexiconTable.viewTableEntryTitle(tableEntry = "Welcome");

LexiconTable.viewTableEntryNotPresent(tableEntry = "Blog");

Search.searchCP(searchTerm = "Test Test");

for (var pageName : list "Welcome,Blog") {
LexiconTable.viewTableEntryTitle(tableEntry = ${pageName});
}
}
}

}

0 comments on commit 8f7b1c3

Please sign in to comment.