From bf9e018078545ac637350cf19f526e16dd65b760 Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Wed, 20 Sep 2023 07:11:50 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20e2e=20test:=20=E2=80=9DWP=20Editor=20Meta?= =?UTF-8?q?=20Boxes=20>=20Should=20save=20the=20changes=E2=80=9D=20(#51884?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/plugins/wp-editor-meta-box.spec.js | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js index 13720de509e3c..c5eafdafe918d 100644 --- a/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js +++ b/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js @@ -20,31 +20,26 @@ test.describe( 'WP Editor Meta Boxes', () => { await admin.createNewPost(); // Add title to enable valid non-empty post save. - await editor.canvas.type( - 'role=textbox[name="Add title"i]', - 'Hello Meta' - ); + await editor.canvas + .locator( 'role=textbox[name="Add title"i]' ) + .type( 'Hello Meta' ); - // Type something. - await page.click( 'role=button[name="Text"i]' ); - await page.click( '#test_tinymce_id' ); - await page.keyboard.type( 'Typing in a metabox' ); - await page.type( '#test_tinymce_id-html', 'Typing in a metabox' ); - await page.click( 'role=button[name="Visual"i]' ); + // Switch tinymce to Text mode, first waiting for it to initialize + // because otherwise it will flip back to Visual mode once initialized. + await page.locator( '#test_tinymce_id_ifr' ).waitFor(); + await page.locator( 'role=button[name="Text"i]' ).click(); - await editor.publishPost(); + // Type something in the tinymce Text mode textarea. + const metaBoxField = page.locator( '#test_tinymce_id' ); + await metaBoxField.type( 'Typing in a metabox' ); - // Close the publish panel so that it won't cover the tinymce editor. - await page.click( - 'role=region[name="Editor publish"i] >> role=button[name="Close panel"i]' - ); + // Switch tinymce back to Visual mode. + await page.locator( 'role=button[name="Visual"i]' ).click(); - await expect( page.locator( '.edit-post-layout' ) ).toBeVisible(); - - await page.click( 'role=button[name="Text"i]' ); + await editor.publishPost(); + await page.reload(); - // Expect the typed text on the tinymce editor - const content = page.locator( '#test_tinymce_id' ); - await expect( content ).toHaveValue( 'Typing in a metabox' ); + // Expect the typed text in the tinymce Text mode textarea. + await expect( metaBoxField ).toHaveValue( 'Typing in a metabox' ); } ); } );