diff --git a/modules/apps/layout/layout-admin-web-test/src/testIntegration/java/com/liferay/layout/admin/web/internal/exportimport/data/handler/test/LayoutStagedModelDataHandlerTest.java b/modules/apps/layout/layout-admin-web-test/src/testIntegration/java/com/liferay/layout/admin/web/internal/exportimport/data/handler/test/LayoutStagedModelDataHandlerTest.java index bc33db20c79129..2097e2e1c63b3a 100644 --- a/modules/apps/layout/layout-admin-web-test/src/testIntegration/java/com/liferay/layout/admin/web/internal/exportimport/data/handler/test/LayoutStagedModelDataHandlerTest.java +++ b/modules/apps/layout/layout-admin-web-test/src/testIntegration/java/com/liferay/layout/admin/web/internal/exportimport/data/handler/test/LayoutStagedModelDataHandlerTest.java @@ -9,6 +9,9 @@ import com.liferay.asset.kernel.model.AssetCategory; import com.liferay.asset.kernel.model.AssetVocabulary; import com.liferay.asset.kernel.service.AssetCategoryLocalService; +import com.liferay.asset.list.constants.AssetListEntryTypeConstants; +import com.liferay.asset.list.model.AssetListEntry; +import com.liferay.asset.list.service.AssetListEntryLocalService; import com.liferay.asset.test.util.AssetTestUtil; import com.liferay.client.extension.constants.ClientExtensionEntryConstants; import com.liferay.client.extension.model.ClientExtensionEntry; @@ -44,11 +47,13 @@ import com.liferay.info.form.InfoForm; import com.liferay.info.item.InfoItemServiceRegistry; import com.liferay.info.item.provider.InfoItemFormProvider; +import com.liferay.item.selector.criteria.InfoListItemSelectorReturnType; import com.liferay.journal.constants.JournalArticleConstants; import com.liferay.journal.constants.JournalFolderConstants; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.service.JournalArticleLocalService; import com.liferay.journal.test.util.JournalTestUtil; +import com.liferay.layout.constants.LayoutTypeSettingsConstants; import com.liferay.layout.page.template.constants.LayoutPageTemplateEntryTypeConstants; import com.liferay.layout.page.template.model.LayoutPageTemplateEntry; import com.liferay.layout.page.template.service.LayoutPageTemplateEntryLocalService; @@ -70,6 +75,7 @@ import com.liferay.portal.kernel.model.Company; import com.liferay.portal.kernel.model.Group; import com.liferay.portal.kernel.model.Layout; +import com.liferay.portal.kernel.model.LayoutConstants; import com.liferay.portal.kernel.model.LayoutFriendlyURL; import com.liferay.portal.kernel.model.PortletPreferencesIds; import com.liferay.portal.kernel.model.StagedModel; @@ -79,6 +85,7 @@ import com.liferay.portal.kernel.repository.model.FileEntry; import com.liferay.portal.kernel.security.permission.ResourceActions; import com.liferay.portal.kernel.service.CompanyLocalService; +import com.liferay.portal.kernel.service.GroupLocalService; import com.liferay.portal.kernel.service.LayoutFriendlyURLLocalService; import com.liferay.portal.kernel.service.LayoutLocalService; import com.liferay.portal.kernel.service.PortletPreferencesLocalService; @@ -650,6 +657,85 @@ public void testStyleBookEntry() throws Exception { importedLayout.getStyleBookEntryId())); } + @Test + @TestInfo("LPS-139864") + public void testTypeCollectionLayout() throws Exception { + Group group = GroupTestUtil.addGroup(); + + AssetListEntry assetListEntry = + _assetListEntryLocalService.addAssetListEntry( + RandomTestUtil.randomString(), TestPropsValues.getUserId(), + group.getGroupId(), RandomTestUtil.randomString(), + AssetListEntryTypeConstants.TYPE_MANUAL, + ServiceContextTestUtil.getServiceContext(group.getGroupId())); + + Layout layout = _layoutLocalService.addLayout( + null, TestPropsValues.getUserId(), group.getGroupId(), false, + LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, 0, 0, + RandomTestUtil.randomLocaleStringMap(), null, + Collections.emptyMap(), Collections.emptyMap(), + Collections.emptyMap(), LayoutConstants.TYPE_COLLECTION, + UnicodePropertiesBuilder.put( + LayoutTypeSettingsConstants.KEY_PUBLISHED, "true" + ).put( + "collectionPK", assetListEntry.getAssetListEntryId() + ).put( + "collectionType", InfoListItemSelectorReturnType.class.getName() + ).buildString(), + false, false, Collections.emptyMap(), 0, + ServiceContextTestUtil.getServiceContext(group.getGroupId())); + + StagingLocalServiceUtil.enableLocalStaging( + TestPropsValues.getUserId(), group, true, false, + ServiceContextTestUtil.getServiceContext(group.getGroupId())); + + Group stagingGroup = group.getStagingGroup(); + + AssetListEntry stagingGroupAssetListEntry = + _assetListEntryLocalService.fetchAssetListEntryByUuidAndGroupId( + assetListEntry.getUuid(), stagingGroup.getGroupId()); + + Layout stagingGroupLayout = + _layoutLocalService.fetchLayoutByUuidAndGroupId( + layout.getUuid(), stagingGroup.getGroupId(), false); + + UnicodeProperties stagingGroupLayoutTypeSettingsUnicodeProperties = + stagingGroupLayout.getTypeSettingsProperties(); + + Assert.assertEquals( + stagingGroupAssetListEntry.getAssetListEntryId(), + GetterUtil.getLong( + stagingGroupLayoutTypeSettingsUnicodeProperties.getProperty( + "collectionPK"))); + Assert.assertEquals( + stagingGroupLayoutTypeSettingsUnicodeProperties.getProperty( + "collectionType"), + InfoListItemSelectorReturnType.class.getName()); + + AssetListEntry liveGroupAssetListEntry = + _assetListEntryLocalService.fetchAssetListEntryByUuidAndGroupId( + assetListEntry.getUuid(), group.getGroupId()); + + Layout liveGroupLayout = + _layoutLocalService.fetchLayoutByUuidAndGroupId( + layout.getUuid(), group.getGroupId(), false); + + UnicodeProperties liveGroupLayoutTypeSettingsUnicodeProperties = + liveGroupLayout.getTypeSettingsProperties(); + + Assert.assertEquals( + liveGroupAssetListEntry.getAssetListEntryId(), + GetterUtil.getLong( + liveGroupLayoutTypeSettingsUnicodeProperties.getProperty( + "collectionPK"))); + Assert.assertEquals( + liveGroupLayoutTypeSettingsUnicodeProperties.getProperty( + "collectionType"), + InfoListItemSelectorReturnType.class.getName()); + + _groupLocalService.deleteGroup(group); + } + @Test public void testTypeLinkToLayout() throws Exception { initExport(); @@ -1581,6 +1667,9 @@ private LayoutSEOEntry _updateLayoutSEOEntry(Layout layout) @Inject private AssetCategoryLocalService _assetCategoryLocalService; + @Inject + private AssetListEntryLocalService _assetListEntryLocalService; + @Inject private BackgroundTaskLocalService _backgroundTaskLocalService; @@ -1615,6 +1704,9 @@ private LayoutSEOEntry _updateLayoutSEOEntry(Layout layout) @Inject private FriendlyURLEntryLocalService _friendlyURLEntryLocalService; + @Inject + private GroupLocalService _groupLocalService; + @Inject private InfoItemServiceRegistry _infoItemServiceRegistry; diff --git a/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/contentpage/collectionpage/CollectionPagesWithStagingPageVersioning.testcase b/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/contentpage/collectionpage/CollectionPagesWithStagingPageVersioning.testcase deleted file mode 100644 index e136eab6f67f21..00000000000000 --- a/portal-web/test/functional/com/liferay/portalweb/tests/enduser/wem/layout/contentpage/collectionpage/CollectionPagesWithStagingPageVersioning.testcase +++ /dev/null @@ -1,141 +0,0 @@ -@component-name = "portal-page-management" -definition { - - property ci.retries.disabled = "true"; - property portal.release = "true"; - property portal.upstream = "true"; - property testray.main.component.name = "Content Pages"; - - static var randomSiteName = StringUtil.randomString(8); - - var siteURLKey = StringUtil.toLowerCase(${randomSiteName}); - - setUp { - task ("Set up virtual instance") { - TestCase.setUpPortalInstance(); - } - - task ("Sign in") { - User.firstLoginPG(); - } - - task ("Add a site") { - HeadlessSite.addSite(siteName = ${randomSiteName}); - } - } - - @description = "This is a test case for LPS-139864. Can enable local live in a site with different types of collection page." - @priority = 4 - test ActivateStagingPageVersioning { - task ("Add a manual collection for all types") { - JSONAssetlist.addManualAssetListEntryWithItemType( - groupName = ${randomSiteName}, - itemType = "All Types", - title = "Manual Collection"); - } - - task ("Add a dynamic collection for all types") { - JSONAssetlist.addDynamicAssetListEntryWithItemType( - groupName = ${randomSiteName}, - itemType = "All Types", - title = "Dynamic Collection"); - } - - task ("Add the first collection page based on manual collection") { - PagesAdmin.openPagesAdmin(siteURLKey = ${siteURLKey}); - - ContentPages.addCollectionPage( - collectionName = "Manual Collection", - pageName = "First Collection Page Name", - tabName = "Collections"); - } - - task ("Publish the first collection page") { - PageEditor.publish(); - } - - task ("Add the second collection page based on dynamic collection") { - ContentPages.addCollectionPage( - collectionName = "Dynamic Collection", - pageName = "Second Collection Page Name", - tabName = "Collections"); - } - - task ("Add a Button fragment above the Container then publish") { - PageEditor.addFragment( - collectionName = "Basic Components", - dropTarget = "Header", - fragmentName = "Button", - targetFragmentName = "Container"); - - PageEditor.publish(); - } - - task ("Add the third collection page based on collection provider") { - ContentPages.addCollectionPage( - collectionName = "Most Viewed Assets", - pageName = "Third Collection Page Name", - tabName = "Collection Providers"); - } - - task ("Add a HTML fragment above the Container without publish") { - PageEditor.addFragment( - collectionName = "Basic Components", - dropTarget = "Header", - fragmentName = "HTML", - targetFragmentName = "Container"); - } - - task ("Activate local live staging") { - JSONStaging.enableLocalStaging(groupName = ${randomSiteName}); - } - - task ("View the workflow message is not shown in staging site") { - for (var text : list "First,Second") { - ContentPagesNavigator.openViewContentPage( - pageName = "${text} Collection Page Name", - siteName = "${randomSiteName} Staging"); - - AssertElementNotPresent(locator1 = "Staging#STAGING_MENU_READY_FOR_PUBLICATION"); - } - } - - task ("View the Heading fragment is shown in live site") { - ContentPagesNavigator.openViewContentPage( - pageName = "First Collection Page Name", - siteName = ${randomSiteName}); - - ContentPages.viewFragmentText( - fragmentName = "heading", - id = "element-text", - text = "Manual Collection"); - } - - task ("View the Button and Heading fragments are shown in live site") { - ContentPagesNavigator.openViewContentPage( - pageName = "Second Collection Page Name", - siteName = ${randomSiteName}); - - ContentPages.viewFragmentText( - fragmentName = "button", - id = "link", - text = "Go Somewhere"); - - ContentPages.viewFragmentText( - fragmentName = "heading", - id = "element-text", - text = "Dynamic Collection"); - } - - task ("Assert View action of the third collection page is disabled in live site") { - PagesAdmin.openPagesAdmin(siteURLKey = ${siteURLKey}); - - PagesAdmin.openPageEllipsisMenu(pageName = "Third Collection Page Name"); - - AssertVisible( - key_menuItem = "View", - locator1 = "MenuItem#DISABLED_MENU_ITEM"); - } - } - -} \ No newline at end of file