diff --git a/backport-changelog/6.9/8063.md b/backport-changelog/6.9/8063.md index 9b83fa2b4a46ad..8b400119ad0f5e 100644 --- a/backport-changelog/6.9/8063.md +++ b/backport-changelog/6.9/8063.md @@ -9,3 +9,4 @@ https://github.com/WordPress/wordpress-develop/pull/8063 * https://github.com/WordPress/gutenberg/pull/72011 * https://github.com/WordPress/gutenberg/pull/72141 * https://github.com/WordPress/gutenberg/pull/72223 +* https://github.com/WordPress/gutenberg/pull/72285 diff --git a/lib/compat/wordpress-6.9/class-gutenberg-rest-templates-controller.php b/lib/compat/wordpress-6.9/class-gutenberg-rest-templates-controller.php deleted file mode 100644 index 53dbb6ca50c39c..00000000000000 --- a/lib/compat/wordpress-6.9/class-gutenberg-rest-templates-controller.php +++ /dev/null @@ -1,16 +0,0 @@ - return { isBlockBasedTheme: select( coreStore ).getCurrentTheme()?.is_block_theme, - canCreateTemplate: select( coreStore ).canUser( 'read', { + canCreateTemplate: select( coreStore ).canUser( 'create', { kind: 'postType', name: templateType, } ), @@ -470,10 +469,6 @@ export function useSiteEditorNavigationCommands() { name: 'core/edit-site/navigate-templates', hook: getNavigationCommandLoaderPerTemplate( 'wp_template' ), } ); - useCommandLoader( { - name: 'core/edit-site/navigate-templates', - hook: getNavigationCommandLoaderPerTemplate( 'wp_registered_template' ), - } ); useCommandLoader( { name: 'core/edit-site/navigate-template-parts', hook: getNavigationCommandLoaderPerTemplate( 'wp_template_part' ), diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index 583f9632ac4a17..6faad5041ec858 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -93,16 +93,6 @@ export function receiveEntityRecords( edits, meta ) { - // If we receive an auto-draft template, pretend it's already published. - if ( kind === 'postType' && name === 'wp_template' ) { - records = ( Array.isArray( records ) ? records : [ records ] ).map( - ( record ) => - record.status === 'auto-draft' - ? { ...record, status: 'publish' } - : record - ); - } - // Auto drafts should not have titles, but some plugins rely on them so we can't filter this // on the server. if ( kind === 'postType' ) { @@ -709,11 +699,6 @@ export const saveEntityRecord = ), }; } - // Unless there is no persisted record, set the status to - // publish. - if ( name === 'wp_template' && persistedRecord ) { - edits.status = 'publish'; - } updatedRecord = await __unstableFetch( { path, method: recordId ? 'PUT' : 'POST', diff --git a/packages/core-data/src/private-actions.js b/packages/core-data/src/private-actions.js index 0ed6e9748b552a..29af65ba137bf6 100644 --- a/packages/core-data/src/private-actions.js +++ b/packages/core-data/src/private-actions.js @@ -132,7 +132,3 @@ export const editMediaEntity = dispatch.__unstableReleaseStoreLock( lock ); } }; - -export function receiveTemplateAutoDraftId( target, id ) { - return { type: 'RECEIVE_TEMPLATE_AUTO_DRAFT_ID', target, id }; -} diff --git a/packages/core-data/src/private-selectors.ts b/packages/core-data/src/private-selectors.ts index d9bc2214c860c0..eb121b170e03a1 100644 --- a/packages/core-data/src/private-selectors.ts +++ b/packages/core-data/src/private-selectors.ts @@ -293,10 +293,3 @@ export const getTemplateId = createRegistrySelector( } ); } ); - -export function getTemplateAutoDraftId( - state: State, - staticTemplateId: string -) { - return state.templateAutoDraftId[ staticTemplateId ]; -} diff --git a/packages/core-data/src/reducer.js b/packages/core-data/src/reducer.js index 051dc884a3f079..2d53bf5762702b 100644 --- a/packages/core-data/src/reducer.js +++ b/packages/core-data/src/reducer.js @@ -628,12 +628,6 @@ export function registeredPostMeta( state = {}, action ) { return state; } -export function templateAutoDraftId( state = {}, action ) { - return action.type === 'RECEIVE_TEMPLATE_AUTO_DRAFT_ID' - ? { ...state, [ action.target ]: action.id } - : state; -} - export default combineReducers( { users, currentTheme, @@ -654,5 +648,4 @@ export default combineReducers( { navigationFallbackId, defaultTemplates, registeredPostMeta, - templateAutoDraftId, } ); diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index fd8a9c76b95f5f..53ff8520ce4c0d 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -248,30 +248,6 @@ getEntityRecord.shouldInvalidate = ( action, kind, name ) => { ); }; -export const getTemplateAutoDraftId = - ( staticTemplateId ) => - async ( { resolveSelect, dispatch } ) => { - const record = await resolveSelect.getEntityRecord( - 'postType', - 'wp_registered_template', - staticTemplateId - ); - const autoDraft = await dispatch.saveEntityRecord( - 'postType', - 'wp_template', - { - ...record, - id: undefined, - type: 'wp_template', - status: 'auto-draft', - } - ); - await dispatch.receiveTemplateAutoDraftId( - staticTemplateId, - autoDraft.id - ); - }; - /** * Requests an entity's record from the REST API. */ diff --git a/packages/core-data/src/selectors.ts b/packages/core-data/src/selectors.ts index c618a72afadf24..5844a2d21cb9fb 100644 --- a/packages/core-data/src/selectors.ts +++ b/packages/core-data/src/selectors.ts @@ -49,7 +49,6 @@ export interface State { userPatternCategories: Array< UserPatternCategory >; defaultTemplates: Record< string, string >; registeredPostMeta: Record< string, Object >; - templateAutoDraftId: Record< string, number | null >; } type EntityRecordKey = string | number; diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index 34a5d36e6fa10f..28707f3bcd9636 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -519,17 +519,6 @@ function Layout( { useMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode ); - const editableResolvedTemplateId = useSelect( - ( select ) => { - if ( typeof templateId !== 'string' ) { - return templateId; - } - return unlock( select( coreStore ) ).getTemplateAutoDraftId( - templateId - ); - }, - [ templateId ] - ); const [ paddingAppenderRef, paddingStyle ] = usePaddingAppender( enablePaddingAppender ); @@ -653,7 +642,7 @@ function Layout( { initialEdits={ initialEdits } postType={ currentPostType } postId={ currentPostId } - templateId={ editableResolvedTemplateId } + templateId={ templateId } className={ className } styles={ styles } forceIsDirty={ hasActiveMetaboxes } diff --git a/packages/edit-site/src/components/editor/use-resolve-edited-entity.js b/packages/edit-site/src/components/editor/use-resolve-edited-entity.js index 93ac9f19406e01..e0b89825ab4ff0 100644 --- a/packages/edit-site/src/components/editor/use-resolve-edited-entity.js +++ b/packages/edit-site/src/components/editor/use-resolve-edited-entity.js @@ -25,7 +25,6 @@ const postTypesWithoutParentTemplate = [ TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user, - 'wp_registered_template', ]; const authorizedPostTypes = [ 'page', 'post' ]; @@ -42,8 +41,6 @@ function getPostType( name ) { postType = TEMPLATE_POST_TYPE; } else if ( name === 'template-item' ) { postType = TEMPLATE_POST_TYPE; - } else if ( name === 'static-template-item' ) { - postType = 'wp_registered_template'; } else if ( name === 'page-item' || name === 'pages' ) { postType = 'page'; } else if ( name === 'post-item' || name === 'posts' ) { @@ -55,29 +52,14 @@ function getPostType( name ) { export function useResolveEditedEntity() { const { name, params = {}, query } = useLocation(); - const { postId: _postId = query?.postId } = params; // Fallback to query param for postId for list view routes. - const _postType = getPostType( name, _postId ) ?? query?.postType; + const { postId = query?.postId } = params; // Fallback to query param for postId for list view routes. + const postType = getPostType( name, postId ) ?? query?.postType; const homePage = useSelect( ( select ) => { const { getHomePage } = unlock( select( coreDataStore ) ); return getHomePage(); }, [] ); - const [ postType, postId ] = useSelect( - ( select ) => { - if ( _postType !== 'wp_registered_template' ) { - return [ _postType, _postId ]; - } - return [ - TEMPLATE_POST_TYPE, - unlock( select( coreDataStore ) ).getTemplateAutoDraftId( - _postId - ), - ]; - }, - [ _postType, _postId ] - ); - /** * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId * in order to match the frontend as closely as possible in the site editor. diff --git a/packages/edit-site/src/components/page-templates/index.js b/packages/edit-site/src/components/page-templates/index.js index f3f7854724c478..7847c1a9901478 100644 --- a/packages/edit-site/src/components/page-templates/index.js +++ b/packages/edit-site/src/components/page-templates/index.js @@ -2,7 +2,8 @@ * WordPress dependencies */ import { Page } from '@wordpress/admin-ui'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; +import { decodeEntities } from '@wordpress/html-entities'; import { useState, useMemo, useCallback } from '@wordpress/element'; import { privateApis as corePrivateApis, @@ -12,10 +13,11 @@ import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { privateApis as editorPrivateApis } from '@wordpress/editor'; import { addQueryArgs } from '@wordpress/url'; -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { useEvent } from '@wordpress/compose'; import { useView } from '@wordpress/views'; -import { Button } from '@wordpress/components'; +import { Button, Modal } from '@wordpress/components'; +import { store as noticesStore } from '@wordpress/notices'; /** * Internal dependencies @@ -45,6 +47,8 @@ export default function PageTemplates() { const { path, query } = useLocation(); const { activeView = 'active', postId } = query; const [ selection, setSelection ] = useState( [ postId ] ); + const [ selectedRegisteredTemplate, setSelectedRegisteredTemplate ] = + useState( false ); const defaultView = useMemo( () => { return getDefaultView( activeView ); }, [ activeView ] ); @@ -207,15 +211,54 @@ export default function PageTemplates() { elements, } ); return _fields; - }, [ users, activeView ] ); + }, [ users, activeView, themeField ] ); const { data, paginationInfo } = useMemo( () => { return filterSortAndPaginate( records, view, fields ); }, [ records, view, fields ] ); + const { createSuccessNotice } = useDispatch( noticesStore ); + const onActionPerformed = useCallback( + ( actionId, items ) => { + switch ( actionId ) { + case 'duplicate-post': + { + const newItem = items[ 0 ]; + const _title = + typeof newItem.title === 'string' + ? newItem.title + : newItem.title?.rendered; + createSuccessNotice( + sprintf( + // translators: %s: Title of the created post or template, e.g: "Hello world". + __( '"%s" successfully created.' ), + decodeEntities( _title ) || __( '(no title)' ) + ), + { + type: 'snackbar', + id: 'duplicate-post-action', + actions: [ + { + label: __( 'Edit' ), + onClick: () => { + history.navigate( + `/${ newItem.type }/${ newItem.id }?canvas=edit` + ); + }, + }, + ], + } + ); + } + break; + } + }, + [ history, createSuccessNotice ] + ); const postTypeActions = usePostActions( { postType: TEMPLATE_POST_TYPE, context: 'list', + onActionPerformed, } ); const editAction = useEditPostAction(); const setActiveTemplateAction = useSetActiveTemplateAction(); @@ -235,6 +278,10 @@ export default function PageTemplates() { updateView( newView ); } ); + const duplicateAction = actions.find( + ( action ) => action.id === 'duplicate-post' + ); + return ( true } onClickItem={ ( item ) => { - history.navigate( - `/${ item.type }/${ item.id }?canvas=edit` - ); + if ( item.type === 'wp_registered_template' ) { + setSelectedRegisteredTemplate( item ); + } else { + history.navigate( + `/${ item.type }/${ item.id }?canvas=edit` + ); + } } } selection={ selection } defaultLayouts={ defaultLayouts } /> + { selectedRegisteredTemplate && duplicateAction && ( + setSelectedRegisteredTemplate() } + size="small" + > + setSelectedRegisteredTemplate() } + onActionPerformed={ ( [ item ] ) => { + history.navigate( + `/${ item.type }/${ item.id }?canvas=edit` + ); + } } + /> + + ) } ); } 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 b7fde2d056b2f3..f05fc19395e7a5 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 @@ -73,7 +73,13 @@ export default function DataviewsTemplatesSidebarContent() { icon={ layout } aria-current={ activeView === 'user' } > - { __( 'Custom templates' ) } + { + // Let's avoid calling them "custom templates" to avoid + // confusion. "Created" is closest to meaning database + // templates, created by users. + // https://developer.wordpress.org/themes/classic-themes/templates/page-template-files/#creating-custom-page-templates-for-global-use + __( 'Created templates' ) + } { firstItemPerAuthorText.map( ( template ) => { return ( diff --git a/packages/edit-site/src/components/site-editor-routes/index.js b/packages/edit-site/src/components/site-editor-routes/index.js index f1ab32b5e48d73..fe2210ae6e5e64 100644 --- a/packages/edit-site/src/components/site-editor-routes/index.js +++ b/packages/edit-site/src/components/site-editor-routes/index.js @@ -17,7 +17,7 @@ import { patternsRoute } from './patterns'; import { patternItemRoute } from './pattern-item'; import { templatePartItemRoute } from './template-part-item'; import { templatesRoute } from './templates'; -import { templateItemRoute, staticTemplateItemRoute } from './template-item'; +import { templateItemRoute } from './template-item'; import { pagesRoute } from './pages'; import { pageItemRoute } from './page-item'; import { stylebookRoute } from './stylebook'; @@ -27,7 +27,6 @@ const routes = [ pageItemRoute, pagesRoute, templateItemRoute, - staticTemplateItemRoute, templatesRoute, templatePartItemRoute, patternItemRoute, diff --git a/packages/edit-site/src/components/site-editor-routes/template-item.js b/packages/edit-site/src/components/site-editor-routes/template-item.js index 55c557a2b47a77..f800fe06ae022f 100644 --- a/packages/edit-site/src/components/site-editor-routes/template-item.js +++ b/packages/edit-site/src/components/site-editor-routes/template-item.js @@ -37,9 +37,3 @@ export const templateItemRoute = { path: '/wp_template/*postId', areas, }; - -export const staticTemplateItemRoute = { - name: 'static-template-item', - path: '/wp_registered_template/*postId', - areas, -}; diff --git a/packages/editor/src/components/post-template/create-new-template-modal.js b/packages/editor/src/components/post-template/create-new-template-modal.js index 574118271276bc..dcad49ca6ae7d7 100644 --- a/packages/editor/src/components/post-template/create-new-template-modal.js +++ b/packages/editor/src/components/post-template/create-new-template-modal.js @@ -99,6 +99,7 @@ export default function CreateNewTemplateModal( { onClose } ) { slug: kebabCase( title || DEFAULT_TITLE ) || 'wp-custom-template', content: newTemplateContent, title: title || DEFAULT_TITLE, + status: 'publish', } ); setIsBusy( false ); diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 36c0920c8f01ab..f90a3bfd1b10e8 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -334,12 +334,19 @@ async function templateActivationNotice( { select, registry } ) { return; } + const currentTheme = await registry + .resolveSelect( coreStore ) + .getCurrentTheme(); + const templateType = currentTheme?.default_template_types.find( + ( type ) => type.slug === slug + ); + await registry.dispatch( noticesStore ).createNotice( 'info', sprintf( - // translators: %s: template slug - __( 'This is a "%s" template. Do you want to activate it?' ), - slug + // translators: %s: The name (or slug) of the type of template. + __( 'Do you want to activate this "%s" template?' ), + templateType?.title ?? slug ), { id: 'template-activate-notice', diff --git a/packages/fields/src/actions/duplicate-post.tsx b/packages/fields/src/actions/duplicate-post.tsx index af1fb668a0c322..034ecf9d4182ac 100644 --- a/packages/fields/src/actions/duplicate-post.tsx +++ b/packages/fields/src/actions/duplicate-post.tsx @@ -142,6 +142,13 @@ const duplicatePost: Action< BasePost > = { return (
+ { item.type === 'wp_registered_template' && ( +
+ { __( + 'You are about to duplicate a bundled template. Changes will not be live until you activate the new template.' + ) } +
+ ) } { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/editor/blocks/post-comments-form.spec.js b/test/e2e/specs/editor/blocks/post-comments-form.spec.js index 96da063ba382a7..db75771dc09154 100644 --- a/test/e2e/specs/editor/blocks/post-comments-form.spec.js +++ b/test/e2e/specs/editor/blocks/post-comments-form.spec.js @@ -33,7 +33,7 @@ test.describe( 'Comments Form', () => { // Navigate to "Singular" post template await admin.visitSiteEditor( { postId: 'emptytheme//singular', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); diff --git a/test/e2e/specs/editor/various/block-bindings/post-meta.spec.js b/test/e2e/specs/editor/various/block-bindings/post-meta.spec.js index 611f88bde77473..afc348fdbfeeeb 100644 --- a/test/e2e/specs/editor/various/block-bindings/post-meta.spec.js +++ b/test/e2e/specs/editor/various/block-bindings/post-meta.spec.js @@ -25,7 +25,7 @@ test.describe( 'Post Meta source', () => { test.beforeEach( async ( { admin, editor } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/block-bindings//single-movie', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await editor.openDocumentSettingsSidebar(); @@ -300,7 +300,7 @@ test.describe( 'Post Meta source', () => { test.beforeEach( async ( { admin, editor } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/block-bindings//custom-template', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await editor.openDocumentSettingsSidebar(); diff --git a/test/e2e/specs/editor/various/pattern-overrides.spec.js b/test/e2e/specs/editor/various/pattern-overrides.spec.js index eb4be25b5e8d8a..d826dca5454310 100644 --- a/test/e2e/specs/editor/various/pattern-overrides.spec.js +++ b/test/e2e/specs/editor/various/pattern-overrides.spec.js @@ -251,7 +251,7 @@ test.describe( 'Pattern Overrides', () => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); diff --git a/test/e2e/specs/editor/various/write-design-mode.spec.js b/test/e2e/specs/editor/various/write-design-mode.spec.js index edeebebdee2051..1337fd9db30a80 100644 --- a/test/e2e/specs/editor/various/write-design-mode.spec.js +++ b/test/e2e/specs/editor/various/write-design-mode.spec.js @@ -13,7 +13,7 @@ test.describe.skip( 'Write/Design mode', () => { } ); await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/block-removal.spec.js b/test/e2e/specs/site-editor/block-removal.spec.js index 8dca99849d70f2..7fc547c19e59e3 100644 --- a/test/e2e/specs/site-editor/block-removal.spec.js +++ b/test/e2e/specs/site-editor/block-removal.spec.js @@ -15,7 +15,7 @@ test.describe( 'Site editor block removal prompt', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/browser-history.spec.js b/test/e2e/specs/site-editor/browser-history.spec.js index f5b73f110f43b1..511ec14e4298de 100644 --- a/test/e2e/specs/site-editor/browser-history.spec.js +++ b/test/e2e/specs/site-editor/browser-history.spec.js @@ -22,8 +22,9 @@ test.describe( 'Site editor browser history', () => { await page .locator( '.fields-field__title', { hasText: 'Index' } ) .click(); + await page.getByRole( 'button', { name: 'Duplicate' } ).click(); await expect( page ).toHaveURL( - '/wp-admin/site-editor.php?p=%2Fwp_registered_template%2Femptytheme%2F%2Findex&canvas=edit' + /\/wp-admin\/site-editor\.php\?p=%2Fwp_template%2F\d+&canvas=edit$/ ); // Navigate back to the template list diff --git a/test/e2e/specs/site-editor/font-library.spec.js b/test/e2e/specs/site-editor/font-library.spec.js index 63dc5d8e509d46..1824257df12fd3 100644 --- a/test/e2e/specs/site-editor/font-library.spec.js +++ b/test/e2e/specs/site-editor/font-library.spec.js @@ -12,7 +12,7 @@ test.describe( 'Font Library', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); @@ -57,7 +57,7 @@ test.describe( 'Font Library', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'twentytwentythree//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); @@ -137,7 +137,7 @@ test.describe( 'Font Library', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); @@ -219,7 +219,7 @@ test.describe( 'Font Library', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'twentytwentyfour//home', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/global-styles-sidebar.spec.js b/test/e2e/specs/site-editor/global-styles-sidebar.spec.js index 754e71813129a9..7f1b818df4ce0a 100644 --- a/test/e2e/specs/site-editor/global-styles-sidebar.spec.js +++ b/test/e2e/specs/site-editor/global-styles-sidebar.spec.js @@ -15,7 +15,7 @@ test.describe( 'Global styles sidebar', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/iframe-rendering.spec.js b/test/e2e/specs/site-editor/iframe-rendering.spec.js index 9306b3e27ca1d8..9c25ef504637e4 100644 --- a/test/e2e/specs/site-editor/iframe-rendering.spec.js +++ b/test/e2e/specs/site-editor/iframe-rendering.spec.js @@ -18,7 +18,7 @@ test.describe( 'Site editor iframe rendering mode', () => { } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); const compatMode = await editor.canvas diff --git a/test/e2e/specs/site-editor/multi-entity-saving.spec.js b/test/e2e/specs/site-editor/multi-entity-saving.spec.js index ba0f1f98e1eaef..cbc3bfde457a14 100644 --- a/test/e2e/specs/site-editor/multi-entity-saving.spec.js +++ b/test/e2e/specs/site-editor/multi-entity-saving.spec.js @@ -21,7 +21,7 @@ test.describe( 'Site Editor - Multi-entity save flow', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/push-to-global-styles.spec.js b/test/e2e/specs/site-editor/push-to-global-styles.spec.js index 2e0db238dd3db4..be62be111ed929 100644 --- a/test/e2e/specs/site-editor/push-to-global-styles.spec.js +++ b/test/e2e/specs/site-editor/push-to-global-styles.spec.js @@ -15,7 +15,7 @@ test.describe( 'Push to Global Styles button', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); diff --git a/test/e2e/specs/site-editor/settings-sidebar.spec.js b/test/e2e/specs/site-editor/settings-sidebar.spec.js index 099222c131077b..87e9023401109d 100644 --- a/test/e2e/specs/site-editor/settings-sidebar.spec.js +++ b/test/e2e/specs/site-editor/settings-sidebar.spec.js @@ -15,7 +15,7 @@ test.describe( 'Settings sidebar', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } ); @@ -63,7 +63,7 @@ test.describe( 'Settings sidebar', () => { await admin.visitSiteEditor( { postId: 'emptytheme//singular', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); diff --git a/test/e2e/specs/site-editor/site-editor-export.spec.js b/test/e2e/specs/site-editor/site-editor-export.spec.js index aa6a472204a6db..a0a56c18089cc2 100644 --- a/test/e2e/specs/site-editor/site-editor-export.spec.js +++ b/test/e2e/specs/site-editor/site-editor-export.spec.js @@ -22,7 +22,7 @@ test.describe( 'Site Editor Templates Export', () => { } ) => { await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await page diff --git a/test/e2e/specs/site-editor/style-variations.spec.js b/test/e2e/specs/site-editor/style-variations.spec.js index 9a718119fb6e94..53de08717226a4 100644 --- a/test/e2e/specs/site-editor/style-variations.spec.js +++ b/test/e2e/specs/site-editor/style-variations.spec.js @@ -36,7 +36,7 @@ test.describe( 'Global styles variations', () => { } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/style-variations//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); @@ -72,7 +72,7 @@ test.describe( 'Global styles variations', () => { } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/style-variations//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await siteEditorStyleVariations.browseStyles(); @@ -108,7 +108,7 @@ test.describe( 'Global styles variations', () => { } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/style-variations//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await siteEditorStyleVariations.browseStyles(); @@ -144,7 +144,7 @@ test.describe( 'Global styles variations', () => { } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/style-variations//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await siteEditorStyleVariations.browseStyles(); @@ -174,7 +174,7 @@ test.describe( 'Global styles variations', () => { } ) => { await admin.visitSiteEditor( { postId: 'gutenberg-test-themes/style-variations//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); await siteEditorStyleVariations.browseStyles(); diff --git a/test/e2e/specs/site-editor/template-registration.spec.js b/test/e2e/specs/site-editor/template-registration.spec.js index 9777f925de6364..b46affc731fcf6 100644 --- a/test/e2e/specs/site-editor/template-registration.spec.js +++ b/test/e2e/specs/site-editor/template-registration.spec.js @@ -53,6 +53,7 @@ test.describe( 'Block template registration', () => { // Verify the template contents are rendered in the editor. await page.getByText( 'Plugin Template' ).click(); + await page.getByRole( 'button', { name: 'Duplicate' } ).click(); await expect( editor.canvas.getByText( 'This is a plugin-registered template.' ) ).toBeVisible(); @@ -84,7 +85,7 @@ test.describe( 'Block template registration', () => { } ); const resetNotice = page .getByLabel( 'Dismiss this notice' ) - .getByText( `"Plugin Template" moved to the trash.` ); + .getByText( `"Plugin Template (Copy)" moved to the trash.` ); const savedButton = page.getByRole( 'button', { name: 'Saved', } ); @@ -194,6 +195,7 @@ test.describe( 'Block template registration', () => { 'Plugin Template' ); await page.getByText( 'Plugin Template' ).click(); + await page.getByRole( 'button', { name: 'Duplicate' } ).click(); await expect( editor.canvas.getByText( 'This is a plugin-registered template.' ) ).toBeVisible(); @@ -217,7 +219,7 @@ test.describe( 'Block template registration', () => { } ); const deletedNotice = page .getByLabel( 'Dismiss this notice' ) - .getByText( `"Plugin Template" moved to the trash.` ); + .getByText( `"Plugin Template (Copy)" moved to the trash.` ); const savedButton = page.getByRole( 'button', { name: 'Saved', } ); diff --git a/test/e2e/specs/site-editor/title.spec.js b/test/e2e/specs/site-editor/title.spec.js index 61ce0b20570a3d..8f6c5252c9f41b 100644 --- a/test/e2e/specs/site-editor/title.spec.js +++ b/test/e2e/specs/site-editor/title.spec.js @@ -19,7 +19,7 @@ test.describe( 'Site editor title', () => { // Navigate to a template. await admin.visitSiteEditor( { postId: 'emptytheme//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); const title = page diff --git a/test/e2e/specs/site-editor/zoom-out.spec.js b/test/e2e/specs/site-editor/zoom-out.spec.js index 74f64226932549..e8b708fc80f3cd 100644 --- a/test/e2e/specs/site-editor/zoom-out.spec.js +++ b/test/e2e/specs/site-editor/zoom-out.spec.js @@ -90,7 +90,7 @@ test.describe( 'Zoom Out', () => { test.beforeEach( async ( { admin } ) => { await admin.visitSiteEditor( { postId: 'twentytwentyfour//index', - postType: 'wp_registered_template', + postType: 'wp_template', canvas: 'edit', } ); } );