From 7bc7fcff52d5dca61777a3fd26cee67ae7bd33d7 Mon Sep 17 00:00:00 2001 From: "Marius L. J" Date: Wed, 28 Jun 2023 10:57:48 +0000 Subject: [PATCH] Build/Test Tools: Switch frame container when testing block editor output. The initial commit added the frame lookup within the wrong test, this follow-up restores the previous test runner, and adds the container lookup to the correct test. Follow-up to [56089]. See #58592. git-svn-id: https://develop.svn.wordpress.org/trunk@56090 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/e2e/specs/edit-posts.test.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/e2e/specs/edit-posts.test.js b/tests/e2e/specs/edit-posts.test.js index 0dce05163f..5c07019f4d 100644 --- a/tests/e2e/specs/edit-posts.test.js +++ b/tests/e2e/specs/edit-posts.test.js @@ -27,17 +27,15 @@ describe( 'Edit Posts', () => { await page.waitForSelector( '#the-list .type-post' ); - // Wait for the editor iframe to load, and switch to it as the active content frame. - const editorFrame = await page.waitForSelector( 'iframe[name="editor-canvas"]' ); + // Expect there to be one row in the post list. + const posts = await page.$$( '#the-list .type-post' ); + expect( posts.length ).toBe( 1 ); - const innerFrame = await editorFrame.contentFrame(); + const [ firstPost ] = posts; - // Wait for title field to render onscreen. - await innerFrame.waitForSelector( '.editor-post-title__input' ); - - // Expect to now be in the editor with the correct post title shown. - const editorPostTitleInput = await innerFrame.$x( - `//h1[contains(@class, "editor-post-title__input")][contains(text(), "${ title }")]` + // Expect the title of the post to be correct. + const postTitle = await firstPost.$x( + `//a[contains(@class, "row-title")][contains(text(), "${ title }")]` ); expect( postTitle.length ).toBe( 1 ); } ); @@ -56,14 +54,16 @@ describe( 'Edit Posts', () => { ); await editLink.click(); - // Edit the post. - await page.waitForNavigation(); + // Wait for the editor iframe to load, and switch to it as the active content frame. + const editorFrame = await page.waitForSelector( 'iframe[name="editor-canvas"]' ); + + const innerFrame = await editorFrame.contentFrame(); // Wait for title field to render onscreen. - await page.waitForSelector( '.editor-post-title__input' ); + await innerFrame.waitForSelector( '.editor-post-title__input' ); // Expect to now be in the editor with the correct post title shown. - const editorPostTitleInput = await page.$x( + const editorPostTitleInput = await innerFrame.$x( `//h1[contains(@class, "editor-post-title__input")][contains(text(), "${ title }")]` ); expect( editorPostTitleInput.length ).toBe( 1 );