Skip to content

typeInRichText test helper accounts for inner HTML tags #52520

@dcalhoun

Description

@dcalhoun

What problem does this address?

The typeInRichText test helper for mobile integration tests accounts for wrapping HTML tags (via temporary removal), but it does not account for HTML tags within the rich text text string (e.g. A <bold>great</bold> statement.). This makes it difficult to target a specific cursor position in the rich text field without manual, brittle calculations to account for the presence and length of inner HTML tags.

A <bold>great</bold> statement. (Raw string)
       |
       |
   ==========
    Targeted
     Cursor
    Position
   ==========
       |
       |
A GREAT statement.              (Rendered string, where uppercase represents bolded text)

The lack of this support makes it difficult to create automated integration tests that require typing within a rich text value that contains formatting tags, e.g. bold, italic, br, etc. This limitation was discussed in wordpress-mobile/test-cases#147 (comment).

What is your proposed solution?

Expand the typeInRichText to parse inner HTML tags. We would likely need to temporarily remove tags to calculate the targeted cursor position in a "visually rendered" version of the text string, then reintroduce the tags, taking into account if the text selection spanned across one or more tag thresholds (e.g. text selection beginning within a tag, but ending outside of it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Mobile App - i.e. Android or iOSNative mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)[Type] Automated TestingTesting infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions