From 599a548b7d5f84a0971d398d0415fe5d4a7acf86 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:28:53 +1000 Subject: [PATCH 1/2] Patterns: Reinstate template parts mode spec --- .../site-editor/template-parts-mode.spec.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/e2e/specs/site-editor/template-parts-mode.spec.js diff --git a/test/e2e/specs/site-editor/template-parts-mode.spec.js b/test/e2e/specs/site-editor/template-parts-mode.spec.js new file mode 100644 index 00000000000000..a8945794ae6a8d --- /dev/null +++ b/test/e2e/specs/site-editor/template-parts-mode.spec.js @@ -0,0 +1,51 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'Template Parts for Classic themes', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'emptyhybrid' ); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.activateTheme( 'twentytwentyone' ); + } ); + + test( 'can access template parts list page', async ( { admin, page } ) => { + await admin.visitAdminPage( + 'site-editor.php', + 'postType=wp_template_part&path=/wp_template_part/all' + ); + + await expect( + page.getByRole( 'table' ).getByRole( 'link', { name: 'header' } ) + ).toBeVisible(); + } ); + + test( 'can view a template part', async ( { admin, editor, page } ) => { + await admin.visitAdminPage( + 'site-editor.php', + 'postType=wp_template_part&path=/wp_template_part/all' + ); + + const templatePart = page + .getByRole( 'table' ) + .getByRole( 'link', { name: 'header' } ); + + await expect( templatePart ).toBeVisible(); + await templatePart.click(); + + await expect( + page.getByRole( 'region', { name: 'Editor content' } ) + ).toBeVisible(); + + await editor.canvas.click( 'body' ); + + await expect( + editor.canvas.getByRole( 'document', { + name: 'Block: Site Title', + } ) + ).toBeVisible(); + } ); +} ); From a8c3007b281210ad9bcb23dc34b3bb29d44a4d1c Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Thu, 20 Jul 2023 15:27:38 +1000 Subject: [PATCH 2/2] Merge tests into new hybrid-theme spec --- .../specs/site-editor/hybrid-theme.spec.js | 37 ++++++++++++++ .../site-editor/template-parts-mode.spec.js | 51 ------------------- 2 files changed, 37 insertions(+), 51 deletions(-) delete mode 100644 test/e2e/specs/site-editor/template-parts-mode.spec.js diff --git a/test/e2e/specs/site-editor/hybrid-theme.spec.js b/test/e2e/specs/site-editor/hybrid-theme.spec.js index 9d5def2caf71fc..993ca5eb6bde86 100644 --- a/test/e2e/specs/site-editor/hybrid-theme.spec.js +++ b/test/e2e/specs/site-editor/hybrid-theme.spec.js @@ -38,4 +38,41 @@ test.describe( 'Hybrid theme', () => { page.locator( 'role=menuitem[name="Create template part"i]' ) ).toBeHidden(); } ); + + test( 'can access template parts list page', async ( { admin, page } ) => { + await admin.visitAdminPage( + 'site-editor.php', + 'postType=wp_template_part&path=/wp_template_part/all' + ); + + await expect( + page.getByRole( 'table' ).getByRole( 'link', { name: 'header' } ) + ).toBeVisible(); + } ); + + test( 'can view a template part', async ( { admin, editor, page } ) => { + await admin.visitAdminPage( + 'site-editor.php', + 'postType=wp_template_part&path=/wp_template_part/all' + ); + + const templatePart = page + .getByRole( 'table' ) + .getByRole( 'link', { name: 'header' } ); + + await expect( templatePart ).toBeVisible(); + await templatePart.click(); + + await expect( + page.getByRole( 'region', { name: 'Editor content' } ) + ).toBeVisible(); + + await editor.canvas.click( 'body' ); + + await expect( + editor.canvas.getByRole( 'document', { + name: 'Block: Site Title', + } ) + ).toBeVisible(); + } ); } ); diff --git a/test/e2e/specs/site-editor/template-parts-mode.spec.js b/test/e2e/specs/site-editor/template-parts-mode.spec.js deleted file mode 100644 index a8945794ae6a8d..00000000000000 --- a/test/e2e/specs/site-editor/template-parts-mode.spec.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); - -test.describe( 'Template Parts for Classic themes', () => { - test.beforeAll( async ( { requestUtils } ) => { - await requestUtils.activateTheme( 'emptyhybrid' ); - } ); - - test.afterAll( async ( { requestUtils } ) => { - await requestUtils.activateTheme( 'twentytwentyone' ); - } ); - - test( 'can access template parts list page', async ( { admin, page } ) => { - await admin.visitAdminPage( - 'site-editor.php', - 'postType=wp_template_part&path=/wp_template_part/all' - ); - - await expect( - page.getByRole( 'table' ).getByRole( 'link', { name: 'header' } ) - ).toBeVisible(); - } ); - - test( 'can view a template part', async ( { admin, editor, page } ) => { - await admin.visitAdminPage( - 'site-editor.php', - 'postType=wp_template_part&path=/wp_template_part/all' - ); - - const templatePart = page - .getByRole( 'table' ) - .getByRole( 'link', { name: 'header' } ); - - await expect( templatePart ).toBeVisible(); - await templatePart.click(); - - await expect( - page.getByRole( 'region', { name: 'Editor content' } ) - ).toBeVisible(); - - await editor.canvas.click( 'body' ); - - await expect( - editor.canvas.getByRole( 'document', { - name: 'Block: Site Title', - } ) - ).toBeVisible(); - } ); -} );