Make WordPress Core

Changeset 56089


Ignore:
Timestamp:
06/28/2023 10:45:16 AM (2 years ago)
Author:
Clorith
Message:

Build/Test Tools: Switch frame container when testing block editor output.

When the block editor is rendered, the editor content is wrapped inside an iframe tag; The tool used to run End to End (E2E) tests, Puppeteer, puts all such frames into separate containers, but the initial test was checking if the parent page had a given selector, which was leading to timeout failures. By actively switching the container to the iframe wrapper,and setting it as the active context, it helps ensure the expected selectors can be found, and its content can be verrified.

See #58592.
Props joemcgill, SergeyBiryukov, talldanwp, oglekler, Clorith.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/e2e/specs/edit-posts.test.js

    r55392 r56089  
    2828        await page.waitForSelector( '#the-list .type-post' );
    2929
    30         // Expect there to be one row in the post list.
    31         const posts = await page.$$( '#the-list .type-post' );
    32         expect( posts.length ).toBe( 1 );
     30        // Wait for the editor iframe to load, and switch to it as the active content frame.
     31        const editorFrame = await page.waitForSelector( 'iframe[name="editor-canvas"]' );
    3332
    34         const [ firstPost ] = posts;
     33        const innerFrame = await editorFrame.contentFrame();
    3534
    36         // Expect the title of the post to be correct.
    37         const postTitle = await firstPost.$x(
    38             `//a[contains(@class, "row-title")][contains(text(), "${ title }")]`
     35        // Wait for title field to render onscreen.
     36        await innerFrame.waitForSelector( '.editor-post-title__input' );
     37
     38        // Expect to now be in the editor with the correct post title shown.
     39        const editorPostTitleInput = await innerFrame.$x(
     40            `//h1[contains(@class, "editor-post-title__input")][contains(text(), "${ title }")]`
    3941        );
    4042        expect( postTitle.length ).toBe( 1 );
Note: See TracChangeset for help on using the changeset viewer.