Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/e2e/iOS/__tests__/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,23 @@ describe('Caret', () => {
expect(selectionTextContent).toBe('new')
expect(childrenTexts).toEqual(['foo', 'bar'])
})

it('Focus is prevented after clearing the cursor', async () => {
await newThought('Hello')
await hideKeyboardByTappingDone()

// Use a native WebDriver click on the inner anchor to clear the cursor.
// A synthetic tap() (performActions pointer events) does not fire the real
// click event that HomeLink's fastClick onClick handler relies on, so the
// cursor would never be cleared.
await browser.$('[data-testid="home"] a').click()

await tap(await waitForEditable('Hello'), { horizontalTapLine: 'right', x: 6, y: 60, pointerType: 'touch' })

// Wait for focus to be cleared and activeElement to be body
await waitUntil(() => browser.execute(() => document.activeElement === document.body))

const activeElementIsBody = await browser.execute(() => document.activeElement === document.body)
expect(activeElementIsBody).toBe(true)
})
})
6 changes: 4 additions & 2 deletions src/e2e/iOS/helpers/tap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { Element } from 'webdriverio'
interface Options {
// Where in the horizontal line (inside) of the target node should be tapped
horizontalTapLine?: 'left' | 'right'
// Pointer type to use for the tap action. Defaults to 'mouse'.
pointerType?: 'mouse' | 'touch'
// Specify specific node on editable to tap. Overrides horizontalClickLine
offset?: number
// Number of pixels of x offset to add to the tap coordinates
Expand All @@ -21,7 +23,7 @@ interface Options {
*/
const tap = async (
nodeHandle: Element,
{ horizontalTapLine = 'left', offset, x = 0, y = 0, releaseDelayMs = 100 }: Options = {},
{ horizontalTapLine = 'left', offset, x = 0, y = 0, pointerType = 'mouse', releaseDelayMs = 100 }: Options = {},
) => {
// Ensure element exists and has an elementId
const exists = await nodeHandle.isExisting()
Expand Down Expand Up @@ -98,7 +100,7 @@ const tap = async (
{
type: 'pointer',
id: 'pointer1',
parameters: { pointerType: 'mouse' },
parameters: { pointerType },
actions: [
{
type: 'pointerMove',
Expand Down
Loading