diff --git a/packages/edit-site/src/components/add-new-pattern/index.js b/packages/edit-site/src/components/add-new-pattern/index.js index 0d25ff67bf4482..8c051d5ca51ec3 100644 --- a/packages/edit-site/src/components/add-new-pattern/index.js +++ b/packages/edit-site/src/components/add-new-pattern/index.js @@ -5,13 +5,12 @@ import { DropdownMenu } from '@wordpress/components'; import { useState, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { plus, symbol, symbolFilled, upload } from '@wordpress/icons'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { useDispatch } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { privateApis as editPatternsPrivateApis, store as patternsStore, } from '@wordpress/patterns'; -import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; /** @@ -31,15 +30,12 @@ const { CreatePatternModal, useAddPatternCategory } = unlock( editPatternsPrivateApis ); -export default function AddNewPattern() { +export default function AddNewPattern( { canCreateParts, canCreatePatterns } ) { const history = useHistory(); const { params } = useLocation(); const [ showPatternModal, setShowPatternModal ] = useState( false ); const [ showTemplatePartModal, setShowTemplatePartModal ] = useState( false ); - const isBlockBasedTheme = useSelect( ( select ) => { - return select( coreStore ).getCurrentTheme()?.is_block_theme; - }, [] ); const { createPatternFromFile } = unlock( useDispatch( patternsStore ) ); const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); @@ -73,15 +69,17 @@ export default function AddNewPattern() { setShowTemplatePartModal( false ); } - const controls = [ - { + const controls = []; + + if ( canCreatePatterns ) { + controls.push( { icon: symbol, onClick: () => setShowPatternModal( true ), title: __( 'Create pattern' ), - }, - ]; + } ); + } - if ( isBlockBasedTheme ) { + if ( canCreateParts ) { controls.push( { icon: symbolFilled, onClick: () => setShowTemplatePartModal( true ), @@ -89,13 +87,15 @@ export default function AddNewPattern() { } ); } - controls.push( { - icon: upload, - onClick: () => { - patternUploadInputRef.current.click(); - }, - title: __( 'Import pattern from JSON' ), - } ); + if ( canCreatePatterns ) { + controls.push( { + icon: upload, + onClick: () => { + patternUploadInputRef.current.click(); + }, + title: __( 'Import pattern from JSON' ), + } ); + } const { categoryMap, findOrCreateTerm } = useAddPatternCategory(); return ( diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index 96354d809bd835..bce9043a77e1b0 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -12,7 +12,7 @@ import { useIsSiteEditorLoading } from './hooks'; import Editor from '../editor'; import PagePages from '../page-pages'; import PagePatterns from '../page-patterns'; -import PageTemplatesTemplateParts from '../page-templates-template-parts'; +import PageTemplates from '../page-templates'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles'; import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main'; @@ -24,10 +24,6 @@ import SidebarNavigationScreenPattern from '../sidebar-navigation-screen-pattern import SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns'; import SidebarNavigationScreenNavigationMenu from '../sidebar-navigation-screen-navigation-menu'; import DataViewsSidebarContent from '../sidebar-dataviews'; -import { - TEMPLATE_POST_TYPE, - TEMPLATE_PART_POST_TYPE, -} from '../../utils/constants'; const { useLocation, useHistory } = unlock( routerPrivateApis ); @@ -108,22 +104,12 @@ export default function useLayoutAreas() { return { key: 'templates-list', areas: { - sidebar: ( - - ), - content: ( - - ), + sidebar: , + content: , preview: isListLayout && ( ), - mobile: ( - - ), + mobile: , }, widths: { content: isListLayout ? 380 : undefined, @@ -132,30 +118,19 @@ export default function useLayoutAreas() { } // Template parts + /* + * This is for legacy reasons, as the template parts are now part of the patterns screen. + * However, hybrid themes (classic themes that support template parts) still access this URL. + * While there are plans to make them use the patterns screen instead, we cannot do it for now. + * See discussion at https://github.com/WordPress/gutenberg/pull/60689 + */ if ( path === '/wp_template_part/all' ) { - const isListLayout = isCustom !== 'true' && layout === 'list'; return { key: 'template-parts', areas: { - sidebar: ( - - ), - content: ( - - ), - preview: isListLayout && ( - - ), - mobile: ( - - ), - }, - widths: { - content: isListLayout ? 380 : undefined, + sidebar: , + content: , + mobile: , }, }; } diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index 1f8521071530cc..76cfce98627fc1 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -50,6 +50,7 @@ import { LAYOUT_LIST, PATTERN_TYPES, TEMPLATE_PART_POST_TYPE, + TEMPLATE_PART_ALL_AREAS_CATEGORY, PATTERN_SYNC_TYPES, PATTERN_DEFAULT_CATEGORY, ENUMERATION_TYPE, @@ -68,7 +69,7 @@ import { unlock } from '../../lock-unlock'; import usePatterns from './use-patterns'; import PatternsHeader from './header'; import { useLink } from '../routes/link'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock( blockEditorPrivateApis @@ -310,9 +311,21 @@ function Title( { item, categoryId } ) { } export default function DataviewsPatterns() { - const { categoryType, categoryId = PATTERN_DEFAULT_CATEGORY } = - getQueryArgs( window.location.href ); - const type = categoryType || PATTERN_TYPES.theme; + const { + categoryType, + categoryId: categoryIdFromURL, + path, + } = getQueryArgs( window.location.href ); + const type = + categoryType || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_POST_TYPE + : PATTERN_TYPES.theme ); + const categoryId = + categoryIdFromURL || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_ALL_AREAS_CATEGORY + : PATTERN_DEFAULT_CATEGORY ); const [ view, setView ] = useState( DEFAULT_VIEW ); const isUncategorizedThemePatterns = type === PATTERN_TYPES.theme && categoryId === 'uncategorized'; diff --git a/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js b/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js deleted file mode 100644 index 2a7bbda971013a..00000000000000 --- a/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * WordPress dependencies - */ -import { privateApis as routerPrivateApis } from '@wordpress/router'; -import { useSelect } from '@wordpress/data'; -import { store as coreStore } from '@wordpress/core-data'; -import { useState, memo } from '@wordpress/element'; -import { Button } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import { unlock } from '../../lock-unlock'; -import { store as editSiteStore } from '../../store'; -import CreateTemplatePartModal from '../create-template-part-modal'; -import { TEMPLATE_PART_POST_TYPE } from '../../utils/constants'; - -const { useHistory } = unlock( routerPrivateApis ); - -function AddNewTemplatePart() { - const { canCreate, postType } = useSelect( ( select ) => { - const { supportsTemplatePartsMode } = - select( editSiteStore ).getSettings(); - return { - canCreate: ! supportsTemplatePartsMode, - postType: select( coreStore ).getPostType( - TEMPLATE_PART_POST_TYPE - ), - }; - }, [] ); - const [ isModalOpen, setIsModalOpen ] = useState( false ); - const history = useHistory(); - - if ( ! canCreate || ! postType ) { - return null; - } - - return ( - <> - - { isModalOpen && ( - setIsModalOpen( false ) } - blocks={ [] } - onCreate={ ( templatePart ) => { - setIsModalOpen( false ); - history.push( { - postId: templatePart.id, - postType: TEMPLATE_PART_POST_TYPE, - canvas: 'edit', - } ); - } } - onError={ () => setIsModalOpen( false ) } - /> - ) } - - ); -} - -export default memo( AddNewTemplatePart ); diff --git a/packages/edit-site/src/components/page-templates-template-parts/hooks.js b/packages/edit-site/src/components/page-templates/hooks.js similarity index 100% rename from packages/edit-site/src/components/page-templates-template-parts/hooks.js rename to packages/edit-site/src/components/page-templates/hooks.js diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates/index.js similarity index 86% rename from packages/edit-site/src/components/page-templates-template-parts/index.js rename to packages/edit-site/src/components/page-templates/index.js index fabcb0a6412186..a64cb63cfbc8c4 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates/index.js @@ -44,7 +44,6 @@ import { import usePatternSettings from '../page-patterns/use-pattern-settings'; import { unlock } from '../../lock-unlock'; -import AddNewTemplatePart from './add-new-template-part'; const { usePostActions } = unlock( editorPrivateApis ); @@ -175,10 +174,7 @@ function Preview( { item, viewType } ) { onClick={ onClick } aria-label={ item.title?.rendered || item.title } > - { isEmpty && - ( item.type === TEMPLATE_POST_TYPE - ? __( 'Empty template' ) - : __( 'Empty template part' ) ) } + { isEmpty && __( 'Empty template' ) } { ! isEmpty && ( @@ -199,7 +195,7 @@ const TEMPLATE_ACTIONS = [ 'delete-template', ]; -export default function PageTemplatesTemplateParts( { postType } ) { +export default function PageTemplates() { const { params } = useLocation(); const { activeView = 'all', layout } = params; const defaultView = useMemo( () => { @@ -239,7 +235,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { const { records, isResolving: isLoadingData } = useEntityRecords( 'postType', - postType, + TEMPLATE_POST_TYPE, { per_page: -1, } @@ -271,8 +267,8 @@ export default function PageTemplatesTemplateParts( { postType } ) { } ) ); }, [ records ] ); - const fields = useMemo( () => { - const _fields = [ + const fields = useMemo( + () => [ { header: __( 'Preview' ), id: 'preview', @@ -284,10 +280,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { enableSorting: false, }, { - header: - postType === TEMPLATE_POST_TYPE - ? __( 'Template' ) - : __( 'Template Part' ), + header: __( 'Template' ), id: 'title', getValue: ( { item } ) => item.title?.rendered, render: ( { item } ) => ( @@ -297,9 +290,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { enableHiding: false, enableGlobalSearch: true, }, - ]; - if ( postType === TEMPLATE_POST_TYPE ) { - _fields.push( { + { header: __( 'Description' ), id: 'description', render: ( { item } ) => { @@ -324,23 +315,21 @@ export default function PageTemplatesTemplateParts( { postType } ) { minWidth: 320, enableSorting: false, enableGlobalSearch: true, - } ); - } - // TODO: The plan is to support fields reordering, which would require an API like `order` or something - // similar. With the aforementioned API we wouldn't need to construct the fields array like this. - _fields.push( { - header: __( 'Author' ), - id: 'author', - getValue: ( { item } ) => item.author_text, - render: ( { item } ) => { - return ; }, - type: ENUMERATION_TYPE, - elements: authors, - width: '1%', - } ); - return _fields; - }, [ postType, authors, view.type ] ); + { + header: __( 'Author' ), + id: 'author', + getValue: ( { item } ) => item.author_text, + render: ( { item } ) => { + return ; + }, + type: ENUMERATION_TYPE, + elements: authors, + width: '1%', + }, + ], + [ authors, view.type ] + ); const { data, paginationInfo } = useMemo( () => { return filterSortAndPaginate( records, view, fields ); @@ -385,19 +374,9 @@ export default function PageTemplatesTemplateParts( { postType } ) { return ( - ) : ( - - ) - } + className="edit-site-page-templates" + title={ __( 'Templates' ) } + actions={ } > { + return !! select( editSiteStore ).getSettings() + .supportsTemplatePartsMode; + }, [] ); - // The absence of a category type in the query params for template parts - // indicates the user has arrived at the template part via the "manage all" - // page and the back button should return them to that list page. + /** + * This sidebar needs to temporarily accomodate two different "URLs" backpaths: + * + * 1. path = /patterns + * Block based themes. Also classic themes can access this URL, though it's not linked anywhere. + * + * 2. path = /wp_template_part/all + * Classic themes with support for block-template-parts. We need to list only Template Parts in this case. + * The URL is accessible from the Appearance > Template Parts menu. + * + * Depending on whether the theme supports block-template-parts, we go back to Patterns or Template screens. + * This is temporary. We aim to consolidate to /patterns. + */ const backPath = - ! categoryType && postType === TEMPLATE_PART_POST_TYPE + isTemplatePartsMode && postType === 'wp_template_part' ? { path: '/wp_template_part/all' } : { path: '/patterns' }; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js index 3c88da7990e1ae..dfdfbd87d22008 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js @@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import useEditedEntityRecord from '../use-edited-entity-record'; import useNavigationMenuContent from './use-navigation-menu-content'; import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer'; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js index 894cd5f8048183..49274a0435bafa 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js @@ -11,9 +11,10 @@ export default function CategoryItem( { isActive, label, type, + path = '/patterns', } ) { const linkInfo = useLink( { - path: '/patterns', + path, categoryType: type, categoryId: id, } ); diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index cb823422480a0a..d795bfb9a893a5 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -5,7 +5,6 @@ import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, } from '@wordpress/components'; -import { useViewportMatch } from '@wordpress/compose'; import { getTemplatePartIcon } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; import { getQueryArgs } from '@wordpress/url'; @@ -17,20 +16,19 @@ import { file } from '@wordpress/icons'; * Internal dependencies */ import AddNewPattern from '../add-new-pattern'; -import SidebarNavigationItem from '../sidebar-navigation-item'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import CategoryItem from './category-item'; import { PATTERN_DEFAULT_CATEGORY, PATTERN_TYPES, TEMPLATE_PART_POST_TYPE, + TEMPLATE_PART_ALL_AREAS_CATEGORY, } from '../../utils/constants'; -import { useLink } from '../routes/link'; import usePatternCategories from './use-pattern-categories'; import useTemplatePartAreas from './use-template-part-areas'; -import { store as editSiteStore } from '../../store'; function CategoriesGroup( { + path, templatePartAreas, patternCategories, currentCategory, @@ -42,15 +40,16 @@ function CategoriesGroup( { templateParts?.length || 0 ) .reduce( ( acc, val ) => acc + val, 0 ) } icon={ getTemplatePartIcon() } /* no name, so it provides the fallback icon */ label={ __( 'All template parts' ) } - id={ 'all-parts' } + id={ TEMPLATE_PART_ALL_AREAS_CATEGORY } type={ TEMPLATE_PART_POST_TYPE } isActive={ - currentCategory === 'all-parts' && + currentCategory === TEMPLATE_PART_ALL_AREAS_CATEGORY && currentType === TEMPLATE_PART_POST_TYPE } /> @@ -58,6 +57,7 @@ function CategoriesGroup( { ( [ area, { label, templateParts } ] ) => ( ( select( coreStore ).getCurrentTheme()?.is_block_theme, [] ); - const isTemplatePartsMode = useSelect( ( select ) => { - const settings = select( editSiteStore ).getSettings(); - return !! settings.supportsTemplatePartsMode; - }, [] ); - - const templatePartsLink = useLink( { - path: '/wp_template_part/all', - // If a classic theme that supports template parts accessed - // the Patterns page directly, preserve that state in the URL. - didAccessPatternsPage: - ! isBlockBasedTheme && isTemplatePartsMode ? 1 : undefined, - } ); - - const footer = ! isMobileViewport ? ( - - { ( isBlockBasedTheme || isTemplatePartsMode ) && ( - - { __( 'Manage all template parts' ) } - - ) } - - ) : undefined; + /** + * This sidebar needs to temporarily accomodate two different "URLs": + * + * 1. path = /patterns + * Block based themes. Also classic themes can access this URL, though it's not linked anywhere. + * + * 2. path = /wp_template_part/all + * Classic themes with support for block-template-parts. We need to list only Template Parts in this case. + * The URL is accessible from the Appearance > Template Parts menu. + * + * This is temporary. We aim to consolidate to /patterns. + */ return ( } - footer={ footer } + title={ + isTemplatePartsPath + ? __( 'Manage template parts' ) + : __( 'Patterns' ) + } + description={ + isTemplatePartsPath + ? __( + 'Create new template parts, or reset any customizations made to the template parts supplied by your theme.' + ) + : __( + 'Manage what patterns are available when editing the site.' + ) + } + actions={ + ( isBlockBasedTheme || ! isTemplatePartsPath ) && ( + + ) + } content={ <> - { isLoading && __( 'Loading patterns…' ) } + { isLoading && __( 'Loading items…' ) } { ! isLoading && ( <> { ! hasTemplateParts && ! hasPatterns && ( - - { __( - 'No template parts or patterns found' - ) } - + { __( 'No items found' ) } ) } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index 1ab45a1566cea0..ff12434b278952 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -17,7 +17,7 @@ import useEditedEntityRecord from '../use-edited-entity-record'; import { unlock } from '../../lock-unlock'; import { store as editSiteStore } from '../../store'; import SidebarButton from '../sidebar-button'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import TemplateActions from '../template-actions'; import HomeTemplateDetails from './home-template-details'; import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer'; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js index dd7d8dc507873d..e7f11f07e82a20 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js @@ -9,8 +9,9 @@ import { __experimentalItemGroup as ItemGroup } from '@wordpress/components'; * Internal dependencies */ import DataViewItem from '../sidebar-dataviews/dataview-item'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import { layout } from '@wordpress/icons'; +import { TEMPLATE_POST_TYPE } from '../../utils/constants'; const EMPTY_ARRAY = []; @@ -30,10 +31,9 @@ function TemplateDataviewItem( { template, isActive } ) { export default function DataviewsTemplatesSidebarContent( { activeView, - postType, title, } ) { - const { records } = useEntityRecords( 'postType', postType, { + const { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, { per_page: -1, } ); const firstItemPerAuthorText = useMemo( () => { diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js index 04774f081163df..d48314d1f36e64 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js @@ -2,64 +2,32 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { useSelect } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; /** * Internal dependencies */ import SidebarNavigationScreen from '../sidebar-navigation-screen'; -import { store as editSiteStore } from '../../store'; -import { - TEMPLATE_POST_TYPE, - TEMPLATE_PART_POST_TYPE, -} from '../../utils/constants'; import { unlock } from '../../lock-unlock'; import DataviewsTemplatesSidebarContent from './content'; -const config = { - [ TEMPLATE_POST_TYPE ]: { - title: __( 'Manage templates' ), - description: __( - 'Create new templates, or reset any customizations made to the templates supplied by your theme.' - ), - contentTitle: __( 'All templates' ), - }, - [ TEMPLATE_PART_POST_TYPE ]: { - title: __( 'Manage template parts' ), - description: __( - 'Create new template parts, or reset any customizations made to the template parts supplied by your theme.' - ), - backPath: { path: '/patterns' }, - contentTitle: __( 'All template parts' ), - }, -}; - const { useLocation } = unlock( routerPrivateApis ); -export default function SidebarNavigationScreenTemplatesBrowse( { postType } ) { +export default function SidebarNavigationScreenTemplatesBrowse() { const { - params: { didAccessPatternsPage, activeView = 'all' }, + params: { activeView = 'all' }, } = useLocation(); - const isTemplatePartsMode = useSelect( ( select ) => { - return !! select( editSiteStore ).getSettings() - .supportsTemplatePartsMode; - }, [] ); - return ( } /> diff --git a/packages/edit-site/src/style.scss b/packages/edit-site/src/style.scss index 32ad64f34fb514..96b8271b25552a 100644 --- a/packages/edit-site/src/style.scss +++ b/packages/edit-site/src/style.scss @@ -10,7 +10,7 @@ @import "./components/page/style.scss"; @import "./components/page-pages/style.scss"; @import "./components/page-patterns/style.scss"; -@import "./components/page-templates-template-parts/style.scss"; +@import "./components/page-templates/style.scss"; @import "./components/table/style.scss"; @import "./components/sidebar-edit-mode/style.scss"; @import "./components/sidebar-edit-mode/page-panels/style.scss"; diff --git a/test/e2e/specs/site-editor/hybrid-theme.spec.js b/test/e2e/specs/site-editor/hybrid-theme.spec.js index 3cb9f0685abe5b..bbef68f72eed64 100644 --- a/test/e2e/specs/site-editor/hybrid-theme.spec.js +++ b/test/e2e/specs/site-editor/hybrid-theme.spec.js @@ -19,7 +19,7 @@ test.describe( 'Hybrid theme', () => { ); await expect( - page.getByRole( 'link', { name: 'header' } ) + page.getByText( 'header', { exact: true } ) ).toBeVisible(); } ); @@ -29,7 +29,7 @@ test.describe( 'Hybrid theme', () => { 'postType=wp_template_part&path=/wp_template_part/all' ); - const templatePart = page.getByRole( 'link', { name: 'header' } ); + const templatePart = page.getByText( 'header', { exact: true } ); await expect( templatePart ).toBeVisible(); await templatePart.click();