From 8f7b1c33c9511690d41d03773303c45c1be2979b Mon Sep 17 00:00:00 2001 From: Eudaldo Alonso Date: Mon, 14 Oct 2024 16:25:50 +0200 Subject: [PATCH] LPD-39283 Migrates NavigateToLockedPagesInList and SearchLockedPagesInLockedPagesAdmin test to playwright --- .../lockedPages.spec.ts | 85 +++++++++++++ modules/test/playwright/utils/portletUrls.ts | 2 + .../layout/lockedpages/LockedPages.testcase | 119 ------------------ 3 files changed, 87 insertions(+), 119 deletions(-) create mode 100644 modules/test/playwright/tests/layout-locked-layouts-web/lockedPages.spec.ts diff --git a/modules/test/playwright/tests/layout-locked-layouts-web/lockedPages.spec.ts b/modules/test/playwright/tests/layout-locked-layouts-web/lockedPages.spec.ts new file mode 100644 index 00000000000000..edd0a1e0d1dcfe --- /dev/null +++ b/modules/test/playwright/tests/layout-locked-layouts-web/lockedPages.spec.ts @@ -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(); + } +); diff --git a/modules/test/playwright/utils/portletUrls.ts b/modules/test/playwright/utils/portletUrls.ts index 92be19098c3f0c..3de9accff5ed11 100644 --- a/modules/test/playwright/utils/portletUrls.ts +++ b/modules/test/playwright/utils/portletUrls.ts @@ -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: diff --git a/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/lockedpages/LockedPages.testcase b/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/lockedpages/LockedPages.testcase index 9953ae5c691d9c..33852711699e7c 100644 --- a/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/lockedpages/LockedPages.testcase +++ b/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/lockedpages/LockedPages.testcase @@ -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}); - } - } - } - } \ No newline at end of file