diff --git a/modules/apps/layout/layout-type-controller/layout-type-controller-test/src/testIntegration/java/com/liferay/layout/type/controller/content/internal/layout/type/controller/test/ContentLayoutTypeControllerTest.java b/modules/apps/layout/layout-type-controller/layout-type-controller-test/src/testIntegration/java/com/liferay/layout/type/controller/content/internal/layout/type/controller/test/ContentLayoutTypeControllerTest.java index 5b4ad0f1dbe4e6..e53a31bfb43e8f 100644 --- a/modules/apps/layout/layout-type-controller/layout-type-controller-test/src/testIntegration/java/com/liferay/layout/type/controller/content/internal/layout/type/controller/test/ContentLayoutTypeControllerTest.java +++ b/modules/apps/layout/layout-type-controller/layout-type-controller-test/src/testIntegration/java/com/liferay/layout/type/controller/content/internal/layout/type/controller/test/ContentLayoutTypeControllerTest.java @@ -175,6 +175,87 @@ public void testContentLayoutTypeControllerDraftViewWithPreviewDraftPermission() LayoutTestUtil.addTypeContentLayout(_group), Constants.VIEW)); } + @Test + public void testContentLayoutTypeControllerMainContentDiv() + throws Exception { + + Layout layout = LayoutTestUtil.addTypeContentLayout(_group); + + FragmentEntry fragmentEntry = + _fragmentCollectionContributorRegistry.getFragmentEntry( + "BASIC_COMPONENT-heading"); + + ContentLayoutTestUtil.addFragmentEntryLinkToLayout( + null, fragmentEntry.getCss(), fragmentEntry.getConfiguration(), + fragmentEntry.getFragmentEntryId(), fragmentEntry.getHtml(), + fragmentEntry.getJs(), layout.fetchDraftLayout(), + fragmentEntry.getFragmentEntryKey(), fragmentEntry.getType(), null, + 0, + _segmentsExperienceLocalService.fetchDefaultSegmentsExperienceId( + layout.getPlid())); + + ContentLayoutTestUtil.publishLayout(layout.fetchDraftLayout(), layout); + + layout = _layoutLocalService.getLayout(layout.getPlid()); + + String html = ContentLayoutTestUtil.getRenderLayoutHTML( + layout, _layoutServiceContextHelper, _layoutStructureProvider, + _segmentsExperienceLocalService.fetchDefaultSegmentsExperienceId( + layout.getPlid())); + + Assert.assertFalse(html.contains("main-content")); + + LayoutPageTemplateEntry layoutPageTemplateEntry = + _layoutPageTemplateEntryLocalService.addLayoutPageTemplateEntry( + null, TestPropsValues.getUserId(), _group.getGroupId(), + LayoutPageTemplateConstants. + PARENT_LAYOUT_PAGE_TEMPLATE_COLLECTION_ID_DEFAULT, + StringUtil.randomString(), + LayoutPageTemplateEntryTypeConstants.MASTER_LAYOUT, 0, + WorkflowConstants.STATUS_DRAFT, + ServiceContextTestUtil.getServiceContext(_group.getGroupId())); + + layout = _layoutLocalService.updateMasterLayoutPlid( + layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), + layoutPageTemplateEntry.getPlid()); + + html = ContentLayoutTestUtil.getRenderLayoutHTML( + layout, _layoutServiceContextHelper, _layoutStructureProvider, + _segmentsExperienceLocalService.fetchDefaultSegmentsExperienceId( + layout.getPlid())); + + Assert.assertTrue( + html.startsWith( + "