-
Notifications
You must be signed in to change notification settings - Fork 4.8k
typeInRichText test helper accounts for inner HTML tags #52520
Description
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).